| 1 |
// PR c++/67348 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
// { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } } |
| 4 |
|
| 5 |
#include <type_traits> |
| 6 |
#include <vector> |
| 7 |
using namespace std; |
| 8 |
|
| 9 |
template <class...Ts> |
| 10 |
requires (is_destructible<Ts>::value && ...) |
| 11 |
struct variant { |
| 12 |
~variant() { /* ... */ } |
| 13 |
~variant() |
| 14 |
requires (is_trivially_destructible<Ts>::value && ...) = default; |
| 15 |
|
| 16 |
variant(variant&&) { /* ... */ } |
| 17 |
variant(variant&&) |
| 18 |
requires (is_trivially_move_constructible<Ts>::value && ...) = default; |
| 19 |
|
| 20 |
variant& operator=(variant&&) { /* ... */ } |
| 21 |
variant& operator=(variant&&) |
| 22 |
requires (is_trivially_move_assignable<Ts>::value && ...) = default; |
| 23 |
|
| 24 |
// ...similar treatment for copy construction / assignment... |
| 25 |
}; |
| 26 |
|
| 27 |
static_assert(is_trivially_destructible<variant<int, float>>()); |
| 28 |
static_assert(!is_trivially_destructible<variant<int, vector<int>>>()); |
| 29 |
|
| 30 |
static_assert(is_trivially_move_constructible<variant<int, float>>()); |
| 31 |
static_assert(!is_trivially_move_constructible<variant<int, vector<int>>>()); |