[libcxx-commits] [libcxx] [libc++] Make std::pair trivially copyable if its members are (PR #89652)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 9 06:48:00 PDT 2024
================
@@ -74,6 +75,31 @@ struct _LIBCPP_TEMPLATE_VIS pair
_LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;
_LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;
+ // Make pair trivially copyable if we have a way to do it
+ static const bool __enable_defaulted_assignment_operators =
+ !is_reference<first_type>::value && !is_reference<second_type>::value;
+#if _LIBCPP_STD_VER >= 20 && defined(_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR)
+ static const bool __has_defaulted_members = __enable_defaulted_assignment_operators;
----------------
ldionne wrote:
I think I would rather repeat the reference condition here and below. It avoids creating two names for the same thing, which then causes confusion when reading the non-defaulted `operator=` overloads in the code far below.
https://github.com/llvm/llvm-project/pull/89652
More information about the libcxx-commits
mailing list