Skip to content

Commit

Permalink
Add test for variant construction with duplicate types.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@366032 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
EricWF committed Jul 14, 2019
1 parent 19063b9 commit 3996cfb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 3996cfb

Please sign in to comment.