[PATCH] D32515: [libcxx] [test] Changes to accommodate LWG 2904 "Make variant move-assignment more exception safe"

Casey Carter via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 28 15:56:12 PDT 2017


CaseyCarter added a comment.

Added some inline notes for reviewers.



================
Comment at: test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp:195
     }
-    assert(v.valueless_by_exception());
+    assert(v.index() == 0);
+    assert(std::get<0>(v) == "hello");
----------------
Reviewer note: After LWG 2904, the assignment on 191 uses a new "emplace from temporary" path. The temporary creation now throws *before* v becomes valueless.


================
Comment at: test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp:168
-    // variant only provides copy assignment when both the copy and move
-    // constructors are well formed
     using V = std::variant<int, CopyOnly>;
----------------
Reviewer note: This comment is no longer true after LWG 2904 copy assignment no longer requires move constructible alternatives.


================
Comment at: test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp:121
-    // variant only provides move assignment when both the move constructor
-    // and move assignment operator are well formed.
     using V = std::variant<int, CopyOnly>;
----------------
Reviewer note: this comment is technically true even after LWG 2904, but no longer significant. `variant<int, CopyOnly>` *does* have an implicitly deleted move assignment operator, but `is_move_assignable_v<variant<int, CopyOnly>>` is nonetheless true after LWG 2904 since `variant<int, CopyOnly>` now has a viable *copy* assignment operator.


https://reviews.llvm.org/D32515





More information about the cfe-commits mailing list