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 | 3996cfb482c288efacc2685d1bf958b0883b7b60 (patch) | |
tree | 2c3123f2207877b9c0be40e35260bf40354b50de | |
parent | 19063b99b0d9478685e125ea9a43a6dbd92ccb24 (diff) |
Add test for variant construction with duplicate types.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@366032 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp b/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp index d05e800b3..42a31f334 100644 --- a/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp +++ b/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; } |