[libcxx-commits] [libcxx] r366032 - Add test for variant construction with duplicate types.
Eric Fiselier via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jul 14 13:59:51 PDT 2019
Author: ericwf
Date: Sun Jul 14 13:59:51 2019
New Revision: 366032
URL: http://llvm.org/viewvc/llvm-project?rev=366032&view=rev
Log:
Add test for variant construction with duplicate types.
Modified:
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp?rev=366032&r1=366031&r2=366032&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp Sun Jul 14 13:59:51 2019
@@ -189,10 +189,22 @@ void test_no_narrowing_check_for_class_t
assert(std::get<0>(v) == 42);
}
+struct Bar {};
+struct Baz {};
+void test_construction_with_repeated_types() {
+ using V = std::variant<int, Bar, Baz, int, Baz, int, int>;
+ static_assert(!std::is_constructible<V, int>::value, "");
+ static_assert(!std::is_constructible<V, Baz>::value, "");
+ // OK, the selected type appears only once and so it shouldn't
+ // be affected by the duplicate types.
+ static_assert(std::is_constructible<V, Bar>::value, "");
+}
+
int main(int, char**) {
test_T_ctor_basic();
test_T_ctor_noexcept();
test_T_ctor_sfinae();
test_no_narrowing_check_for_class_types();
+ test_construction_with_repeated_types();
return 0;
}
More information about the libcxx-commits
mailing list