[libcxx-commits] [libcxx] [libcxx] makes `pair` conditionally trivially copyable for C++20 (PR #84811)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 11 11:35:22 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 725a0523a18ef1a75a6d4a010dc3debe1b08c9d1 dd4566d652c0b4b9c6145a2b54592fbb45b0378f -- libcxx/include/__config libcxx/include/__utility/pair.h libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_pair.pass.cpp libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h
index 7cded19bcf..28d7251e9a 100644
--- a/libcxx/include/__utility/pair.h
+++ b/libcxx/include/__utility/pair.h
@@ -32,11 +32,9 @@
#include <__type_traits/is_constructible.h>
#include <__type_traits/is_convertible.h>
#include <__type_traits/is_copy_assignable.h>
-#include <__type_traits/is_trivially_copy_assignable.h>
#include <__type_traits/is_default_constructible.h>
#include <__type_traits/is_implicitly_default_constructible.h>
#include <__type_traits/is_move_assignable.h>
-#include <__type_traits/is_trivially_move_assignable.h>
#include <__type_traits/is_nothrow_assignable.h>
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/is_nothrow_copy_assignable.h>
@@ -46,6 +44,8 @@
#include <__type_traits/is_object.h>
#include <__type_traits/is_same.h>
#include <__type_traits/is_swappable.h>
+#include <__type_traits/is_trivially_copy_assignable.h>
+#include <__type_traits/is_trivially_move_assignable.h>
#include <__type_traits/nat.h>
#include <__type_traits/remove_cvref.h>
#include <__type_traits/unwrap_ref.h>
@@ -72,10 +72,10 @@ struct __non_trivially_copyable_base {
};
#if _LIBCPP_STD_VER >= 20
-template<class _Tp>
+template <class _Tp>
concept __trivially_copy_assignable_object = is_trivially_copy_assignable_v<_Tp> && is_object_v<_Tp>;
-template<class _Tp>
+template <class _Tp>
concept __trivially_move_assignable_object = is_trivially_move_assignable_v<_Tp> && is_object_v<_Tp>;
#endif
@@ -250,10 +250,12 @@ struct _LIBCPP_TEMPLATE_VIS pair
# if _LIBCPP_STD_VER >= 20 && defined(_LIBCPP_ABI_PAIR_TRIVIALLY_COPYABLE)
_LIBCPP_HIDE_FROM_ABI pair& operator=(pair const& __p)
- requires __trivially_copy_assignable_object<first_type> && __trivially_copy_assignable_object<second_type> = default;
+ requires __trivially_copy_assignable_object<first_type> && __trivially_copy_assignable_object<second_type>
+ = default;
_LIBCPP_HIDE_FROM_ABI pair& operator=(pair&& __p)
- requires __trivially_move_assignable_object<first_type> && __trivially_move_assignable_object<second_type> = default;
-#endif
+ requires __trivially_move_assignable_object<first_type> && __trivially_move_assignable_object<second_type>
+ = default;
+# endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&
operator=(__conditional_t< is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value,
diff --git a/libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp
index baa472e1cf..9b924e9f0d 100644
--- a/libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp
+++ b/libcxx/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp
@@ -64,7 +64,7 @@ int main(int, char**)
static_assert(!std::is_trivially_copy_assignable<std::pair<int, int>>::value);
- return 0;
+ return 0;
}
struct Incomplete {};
``````````
</details>
https://github.com/llvm/llvm-project/pull/84811
More information about the libcxx-commits
mailing list