diff options
author | Hui <hui.xie1990@gmail.com> | 2024-03-26 13:39:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-26 09:39:20 -0400 |
commit | dfde6e89ecc10b1f1eebdb0e409ef1a084030a6c (patch) | |
tree | f9a145eebe7af1e1802cfdd413ba28b19036d62d | |
parent | 308ed0233a3da5b3a7d646808c6470ac30870603 (diff) | |
download | llvm-dfde6e89ecc10b1f1eebdb0e409ef1a084030a6c.zip llvm-dfde6e89ecc10b1f1eebdb0e409ef1a084030a6c.tar.gz llvm-dfde6e89ecc10b1f1eebdb0e409ef1a084030a6c.tar.bz2 |
[libc++][test] Remove tests that testing std::variant<T&> (#84222)
Fixes #83600
15 files changed, 21 insertions, 695 deletions
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 3333d2a..09e2e85 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 &>; - 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 &&>; - 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<const int &&>; - 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 &>; - 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<const int &>; - 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 &&>; - 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<const int &&>; - 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 b81e000..c4fefc7 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<const long>(&v) == 42, ""); static_assert(std::get_if<int>(&v) == nullptr, ""); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int &>; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get_if<int &>(&v)), int *); - assert(std::get_if<int &>(&v) == &x); - } - { - using V = std::variant<int &&>; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if<int &&>(&v)), int *); - assert(std::get_if<int &&>(&v) == &x); - } - { - using V = std::variant<const int &&>; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if<const int &&>(&v)), const int *); - assert(std::get_if<const int &&>(&v) == &x); - } -#endif } void test_get_if() { @@ -89,37 +65,6 @@ void test_get_if() { assert(*std::get_if<const long>(&v) == 42); assert(std::get_if<int>(&v) == nullptr); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int &>; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get_if<int &>(&v)), int *); - assert(std::get_if<int &>(&v) == &x); - } - { - using V = std::variant<const int &>; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get_if<const int &>(&v)), const int *); - assert(std::get_if<const int &>(&v) == &x); - } - { - using V = std::variant<int &&>; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if<int &&>(&v)), int *); - assert(std::get_if<int &&>(&v) == &x); - } - { - using V = std::variant<const int &&>; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get_if<const int &&>(&v)), const int *); - assert(std::get_if<const int &&>(&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 97c7ff0..7ec9d88 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 &>; - 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 &&>; - 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<const int &&>; - 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 &>; - 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<const int &>; - 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 &&>; - 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<const int &&>; - 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 &>; - 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<const int &>; - 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 &&>; - 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<const int &&>; - 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 &>; - 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<const int &>; - 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 &&>; - 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<const int &&>; - 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 <std::size_t I> using Idx = std::integral_constant<std::size_t, I>; 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 d5e54d4..3485122 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<const long>(v)), const long &); assert(std::get<const long>(v) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int &>; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get<int &>(v)), int &); - assert(&std::get<int &>(v) == &x); - } - { - using V = std::variant<int &&>; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<int &&>(v)), int &); - assert(&std::get<int &&>(v) == &x); - } - { - using V = std::variant<const int &&>; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<const int &&>(v)), const int &); - assert(&std::get<const int &&>(v) == &x); - } -#endif } void test_lvalue_get() { @@ -94,37 +70,6 @@ void test_lvalue_get() { ASSERT_SAME_TYPE(decltype(std::get<const long>(v)), const long &); assert(std::get<const long>(v) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int &>; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get<int &>(v)), int &); - assert(&std::get<int &>(v) == &x); - } - { - using V = std::variant<const int &>; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get<const int &>(v)), const int &); - assert(&std::get<const int &>(v) == &x); - } - { - using V = std::variant<int &&>; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<int &&>(v)), int &); - assert(&std::get<int &&>(v) == &x); - } - { - using V = std::variant<const int &&>; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<const int &&>(v)), const int &); - assert(&std::get<const int &&>(v) == &x); - } -#endif } void test_rvalue_get() { @@ -142,41 +87,6 @@ void test_rvalue_get() { const long &&); assert(std::get<const long>(std::move(v)) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int &>; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get<int &>(std::move(v))), int &); - assert(&std::get<int &>(std::move(v)) == &x); - } - { - using V = std::variant<const int &>; - int x = 42; - V v(x); - ASSERT_SAME_TYPE(decltype(std::get<const int &>(std::move(v))), - const int &); - assert(&std::get<const int &>(std::move(v)) == &x); - } - { - using V = std::variant<int &&>; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<int &&>(std::move(v))), int &&); - int &&xref = std::get<int &&>(std::move(v)); - assert(&xref == &x); - } - { - using V = std::variant<const int &&>; - int x = 42; - V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<const int &&>(std::move(v))), - const int &&); - const int &&xref = std::get<const int &&>(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<const long>(std::move(v)) == 42); } -// FIXME: Remove these once reference support is reinstated -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int &>; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get<int &>(std::move(v))), int &); - assert(&std::get<int &>(std::move(v)) == &x); - } - { - using V = std::variant<const int &>; - int x = 42; - const V v(x); - ASSERT_SAME_TYPE(decltype(std::get<const int &>(std::move(v))), - const int &); - assert(&std::get<const int &>(std::move(v)) == &x); - } - { - using V = std::variant<int &&>; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<int &&>(std::move(v))), int &&); - int &&xref = std::get<int &&>(std::move(v)); - assert(&xref == &x); - } - { - using V = std::variant<const int &&>; - int x = 42; - const V v(std::move(x)); - ASSERT_SAME_TYPE(decltype(std::get<const int &&>(std::move(v))), - const int &&); - const int &&xref = std::get<const int &&>(std::move(v)); - assert(&xref == &x); - } -#endif } template <class Tp> 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 be1a0c9..31b9b76 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<V, 2, const void *>(); test<V, 3, long double>(); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int, int &, const int &, int &&, long double>; - test<V, 0, int>(); - test<V, 1, int &>(); - test<V, 2, const int &>(); - test<V, 3, int &&>(); - test<V, 4, long double>(); - } -#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 b38b10d..4b9eaba 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<V, Y>::value, "regression on user-defined conversions in operator="); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int, int &&>; - static_assert(!std::is_assignable<V, int>::value, "ambiguous"); - } - { - using V = std::variant<int, const int &>; - static_assert(!std::is_assignable<V, int>::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 &, int &&, long>; - 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 6b7de88..142da1d 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 <typename T> AnyConstructible(T&&) {} }; -struct NoConstructible { NoConstructible() = delete; }; +struct AnyConstructible { + template <typename T> + AnyConstructible(T&&) {} +}; +struct NoConstructible { + NoConstructible() = delete; +}; template <class T> -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<std::string, std::string>; - static_assert(!std::is_constructible<V, const char *>::value, "ambiguous"); + static_assert(!std::is_constructible<V, const char*>::value, "ambiguous"); } { - using V = std::variant<std::string, void *>; - static_assert(!std::is_constructible<V, int>::value, - "no matching constructor"); + using V = std::variant<std::string, void*>; + static_assert(!std::is_constructible<V, int>::value, "no matching constructor"); } { using V = std::variant<std::string, float>; @@ -72,8 +78,7 @@ void test_T_ctor_sfinae() { } { using V = std::variant<std::unique_ptr<int>, bool>; - static_assert(!std::is_constructible<V, std::unique_ptr<char>>::value, - "no explicit bool in constructor"); + static_assert(!std::is_constructible<V, std::unique_ptr<char>>::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<X>; - static_assert(std::is_constructible<V, Y>::value, - "regression on user-defined conversions in constructor"); + static_assert(std::is_constructible<V, Y>::value, "regression on user-defined conversions in constructor"); } { using V = std::variant<AnyConstructible, NoConstructible>; - static_assert( - !std::is_constructible<V, std::in_place_type_t<NoConstructible>>::value, - "no matching constructor"); - static_assert(!std::is_constructible<V, std::in_place_index_t<1>>::value, - "no matching constructor"); - } - - - -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int, int &&>; - static_assert(!std::is_constructible<V, int>::value, "ambiguous"); + static_assert(!std::is_constructible<V, std::in_place_type_t<NoConstructible>>::value, "no matching constructor"); + static_assert(!std::is_constructible<V, std::in_place_index_t<1>>::value, "no matching constructor"); } - { - using V = std::variant<int, const int &>; - static_assert(!std::is_constructible<V, int>::value, "ambiguous"); - } -#endif } void test_T_ctor_basic() { @@ -147,33 +135,17 @@ void test_T_ctor_basic() { std::variant<RValueConvertibleFrom<int>> v1 = 42; assert(v1.index() == 0); - int x = 42; + int x = 42; std::variant<RValueConvertibleFrom<int>, AnyConstructible> v2 = x; assert(v2.index() == 1); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<const int &, int &&, long>; - static_assert(std::is_convertible<int &, V>::value, "must be implicit"); - int x = 42; - V v(x); - assert(v.index() == 0); - assert(&std::get<0>(v) == &x); - } - { - using V = std::variant<const int &, int &&, long>; - static_assert(std::is_convertible<int, V>::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 <class T> - constexpr BoomOnAnything(T) { static_assert(!std::is_same<T, T>::value, ""); } + constexpr BoomOnAnything(T) { + static_assert(!std::is_same<T, T>::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 cc1a3fe..40db038 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<NonDefaultConstructible, int>; static_assert(!std::is_default_constructible<V>::value, ""); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int &, int>; - static_assert(!std::is_default_constructible<V>::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 96fcd7e..2fe9033 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<V, 2, int *>(), ""); static_assert(!emplace_exists<V, 3>(), "cannot construct"); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { - using V = std::variant<int, int &, const int &, int &&, TestTypes::NoCtors>; - static_assert(emplace_exists<V, 0>(), ""); - static_assert(emplace_exists<V, 0, int>(), ""); - static_assert(emplace_exists<V, 0, long long>(), ""); - static_assert(!emplace_exists<V, 0, int, int>(), "too many args"); - static_assert(emplace_exists<V, 1, int &>(), ""); - static_assert(!emplace_exists<V, 1>(), "cannot default construct ref"); - static_assert(!emplace_exists<V, 1, const int &>(), "cannot bind ref"); - static_assert(!emplace_exists<V, 1, int &&>(), "cannot bind ref"); - static_assert(emplace_exists<V, 2, int &>(), ""); - static_assert(emplace_exists<V, 2, const int &>(), ""); - static_assert(emplace_exists<V, 2, int &&>(), ""); - static_assert(!emplace_exists<V, 2, void *>(), - "not constructible from void*"); - static_assert(emplace_exists<V, 3, int>(), ""); - static_assert(!emplace_exists<V, 3, int &>(), "cannot bind ref"); - static_assert(!emplace_exists<V, 3, const int &>(), "cannot bind ref"); - static_assert(!emplace_exists<V, 3, const int &&>(), "cannot bind ref"); - static_assert(!emplace_exists<V, 4>(), "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<int, long, const int &, int &&, TestTypes::NoCtors, - std::string>; - 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<long&, decltype(ref1)>, ""); - 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<std::string&, decltype(ref5)>, ""); - 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 24305aa..4e9f677 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<V, const void *, int *>(), ""); static_assert(!emplace_exists<V, TestTypes::NoCtors>(), "cannot construct"); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - using V = std::variant<int, int &, const int &, int &&, long, long, - TestTypes::NoCtors>; - static_assert(emplace_exists<V, int>(), ""); - static_assert(emplace_exists<V, int, int>(), ""); - static_assert(emplace_exists<V, int, long long>(), ""); - static_assert(!emplace_exists<V, int, int, int>(), "too many args"); - static_assert(emplace_exists<V, int &, int &>(), ""); - static_assert(!emplace_exists<V, int &>(), "cannot default construct ref"); - static_assert(!emplace_exists<V, int &, const int &>(), "cannot bind ref"); - static_assert(!emplace_exists<V, int &, int &&>(), "cannot bind ref"); - static_assert(emplace_exists<V, const int &, int &>(), ""); - static_assert(emplace_exists<V, const int &, const int &>(), ""); - static_assert(emplace_exists<V, const int &, int &&>(), ""); - static_assert(!emplace_exists<V, const int &, void *>(), - "not constructible from void*"); - static_assert(emplace_exists<V, int &&, int>(), ""); - static_assert(!emplace_exists<V, int &&, int &>(), "cannot bind ref"); - static_assert(!emplace_exists<V, int &&, const int &>(), "cannot bind ref"); - static_assert(!emplace_exists<V, int &&, const int &&>(), "cannot bind ref"); - static_assert(!emplace_exists<V, long, long>(), "ambiguous"); - static_assert(!emplace_exists<V, TestTypes::NoCtors>(), - "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<int, long, const int &, int &&, TestTypes::NoCtors, - std::string>; - 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<long>(); - static_assert(std::is_same_v<long&, decltype(ref1)>, ""); - assert(std::get<long>(v) == 0); - assert(&ref1 == &std::get<long>(v)); - // emplace a reference - auto& ref2 = v.emplace<const int &>(x); - static_assert(std::is_same_v<const int&, decltype(ref2)>, ""); - assert(&std::get<const int &>(v) == &x); - assert(&ref2 == &std::get<const int &>(v)); - // emplace an rvalue reference - auto& ref3 = v.emplace<int &&>(std::move(y)); - static_assert(std::is_same_v<int &&, decltype(ref3)>, ""); - assert(&std::get<int &&>(v) == &y); - assert(&ref3 == &std::get<int &&>(v)); - // re-emplace a new reference over the active member - auto& ref4 = v.emplace<int &&>(std::move(z)); - static_assert(std::is_same_v<int &, decltype(ref4)>, ""); - assert(&std::get<int &&>(v) == &z); - assert(&ref4 == &std::get<int &&>(v)); - // emplace with multiple args - auto& ref5 = v.emplace<std::string>(3u, 'a'); - static_assert(std::is_same_v<std::string&, decltype(ref5)>, ""); - assert(std::get<std::string>(v) == "aaa"); - assert(&ref5 == &std::get<std::string>(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 50e7fc8..d0c9099 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<const int&&>(val)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { // single argument - lvalue reference - using V = std::variant<int&>; - int x = 42; - V v(x); - const V& cv = v; - - v.visit(obj); - assert(Fn::check_call<int&>(val)); - cv.visit(obj); - assert(Fn::check_call<int&>(val)); - std::move(v).visit(obj); - assert(Fn::check_call<int&>(val)); - std::move(cv).visit(obj); - assert(Fn::check_call<int&>(val)); - assert(false); - } - { // single argument - rvalue reference - using V = std::variant<int&&>; - int x = 42; - V v(std::move(x)); - const V& cv = v; - - v.visit(obj); - assert(Fn::check_call<int&>(val)); - cvstd::visit(obj); - assert(Fn::check_call<int&>(val)); - std::move(v).visit(obj); - assert(Fn::check_call<int&&>(val)); - std::move(cv).visit(obj); - assert(Fn::check_call<int&&>(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 b005f30..3312197 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<ReturnType>(obj); assert(Fn::check_call<const int&&>(val)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { // single argument - lvalue reference - using V = std::variant<int&>; - int x = 42; - V v(x); - const V& cv = v; - - v.visit<ReturnType>(obj); - assert(Fn::check_call<int&>(val)); - cv.visit<ReturnType>(obj); - assert(Fn::check_call<int&>(val)); - std::move(v).visit<ReturnType>(obj); - assert(Fn::check_call<int&>(val)); - std::move(cv).visit<ReturnType>(obj); - assert(Fn::check_call<int&>(val)); - } - { // single argument - rvalue reference - using V = std::variant<int&&>; - int x = 42; - V v(std::move(x)); - const V& cv = v; - - v.visit<ReturnType>(obj); - assert(Fn::check_call<int&>(val)); - cv.visit<ReturnType>(obj); - assert(Fn::check_call<int&>(val)); - std::move(v).visit<ReturnType>(obj); - assert(Fn::check_call<int&&>(val)); - std::move(cv).visit<ReturnType>(obj); - assert(Fn::check_call<int&&>(val)); - } -#endif } template <typename ReturnType> 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 798ce7d..0caecbe 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<const int &&>(Val)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { // single argument - lvalue reference - using V = std::variant<int &>; - int x = 42; - V v(x); - const V &cv = v; - std::visit(obj, v); - assert(Fn::check_call<int &>(Val)); - std::visit(obj, cv); - assert(Fn::check_call<int &>(Val)); - std::visit(obj, std::move(v)); - assert(Fn::check_call<int &>(Val)); - std::visit(obj, std::move(cv)); - assert(Fn::check_call<int &>(Val)); - } - { // single argument - rvalue reference - using V = std::variant<int &&>; - int x = 42; - V v(std::move(x)); - const V &cv = v; - std::visit(obj, v); - assert(Fn::check_call<int &>(Val)); - std::visit(obj, cv); - assert(Fn::check_call<int &>(Val)); - std::visit(obj, std::move(v)); - assert(Fn::check_call<int &&>(Val)); - std::visit(obj, std::move(cv)); - assert(Fn::check_call<int &&>(Val)); - } -#endif { // multi argument - multi variant using V = std::variant<int, std::string, long>; 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 b1189df..d26c785 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<ReturnType>(obj, std::move(cv)); assert(Fn::check_call<const int &&>(Val)); } -#if !defined(TEST_VARIANT_HAS_NO_REFERENCES) - { // single argument - lvalue reference - using V = std::variant<int &>; - int x = 42; - V v(x); - const V &cv = v; - std::visit<ReturnType>(obj, v); - assert(Fn::check_call<int &>(Val)); - std::visit<ReturnType>(obj, cv); - assert(Fn::check_call<int &>(Val)); - std::visit<ReturnType>(obj, std::move(v)); - assert(Fn::check_call<int &>(Val)); - std::visit<ReturnType>(obj, std::move(cv)); - assert(Fn::check_call<int &>(Val)); - } - { // single argument - rvalue reference - using V = std::variant<int &&>; - int x = 42; - V v(std::move(x)); - const V &cv = v; - std::visit<ReturnType>(obj, v); - assert(Fn::check_call<int &>(Val)); - std::visit<ReturnType>(obj, cv); - assert(Fn::check_call<int &>(Val)); - std::visit<ReturnType>(obj, std::move(v)); - assert(Fn::check_call<int &&>(Val)); - std::visit<ReturnType>(obj, std::move(cv)); - assert(Fn::check_call<int &&>(Val)); - } -#endif { // multi argument - multi variant using V = std::variant<int, std::string, long>; 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 345e321..d1bc36d 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<T&> tests are disabled using this macro. -#define TEST_VARIANT_HAS_NO_REFERENCES - #ifndef TEST_HAS_NO_EXCEPTIONS struct CopyThrows { CopyThrows() = default; |