[libcxx-commits] [libcxx] [libcxx] makes `expected` trivially assignable when both members are … (PR #74768)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 7 13:50:41 PST 2023


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 97f3be2c5a0295632321141bdc001d4f81821958 d9ffc415f43e2a05b6d55483709b882adb34ccc6 -- libcxx/include/__expected/expected.h libcxx/test/std/utilities/expected/expected.expected/assign/assign.copy.pass.cpp libcxx/test/std/utilities/expected/expected.expected/assign/assign.move.pass.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/__expected/expected.h b/libcxx/include/__expected/expected.h
index 128369fc1b..3d5fef5952 100644
--- a/libcxx/include/__expected/expected.h
+++ b/libcxx/include/__expected/expected.h
@@ -285,17 +285,12 @@ private:
   }
 
   static constexpr bool __is_trivially_move_assignable =
-      is_trivially_move_constructible_v<_Tp> &&
-      is_trivially_move_assignable_v<_Tp> &&
-      is_trivially_move_constructible_v<_Err> &&
-      is_trivially_move_assignable_v<_Err>;
+      is_trivially_move_constructible_v<_Tp> && is_trivially_move_assignable_v<_Tp> &&
+      is_trivially_move_constructible_v<_Err> && is_trivially_move_assignable_v<_Err>;
 
   static constexpr bool __is_trivially_copy_assignable =
-      __is_trivially_move_assignable &&
-      is_trivially_copy_constructible_v<_Tp> &&
-      is_trivially_copy_assignable_v<_Tp> &&
-      is_trivially_copy_constructible_v<_Err> &&
-      is_trivially_copy_assignable_v<_Err>;
+      __is_trivially_move_assignable && is_trivially_copy_constructible_v<_Tp> && is_trivially_copy_assignable_v<_Tp> &&
+      is_trivially_copy_constructible_v<_Err> && is_trivially_copy_assignable_v<_Err>;
 
 public:
   // [expected.object.assign], assignment
@@ -305,18 +300,12 @@ public:
     requires __is_trivially_copy_assignable
   = default;
 
-  _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected& __rhs)
-    noexcept(is_nothrow_copy_assignable_v<_Tp> &&
-             is_nothrow_copy_constructible_v<_Tp> &&
-             is_nothrow_copy_assignable_v<_Err> &&
-             is_nothrow_copy_constructible_v<_Err>) // strengthened
-    requires(is_copy_assignable_v<_Tp> &&
-             is_copy_constructible_v<_Tp> &&
-             is_copy_assignable_v<_Err> &&
-             is_copy_constructible_v<_Err> &&
-             !__is_trivially_copy_assignable &&
-             (is_nothrow_move_constructible_v<_Tp> ||
-              is_nothrow_move_constructible_v<_Err>))
+  _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected& __rhs) noexcept(
+      is_nothrow_copy_assignable_v<_Tp> && is_nothrow_copy_constructible_v<_Tp> && is_nothrow_copy_assignable_v<_Err> &&
+      is_nothrow_copy_constructible_v<_Err>) // strengthened
+    requires(is_copy_assignable_v<_Tp> && is_copy_constructible_v<_Tp> && is_copy_assignable_v<_Err> &&
+             is_copy_constructible_v<_Err> && !__is_trivially_copy_assignable &&
+             (is_nothrow_move_constructible_v<_Tp> || is_nothrow_move_constructible_v<_Err>))
   {
     if (__has_val_ && __rhs.__has_val_) {
       __union_.__val_ = __rhs.__union_.__val_;
@@ -336,18 +325,12 @@ public:
     requires __is_trivially_move_assignable
   = default;
 
-  _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(expected&& __rhs)
-    noexcept(is_nothrow_move_assignable_v<_Tp> &&
-             is_nothrow_move_constructible_v<_Tp> &&
-             is_nothrow_move_assignable_v<_Err> &&
-             is_nothrow_move_constructible_v<_Err>)
-    requires(is_move_constructible_v<_Tp> &&
-             is_move_assignable_v<_Tp> &&
-             is_move_constructible_v<_Err> &&
-             is_move_assignable_v<_Err> &&
-             !__is_trivially_move_assignable &&
-             (is_nothrow_move_constructible_v<_Tp> ||
-              is_nothrow_move_constructible_v<_Err>))
+  _LIBCPP_HIDE_FROM_ABI constexpr expected&
+  operator=(expected&& __rhs) noexcept(is_nothrow_move_assignable_v<_Tp> && is_nothrow_move_constructible_v<_Tp> &&
+                                       is_nothrow_move_assignable_v<_Err> && is_nothrow_move_constructible_v<_Err>)
+    requires(is_move_constructible_v<_Tp> && is_move_assignable_v<_Tp> && is_move_constructible_v<_Err> &&
+             is_move_assignable_v<_Err> && !__is_trivially_move_assignable &&
+             (is_nothrow_move_constructible_v<_Tp> || is_nothrow_move_constructible_v<_Err>))
   {
     if (__has_val_ && __rhs.__has_val_) {
       __union_.__val_ = std::move(__rhs.__union_.__val_);

``````````

</details>


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


More information about the libcxx-commits mailing list