[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 Jul 18 07:49:13 PDT 2024


================
@@ -80,6 +81,31 @@ struct _LIBCPP_TEMPLATE_VIS pair
   _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;
   _LIBCPP_HIDE_FROM_ABI pair(pair&&)      = default;
 
+  // When we are requested for pair to be trivially copyable by the ABI macro, we use defaulted members
+  // if it is both legal to do it (i.e. no references) and we have a way to actually implement it, which requires
+  // the __enable_if__ attribute before C++20.
+#ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
+  static const bool __has_defaulted_members = !is_reference<first_type>::value && !is_reference<second_type>::value;
----------------
ldionne wrote:

To unblock the GDB pretty printer tests, you could avoid adding a static member here and fix it in a follow-up patch. Just as a tactical matter to land before LLVM 19 branches.

https://github.com/llvm/llvm-project/pull/89652


More information about the libcxx-commits mailing list