[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)
----------------
ldionne wrote:

```suggestion
#if defined(_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR) && _LIBCPP_STD_VER >= 20
```

This simple change makes it easier to understand that the primary purpose of this block is to satisfy the request of the ABI macro.

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


More information about the libcxx-commits mailing list