diff --git a/libcxx/test/std/utilities/variant/variant.get/get_if_index.pass.cpp b/libcxx/test/std/utilities/variant/variant.get/get_if_index.pass.cpp index 3333d2a993ec98..09e2e85abe6681 100644 --- a/libcxx/test/std/utilities/variant/variant.get/get_if_index.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.get/get_if_index.pass.cpp @@ -44,30 +44,6 @@ void test_const_get_if() { static_assert(*std::get_if<1>(&v) == 42, ""); static_assert(std::get_if<0>(&v) == nullptr, ""); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *); - assert(std::get_if<0>(&v) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *); - assert(std::get_if<0>(&v) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), const int *); - assert(std::get_if<0>(&v) == &x); - } -#endif } void test_get_if() { @@ -91,37 +67,6 @@ void test_get_if() { assert(*std::get_if<1>(&v) == 42); assert(std::get_if<0>(&v) == nullptr); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *); - assert(std::get_if<0>(&v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), const int *); - assert(std::get_if<0>(&v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *); - assert(std::get_if<0>(&v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), const int *); - assert(std::get_if<0>(&v) == &x); - } -#endif } int main(int, char**) { diff --git a/libcxx/test/std/utilities/variant/variant.get/get_if_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.get/get_if_type.pass.cpp index b81e000f5bf6c3..c4fefc74e62a9c 100644 --- a/libcxx/test/std/utilities/variant/variant.get/get_if_type.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.get/get_if_type.pass.cpp @@ -42,30 +42,6 @@ void test_const_get_if() { static_assert(*std::get_if(&v) == 42, ""); static_assert(std::get_if(&v) == nullptr, ""); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get_if(&v)), int *); - assert(std::get_if(&v) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if(&v)), int *); - assert(std::get_if(&v) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if(&v)), const int *); - assert(std::get_if(&v) == &x); - } -#endif } void test_get_if() { @@ -89,37 +65,6 @@ void test_get_if() { assert(*std::get_if(&v) == 42); assert(std::get_if(&v) == nullptr); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get_if(&v)), int *); - assert(std::get_if(&v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get_if(&v)), const int *); - assert(std::get_if(&v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if(&v)), int *); - assert(std::get_if(&v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if(&v)), const int *); - assert(std::get_if(&v) == &x); - } -#endif } int main(int, char**) { diff --git a/libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp b/libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp index 97c7ff0ed09579..7ec9d8827f6b4b 100644 --- a/libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp @@ -60,30 +60,6 @@ void test_const_lvalue_get() { ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &); assert(std::get<1>(v) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &); - assert(&std::get<0>(v) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &); - assert(&std::get<0>(v) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); - assert(&std::get<0>(v) == &x); - } -#endif } void test_lvalue_get() { @@ -100,37 +76,6 @@ void test_lvalue_get() { ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &); assert(std::get<1>(v) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &); - assert(&std::get<0>(v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); - assert(&std::get<0>(v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &); - assert(&std::get<0>(v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &); - assert(&std::get<0>(v) == &x); - } -#endif } void test_rvalue_get() { @@ -147,39 +92,6 @@ void test_rvalue_get() { ASSERT_SAME_TYPE(decltype(std::get<1>(std::move(v))), const long &&); assert(std::get<1>(std::move(v)) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &); - assert(&std::get<0>(std::move(v)) == &x); - } - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &); - assert(&std::get<0>(std::move(v)) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &&); - int &&xref = std::get<0>(std::move(v)); - assert(&xref == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &&); - const int &&xref = std::get<0>(std::move(v)); - assert(&xref == &x); - } -#endif } void test_const_rvalue_get() { @@ -196,39 +108,6 @@ void test_const_rvalue_get() { ASSERT_SAME_TYPE(decltype(std::get<1>(std::move(v))), const long &&); assert(std::get<1>(std::move(v)) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &); - assert(&std::get<0>(std::move(v)) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &); - assert(&std::get<0>(std::move(v)) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &&); - int &&xref = std::get<0>(std::move(v)); - assert(&xref == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &&); - const int &&xref = std::get<0>(std::move(v)); - assert(&xref == &x); - } -#endif } template using Idx = std::integral_constant; diff --git a/libcxx/test/std/utilities/variant/variant.get/get_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.get/get_type.pass.cpp index d5e54d41e2f7b4..3485122c98f0b1 100644 --- a/libcxx/test/std/utilities/variant/variant.get/get_type.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.get/get_type.pass.cpp @@ -54,30 +54,6 @@ void test_const_lvalue_get() { ASSERT_SAME_TYPE(decltype(std::get(v)), const long &); assert(std::get(v) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get(v)), int &); - assert(&std::get(v) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get(v)), int &); - assert(&std::get(v) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get(v)), const int &); - assert(&std::get(v) == &x); - } -#endif } void test_lvalue_get() { @@ -94,37 +70,6 @@ void test_lvalue_get() { ASSERT_SAME_TYPE(decltype(std::get(v)), const long &); assert(std::get(v) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get(v)), int &); - assert(&std::get(v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get(v)), const int &); - assert(&std::get(v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get(v)), int &); - assert(&std::get(v) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get(v)), const int &); - assert(&std::get(v) == &x); - } -#endif } void test_rvalue_get() { @@ -142,41 +87,6 @@ void test_rvalue_get() { const long &&); assert(std::get(std::move(v)) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get(std::move(v))), int &); - assert(&std::get(std::move(v)) == &x); - } - { - using V = std::variant; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get(std::move(v))), - const int &); - assert(&std::get(std::move(v)) == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get(std::move(v))), int &&); - int &&xref = std::get(std::move(v)); - assert(&xref == &x); - } - { - using V = std::variant; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get(std::move(v))), - const int &&); - const int &&xref = std::get(std::move(v)); - assert(&xref == &x); - } -#endif } void test_const_rvalue_get() { @@ -194,41 +104,6 @@ void test_const_rvalue_get() { const long &&); assert(std::get(std::move(v)) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get(std::move(v))), int &); - assert(&std::get(std::move(v)) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get(std::move(v))), - const int &); - assert(&std::get(std::move(v)) == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get(std::move(v))), int &&); - int &&xref = std::get(std::move(v)); - assert(&xref == &x); - } - { - using V = std::variant; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get(std::move(v))), - const int &&); - const int &&xref = std::get(std::move(v)); - assert(&xref == &x); - } -#endif } template struct identity { using type = Tp; }; diff --git a/libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp b/libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp index be1a0c960d1cee..31b9b76213c45c 100644 --- a/libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.pass.cpp @@ -62,16 +62,6 @@ int main(int, char**) { test(); test(); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - test(); - test(); - test(); - test(); - test(); - } -#endif return 0; } 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 b38b10d89dfd7e..4b9eaba2d2ba81 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 @@ -155,16 +155,6 @@ void test_T_assignment_sfinae() { static_assert(std::is_assignable::value, "regression on user-defined conversions in operator="); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - static_assert(!std::is_assignable::value, "ambiguous"); - } - { - using V = std::variant; - static_assert(!std::is_assignable::value, "ambiguous"); - } -#endif // TEST_VARIANT_HAS_NO_REFERENCES } void test_T_assignment_basic() { @@ -204,25 +194,6 @@ void test_T_assignment_basic() { assert(v.index() == 1); assert(std::get<1>(v) == nullptr); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - int x = 42; - V v(43l); - v = x; - assert(v.index() == 0); - assert(&std::get<0>(v) == &x); - v = std::move(x); - assert(v.index() == 1); - assert(&std::get<1>(v) == &x); - // 'long' is selected by FUN(const int &) since 'const int &' cannot bind - // to 'int&'. - const int &cx = x; - v = cx; - assert(v.index() == 2); - assert(std::get<2>(v) == 42); - } -#endif // TEST_VARIANT_HAS_NO_REFERENCES } void test_T_assignment_performs_construction() { diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp index 6b7de888884986..142da1d820d9a7 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp @@ -36,10 +36,17 @@ struct NoThrowT { NoThrowT(int) noexcept(true) {} }; -struct AnyConstructible { template AnyConstructible(T&&) {} }; -struct NoConstructible { NoConstructible() = delete; }; +struct AnyConstructible { + template + AnyConstructible(T&&) {} +}; +struct NoConstructible { + NoConstructible() = delete; +}; template -struct RValueConvertibleFrom { RValueConvertibleFrom(T&&) {} }; +struct RValueConvertibleFrom { + RValueConvertibleFrom(T&&) {} +}; void test_T_ctor_noexcept() { { @@ -59,12 +66,11 @@ void test_T_ctor_sfinae() { } { using V = std::variant; - static_assert(!std::is_constructible::value, "ambiguous"); + static_assert(!std::is_constructible::value, "ambiguous"); } { - using V = std::variant; - static_assert(!std::is_constructible::value, - "no matching constructor"); + using V = std::variant; + static_assert(!std::is_constructible::value, "no matching constructor"); } { using V = std::variant; @@ -72,8 +78,7 @@ void test_T_ctor_sfinae() { } { using V = std::variant, bool>; - static_assert(!std::is_constructible>::value, - "no explicit bool in constructor"); + static_assert(!std::is_constructible>::value, "no explicit bool in constructor"); struct X { operator void*(); }; @@ -86,30 +91,13 @@ void test_T_ctor_sfinae() { operator X(); }; using V = std::variant; - static_assert(std::is_constructible::value, - "regression on user-defined conversions in constructor"); + static_assert(std::is_constructible::value, "regression on user-defined conversions in constructor"); } { using V = std::variant; - static_assert( - !std::is_constructible>::value, - "no matching constructor"); - static_assert(!std::is_constructible>::value, - "no matching constructor"); - } - - - -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - static_assert(!std::is_constructible::value, "ambiguous"); + static_assert(!std::is_constructible>::value, "no matching constructor"); + static_assert(!std::is_constructible>::value, "no matching constructor"); } - { - using V = std::variant; - static_assert(!std::is_constructible::value, "ambiguous"); - } -#endif } void test_T_ctor_basic() { @@ -147,33 +135,17 @@ void test_T_ctor_basic() { std::variant> v1 = 42; assert(v1.index() == 0); - int x = 42; + int x = 42; std::variant, AnyConstructible> v2 = x; assert(v2.index() == 1); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - static_assert(std::is_convertible::value, "must be implicit"); - int x = 42; - V v(x); - assert(v.index() == 0); - assert(&std::get<0>(v) == &x); - } - { - using V = std::variant; - static_assert(std::is_convertible::value, "must be implicit"); - int x = 42; - V v(std::move(x)); - assert(v.index() == 1); - assert(&std::get<1>(v) == &x); - } -#endif } struct BoomOnAnything { template - constexpr BoomOnAnything(T) { static_assert(!std::is_same::value, ""); } + constexpr BoomOnAnything(T) { + static_assert(!std::is_same::value, ""); + } }; void test_no_narrowing_check_for_class_types() { diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/default.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/default.pass.cpp index cc1a3fe8ff78af..40db038a003366 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/default.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/default.pass.cpp @@ -44,12 +44,6 @@ void test_default_ctor_sfinae() { using V = std::variant; static_assert(!std::is_default_constructible::value, ""); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - static_assert(!std::is_default_constructible::value, ""); - } -#endif } void test_default_ctor_noexcept() { diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp index 96fcd7e7bee481..2fe9033dd8166f 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp @@ -55,29 +55,6 @@ void test_emplace_sfinae() { static_assert(emplace_exists(), ""); static_assert(!emplace_exists(), "cannot construct"); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - static_assert(emplace_exists(), ""); - static_assert(emplace_exists(), ""); - static_assert(emplace_exists(), ""); - static_assert(!emplace_exists(), "too many args"); - static_assert(emplace_exists(), ""); - static_assert(!emplace_exists(), "cannot default construct ref"); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(emplace_exists(), ""); - static_assert(emplace_exists(), ""); - static_assert(emplace_exists(), ""); - static_assert(!emplace_exists(), - "not constructible from void*"); - static_assert(emplace_exists(), ""); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(!emplace_exists(), "no ctors"); - } -#endif } void test_basic() { @@ -113,41 +90,6 @@ void test_basic() { assert(std::get<4>(v) == "aaa"); assert(&ref3 == &std::get<4>(v)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - const int x = 100; - int y = 42; - int z = 43; - V v(std::in_place_index<0>, -1); - // default emplace a value - auto& ref1 = v.emplace<1>(); - static_assert(std::is_same_v, ""); - assert(std::get<1>(v) == 0); - assert(&ref1 == &std::get<1>(v)); - // emplace a reference - auto& ref2 = v.emplace<2>(x); - static_assert(std::is_same_v<&, decltype(ref)>, ""); - assert(&std::get<2>(v) == &x); - assert(&ref2 == &std::get<2>(v)); - // emplace an rvalue reference - auto& ref3 = v.emplace<3>(std::move(y)); - static_assert(std::is_same_v<&, decltype(ref)>, ""); - assert(&std::get<3>(v) == &y); - assert(&ref3 == &std::get<3>(v)); - // re-emplace a new reference over the active member - auto& ref4 = v.emplace<3>(std::move(z)); - static_assert(std::is_same_v<&, decltype(ref)>, ""); - assert(&std::get<3>(v) == &z); - assert(&ref4 == &std::get<3>(v)); - // emplace with multiple args - auto& ref5 = v.emplace<5>(3u, 'a'); - static_assert(std::is_same_v, ""); - assert(std::get<5>(v) == "aaa"); - assert(&ref5 == &std::get<5>(v)); - } -#endif } int main(int, char**) { diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp index 24305aa0a35dae..4e9f67775d10c4 100644 --- a/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp @@ -54,30 +54,6 @@ void test_emplace_sfinae() { static_assert(emplace_exists(), ""); static_assert(!emplace_exists(), "cannot construct"); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - using V = std::variant; - static_assert(emplace_exists(), ""); - static_assert(emplace_exists(), ""); - static_assert(emplace_exists(), ""); - static_assert(!emplace_exists(), "too many args"); - static_assert(emplace_exists(), ""); - static_assert(!emplace_exists(), "cannot default construct ref"); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(emplace_exists(), ""); - static_assert(emplace_exists(), ""); - static_assert(emplace_exists(), ""); - static_assert(!emplace_exists(), - "not constructible from void*"); - static_assert(emplace_exists(), ""); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(!emplace_exists(), "cannot bind ref"); - static_assert(!emplace_exists(), "ambiguous"); - static_assert(!emplace_exists(), - "cannot construct void"); -#endif } void test_basic() { @@ -113,41 +89,6 @@ void test_basic() { assert(std::get<4>(v) == "aaa"); assert(&ref3 == &std::get<4>(v)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant; - const int x = 100; - int y = 42; - int z = 43; - V v(std::in_place_index<0>, -1); - // default emplace a value - auto& ref1 = v.emplace(); - static_assert(std::is_same_v, ""); - assert(std::get(v) == 0); - assert(&ref1 == &std::get(v)); - // emplace a reference - auto& ref2 = v.emplace(x); - static_assert(std::is_same_v, ""); - assert(&std::get(v) == &x); - assert(&ref2 == &std::get(v)); - // emplace an rvalue reference - auto& ref3 = v.emplace(std::move(y)); - static_assert(std::is_same_v, ""); - assert(&std::get(v) == &y); - assert(&ref3 == &std::get(v)); - // re-emplace a new reference over the active member - auto& ref4 = v.emplace(std::move(z)); - static_assert(std::is_same_v, ""); - assert(&std::get(v) == &z); - assert(&ref4 == &std::get(v)); - // emplace with multiple args - auto& ref5 = v.emplace(3u, 'a'); - static_assert(std::is_same_v, ""); - assert(std::get(v) == "aaa"); - assert(&ref5 == &std::get(v)); - } -#endif } int main(int, char**) { diff --git a/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp index 50e7fc81387abc..d0c909985bbb37 100644 --- a/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp @@ -82,39 +82,6 @@ void test_argument_forwarding() { std::move(cv).visit(obj); assert(Fn::check_call(val)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { // single argument - lvalue reference - using V = std::variant; - int x = 42; - V v(x); - const V& cv = v; - - v.visit(obj); - assert(Fn::check_call(val)); - cv.visit(obj); - assert(Fn::check_call(val)); - std::move(v).visit(obj); - assert(Fn::check_call(val)); - std::move(cv).visit(obj); - assert(Fn::check_call(val)); - assert(false); - } - { // single argument - rvalue reference - using V = std::variant; - int x = 42; - V v(std::move(x)); - const V& cv = v; - - v.visit(obj); - assert(Fn::check_call(val)); - cvstd::visit(obj); - assert(Fn::check_call(val)); - std::move(v).visit(obj); - assert(Fn::check_call(val)); - std::move(cv).visit(obj); - assert(Fn::check_call(val)); - } -#endif } void test_return_type() { diff --git a/libcxx/test/std/utilities/variant/variant.visit.member/visit_return_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit.member/visit_return_type.pass.cpp index b005f303bc4b6c..3312197d8df9c3 100644 --- a/libcxx/test/std/utilities/variant/variant.visit.member/visit_return_type.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit.member/visit_return_type.pass.cpp @@ -110,38 +110,6 @@ void test_argument_forwarding() { std::move(cv).visit(obj); assert(Fn::check_call(val)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { // single argument - lvalue reference - using V = std::variant; - int x = 42; - V v(x); - const V& cv = v; - - v.visit(obj); - assert(Fn::check_call(val)); - cv.visit(obj); - assert(Fn::check_call(val)); - std::move(v).visit(obj); - assert(Fn::check_call(val)); - std::move(cv).visit(obj); - assert(Fn::check_call(val)); - } - { // single argument - rvalue reference - using V = std::variant; - int x = 42; - V v(std::move(x)); - const V& cv = v; - - v.visit(obj); - assert(Fn::check_call(val)); - cv.visit(obj); - assert(Fn::check_call(val)); - std::move(v).visit(obj); - assert(Fn::check_call(val)); - std::move(cv).visit(obj); - assert(Fn::check_call(val)); - } -#endif } template diff --git a/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp index 798ce7ded72a60..0caecbe875d55e 100644 --- a/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp @@ -118,36 +118,6 @@ void test_argument_forwarding() { std::visit(obj, std::move(cv)); assert(Fn::check_call(Val)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { // single argument - lvalue reference - using V = std::variant; - int x = 42; - V v(x); - const V &cv = v; - std::visit(obj, v); - assert(Fn::check_call(Val)); - std::visit(obj, cv); - assert(Fn::check_call(Val)); - std::visit(obj, std::move(v)); - assert(Fn::check_call(Val)); - std::visit(obj, std::move(cv)); - assert(Fn::check_call(Val)); - } - { // single argument - rvalue reference - using V = std::variant; - int x = 42; - V v(std::move(x)); - const V &cv = v; - std::visit(obj, v); - assert(Fn::check_call(Val)); - std::visit(obj, cv); - assert(Fn::check_call(Val)); - std::visit(obj, std::move(v)); - assert(Fn::check_call(Val)); - std::visit(obj, std::move(cv)); - assert(Fn::check_call(Val)); - } -#endif { // multi argument - multi variant using V = std::variant; V v1(42), v2("hello"), v3(43l); diff --git a/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp index b1189dff656db4..d26c785c037477 100644 --- a/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp @@ -120,36 +120,6 @@ void test_argument_forwarding() { std::visit(obj, std::move(cv)); assert(Fn::check_call(Val)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { // single argument - lvalue reference - using V = std::variant; - int x = 42; - V v(x); - const V &cv = v; - std::visit(obj, v); - assert(Fn::check_call(Val)); - std::visit(obj, cv); - assert(Fn::check_call(Val)); - std::visit(obj, std::move(v)); - assert(Fn::check_call(Val)); - std::visit(obj, std::move(cv)); - assert(Fn::check_call(Val)); - } - { // single argument - rvalue reference - using V = std::variant; - int x = 42; - V v(std::move(x)); - const V &cv = v; - std::visit(obj, v); - assert(Fn::check_call(Val)); - std::visit(obj, cv); - assert(Fn::check_call(Val)); - std::visit(obj, std::move(v)); - assert(Fn::check_call(Val)); - std::visit(obj, std::move(cv)); - assert(Fn::check_call(Val)); - } -#endif { // multi argument - multi variant using V = std::variant; V v1(42), v2("hello"), v3(43l); diff --git a/libcxx/test/support/variant_test_helpers.h b/libcxx/test/support/variant_test_helpers.h index 345e32170e5844..d1bc36dea671ec 100644 --- a/libcxx/test/support/variant_test_helpers.h +++ b/libcxx/test/support/variant_test_helpers.h @@ -21,9 +21,6 @@ #error This file requires C++17 #endif -// FIXME: Currently the variant tests are disabled using this macro. -#define TEST_VARIANT_HAS_NO_REFERENCES - #ifndef TEST_HAS_NO_EXCEPTIONS struct CopyThrows { CopyThrows() = default;