From 1d5f6a81f577d62688946e3ffbcf2643f03fa507 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 10 Jan 2019 20:06:11 +0000 Subject: [libcxx] Reorganize tests since the application of P0602R4 Summary: P0602R4 makes the special member functions of optional and variant conditionally trivial based on the types in the optional/variant. We already implemented that, but the tests were organized as if this were a non-standard extension. This patch reorganizes the tests in a way that makes more sense since this is not an extension anymore. Reviewers: EricWF, mpark, mclow.lists Subscribers: christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D54772 llvm-svn: 350884 --- .../variant.variant/variant.assign/copy.pass.cpp | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp') 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 775ecffeafb8..5ea7069f5d11 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 @@ -26,7 +26,7 @@ // template class variant; -// variant& operator=(variant const&); +// variant& operator=(variant const&); // constexpr in C++20 #include #include @@ -240,7 +240,8 @@ void test_copy_assignment_sfinae() { static_assert(!std::is_copy_assignable::value, ""); } - // The following tests are for not-yet-standardized behavior (P0602): + // Make sure we properly propagate triviality (see P0602R4). +#if TEST_STD_VER > 17 { using V = std::variant; static_assert(std::is_trivially_copy_assignable::value, ""); @@ -262,6 +263,7 @@ void test_copy_assignment_sfinae() { using V = std::variant; static_assert(std::is_trivially_copy_assignable::value, ""); } +#endif // > C++17 } void test_copy_assignment_empty_empty() { @@ -384,7 +386,8 @@ void test_copy_assignment_same_index() { } #endif // TEST_HAS_NO_EXCEPTIONS - // The following tests are for not-yet-standardized behavior (P0602): + // Make sure we properly propagate triviality, which implies constexpr-ness (see P0602R4). +#if TEST_STD_VER > 17 { struct { constexpr Result operator()() const { @@ -441,6 +444,7 @@ void test_copy_assignment_same_index() { static_assert(result.index == 1, ""); static_assert(result.value == 42, ""); } +#endif // > C++17 } void test_copy_assignment_different_index() { @@ -530,7 +534,8 @@ void test_copy_assignment_different_index() { } #endif // TEST_HAS_NO_EXCEPTIONS - // The following tests are for not-yet-standardized behavior (P0602): + // Make sure we properly propagate triviality, which implies constexpr-ness (see P0602R4). +#if TEST_STD_VER > 17 { struct { constexpr Result operator()() const { @@ -559,10 +564,11 @@ void test_copy_assignment_different_index() { static_assert(result.index == 1, ""); static_assert(result.value == 42, ""); } +#endif // > C++17 } template -constexpr bool test_constexpr_assign_extension_imp( +constexpr bool test_constexpr_assign_imp( std::variant&& v, ValueType&& new_value) { const std::variant cp( @@ -572,15 +578,17 @@ constexpr bool test_constexpr_assign_extension_imp( std::get(v) == std::get(cp); } -void test_constexpr_copy_assignment_extension() { - // The following tests are for not-yet-standardized behavior (P0602): +void test_constexpr_copy_assignment() { + // Make sure we properly propagate triviality, which implies constexpr-ness (see P0602R4). +#if TEST_STD_VER > 17 using V = std::variant; static_assert(std::is_trivially_copyable::value, ""); static_assert(std::is_trivially_copy_assignable::value, ""); - static_assert(test_constexpr_assign_extension_imp<0>(V(42l), 101l), ""); - static_assert(test_constexpr_assign_extension_imp<0>(V(nullptr), 101l), ""); - static_assert(test_constexpr_assign_extension_imp<1>(V(42l), nullptr), ""); - static_assert(test_constexpr_assign_extension_imp<2>(V(42l), 101), ""); + static_assert(test_constexpr_assign_imp<0>(V(42l), 101l), ""); + static_assert(test_constexpr_assign_imp<0>(V(nullptr), 101l), ""); + static_assert(test_constexpr_assign_imp<1>(V(42l), nullptr), ""); + static_assert(test_constexpr_assign_imp<2>(V(42l), 101), ""); +#endif // > C++17 } int main() { @@ -591,5 +599,5 @@ int main() { test_copy_assignment_different_index(); test_copy_assignment_sfinae(); test_copy_assignment_not_noexcept(); - test_constexpr_copy_assignment_extension(); + test_constexpr_copy_assignment(); } -- cgit v1.2.3