Fix std::variant test for ILP32 targets
* testsuite/20_util/variant/compile.cc: Fix narrowing test for ILP32 targets. Add more cases from P0608R3. * testsuite/20_util/variant/run.cc: Add more cases from P0608R3. From-SVN: r271325
This commit is contained in:
parent
593cda3e61
commit
ac781bc880
|
@ -1,5 +1,9 @@
|
|||
2019-05-17 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* testsuite/20_util/variant/compile.cc: Fix narrowing test for ILP32
|
||||
targets. Add more cases from P0608R3.
|
||||
* testsuite/20_util/variant/run.cc: Add more cases from P0608R3.
|
||||
|
||||
* include/bits/random.h (seed_seq::param): Fix non-reserved name.
|
||||
* include/experimental/type_traits (is_detected_exact)
|
||||
(is_detected_exact_v): Likewise.
|
||||
|
|
|
@ -144,7 +144,15 @@ void arbitrary_ctor()
|
|||
static_assert(noexcept(variant<int, DefaultNoexcept>(DefaultNoexcept{})));
|
||||
|
||||
// P0608R3 disallow narrowing conversions and boolean conversions
|
||||
static_assert(!is_constructible_v<variant<int>, long>);
|
||||
static_assert(!is_constructible_v<variant<float>, int>);
|
||||
static_assert(!is_constructible_v<variant<float, vector<int>>, int>);
|
||||
static_assert(is_constructible_v<variant<float, int>, char>);
|
||||
static_assert(!is_constructible_v<variant<float, char>, int>);
|
||||
static_assert(is_constructible_v<variant<float, long>, int>);
|
||||
struct big_int { big_int(int) { } };
|
||||
static_assert(is_constructible_v<variant<float, big_int>, int>);
|
||||
|
||||
static_assert(!is_constructible_v<variant<int>, unsigned>);
|
||||
static_assert(!is_constructible_v<variant<bool>, int>);
|
||||
static_assert(!is_constructible_v<variant<bool>, void*>);
|
||||
}
|
||||
|
|
|
@ -128,6 +128,17 @@ void arbitrary_ctor()
|
|||
VERIFY(y.index() == 1);
|
||||
VERIFY(std::get<1>(y).d == d);
|
||||
}
|
||||
|
||||
{
|
||||
// P0608R3
|
||||
variant<float, int> v1 = 'a';
|
||||
VERIFY(std::get<1>(v1) == int('a'));
|
||||
variant<float, long> v2 = 0;
|
||||
VERIFY(std::get<1>(v2) == 0L);
|
||||
struct big_int { big_int(int) { } };
|
||||
variant<float, big_int> v3 = 0;
|
||||
VERIFY(v3.index() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
struct ThrowingMoveCtorThrowsCopyCtor
|
||||
|
|
Loading…
Reference in New Issue