summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities
diff options
context:
space:
mode:
authorMichael Park <mcypark@gmail.com>2017-06-07 10:22:43 +0000
committerMichael Park <mcypark@gmail.com>2017-06-07 10:22:43 +0000
commita8b057483be7f3aa185e0fc9a3fc38c55c28f34f (patch)
tree1bbb006c58c257014df3664f756364c9f04e9636 /libcxx/test/std/utilities
parenteeb0aad8e4041fcc7baed47f0ca2777fcfddbc34 (diff)
downloadbcm5719-llvm-a8b057483be7f3aa185e0fc9a3fc38c55c28f34f.tar.gz
bcm5719-llvm-a8b057483be7f3aa185e0fc9a3fc38c55c28f34f.zip
Implement LWG 2904.
Summary: - Removed the move-constructibe requirement from copy-assignable. - Updated `__assign_alt` such that we direct initialize if `_Tp` can be `nothrow`-constructible from `_Arg`, or `_Tp`'s move construction can throw. Otherwise, construct a temporary and move it. - Updated the tests to remove the pre-LWG2904 path. Depends on D32671. Reviewers: EricWF, CaseyCarter Reviewed By: EricWF Differential Revision: https://reviews.llvm.org/D33965 llvm-svn: 304891
Diffstat (limited to 'libcxx/test/std/utilities')
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp26
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp29
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp8
3 files changed, 0 insertions, 63 deletions
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
index 69713662f3a..29228e562d6 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
@@ -199,12 +199,8 @@ void test_T_assignment_performs_construction() {
assert(false);
} catch (...) { /* ... */
}
-#ifdef _LIBCPP_VERSION // LWG2904
- assert(v.valueless_by_exception());
-#else // _LIBCPP_VERSION
assert(v.index() == 0);
assert(std::get<0>(v) == "hello");
-#endif // _LIBCPP_VERSION
}
{
using V = std::variant<ThrowsAssignT, std::string>;
@@ -213,28 +209,6 @@ void test_T_assignment_performs_construction() {
assert(v.index() == 0);
assert(std::get<0>(v).value == 42);
}
-#ifdef _LIBCPP_VERSION // LWG2904
- {
- // Test that nothrow direct construction is preferred to nothrow move.
- using V = std::variant<MoveCrashes, std::string>;
- V v(std::in_place_type<std::string>, "hello");
- v = 42;
- assert(v.index() == 0);
- assert(std::get<0>(v).value == 42);
- }
- {
- // Test that throwing direct construction is preferred to copy-and-move when
- // move can throw.
- using V = std::variant<ThrowsCtorTandMove, std::string>;
- V v(std::in_place_type<std::string>, "hello");
- try {
- v = 42;
- assert(false);
- } catch(...) { /* ... */
- }
- assert(v.valueless_by_exception());
- }
-#endif // _LIBCPP_VERSION // LWG2904
#endif // TEST_HAS_NO_EXCEPTIONS
}
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
index 9dfd09e94a9..068b9a20156 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
@@ -224,13 +224,7 @@ void test_copy_assignment_sfinae() {
}
{
using V = std::variant<int, CopyOnly>;
-#ifdef _LIBCPP_VERSION // LWG2904
- // variant only provides copy assignment when both the copy and move
- // constructors are well formed
- static_assert(!std::is_copy_assignable<V>::value, "");
-#else // _LIBCPP_VERSION // LWG2904
static_assert(std::is_copy_assignable<V>::value, "");
-#endif // _LIBCPP_VERSION // LWG2904
}
{
using V = std::variant<int, NoCopy>;
@@ -263,12 +257,10 @@ void test_copy_assignment_sfinae() {
using V = std::variant<int, TCopyAssignNTMoveAssign>;
static_assert(std::is_trivially_copy_assignable<V>::value, "");
}
-#ifndef _LIBCPP_VERSION // LWG2904
{
using V = std::variant<int, CopyOnly>;
static_assert(std::is_trivially_copy_assignable<V>::value, "");
}
-#endif // _LIBCPP_VERSION
}
void test_copy_assignment_empty_empty() {
@@ -487,41 +479,21 @@ void test_copy_assignment_different_index() {
assert(false);
} catch (...) { /* ... */
}
-#ifdef _LIBCPP_VERSION // LWG2904
- // Test that if copy construction throws then original value is unchanged.
- assert(v1.index() == 2);
- assert(std::get<2>(v1) == "hello");
-#else // _LIBCPP_VERSION // LWG2904
// Test that copy construction is used directly if move construction may throw,
// resulting in a valueless variant if copy throws.
assert(v1.valueless_by_exception());
-#endif // _LIBCPP_VERSION // LWG2904
}
{
using V = std::variant<int, MoveThrows, std::string>;
V v1(std::in_place_type<std::string>, "hello");
V v2(std::in_place_type<MoveThrows>);
assert(MoveThrows::alive == 1);
-#ifdef _LIBCPP_VERSION // LWG2904
- // Test that if move construction throws then the variant is left
- // valueless by exception.
- try {
- v1 = v2;
- assert(false);
- } catch (...) { /* ... */
- }
- assert(v1.valueless_by_exception());
- assert(v2.index() == 1);
- assert(MoveThrows::alive == 1);
-#else // _LIBCPP_VERSION // LWG2904
// Test that copy construction is used directly if move construction may throw.
v1 = v2;
assert(v1.index() == 1);
assert(v2.index() == 1);
assert(MoveThrows::alive == 2);
-#endif // _LIBCPP_VERSION // LWG2904
}
-#ifndef _LIBCPP_VERSION // LWG2904
{
// Test that direct copy construction is preferred when it cannot throw.
using V = std::variant<int, CopyCannotThrow, std::string>;
@@ -533,7 +505,6 @@ void test_copy_assignment_different_index() {
assert(v2.index() == 1);
assert(CopyCannotThrow::alive == 2);
}
-#endif // _LIBCPP_VERSION // LWG2904
{
using V = std::variant<int, CopyThrows, std::string>;
V v1(std::in_place_type<CopyThrows>);
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
index 77c122bf9f9..c410b4b8f3e 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
@@ -183,13 +183,7 @@ void test_move_assignment_sfinae() {
}
{
using V = std::variant<int, CopyOnly>;
-#ifdef _LIBCPP_VERSION // LWG2904
- // variant only provides move assignment when both the move constructor
- // and move assignment operator are well formed.
- static_assert(!std::is_move_assignable<V>::value, "");
-#else // _LIBCPP_VERSION // LWG2904
static_assert(std::is_move_assignable<V>::value, "");
-#endif // _LIBCPP_VERSION // LWG2904
}
{
using V = std::variant<int, NoCopy>;
@@ -232,12 +226,10 @@ void test_move_assignment_sfinae() {
using V = std::variant<int, TrivialCopyNontrivialMove>;
static_assert(!std::is_trivially_move_assignable<V>::value, "");
}
-#ifndef _LIBCPP_VERSION // LWG2904
{
using V = std::variant<int, CopyOnly>;
static_assert(std::is_trivially_move_assignable<V>::value, "");
}
-#endif // _LIBCPP_VERSION // LWG2904
}
void test_move_assignment_empty_empty() {
OpenPOWER on IntegriCloud