diff options
author | Eric Fiselier <eric@efcs.ca> | 2019-07-14 20:59:51 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2019-07-14 20:59:51 +0000 |
commit | 3c0e2bb0cba205166f85811140da0f6c17ae8280 (patch) | |
tree | 2882b16278e78e04d23bd4b8a72fcab25f66eba5 /libcxx | |
parent | 951bb68ce262545bdb0bff536256e0514daf0046 (diff) | |
download | llvm-3c0e2bb0cba205166f85811140da0f6c17ae8280.zip llvm-3c0e2bb0cba205166f85811140da0f6c17ae8280.tar.gz llvm-3c0e2bb0cba205166f85811140da0f6c17ae8280.tar.bz2 |
Add test for variant construction with duplicate types.
llvm-svn: 366032
Diffstat (limited to 'libcxx')
-rw-r--r-- | libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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 d05e800..42a31f3 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 @@ -189,10 +189,22 @@ void test_no_narrowing_check_for_class_types() { 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; } |