| 1 | // { dg-do compile { target c++20 } } |
| 2 | |
| 3 | #include <tuple> |
| 4 | |
| 5 | // PR libstdc++/102270 - std::tuple<>::swap missing constexpr specifier |
| 6 | |
| 7 | constexpr bool swap_empty_tuple() |
| 8 | { |
| 9 | std::tuple<> t, u; |
| 10 | t.swap(u); |
| 11 | return true; |
| 12 | } |
| 13 | static_assert( swap_empty_tuple() ); |
| 14 | |
| 15 | #include <testsuite_allocator.h> |
| 16 | |
| 17 | constexpr bool construct_using_allocator() |
| 18 | { |
| 19 | using Alloc = __gnu_test::SimpleAllocator<int>; |
| 20 | |
| 21 | Alloc a; |
| 22 | const int i = 0; |
| 23 | |
| 24 | struct X0a { |
| 25 | using allocator_type = Alloc; |
| 26 | /* not constexpr */ X0a() { } |
| 27 | constexpr X0a(allocator_type) { } |
| 28 | }; |
| 29 | std::tuple<X0a> t0a(std::allocator_arg, a); |
| 30 | std::tuple<X0a, X0a> t00a(std::allocator_arg, a); |
| 31 | |
| 32 | struct X0b { |
| 33 | using allocator_type = Alloc; |
| 34 | /* not constexpr */ X0b() { } |
| 35 | constexpr X0b(std::allocator_arg_t, allocator_type) { } |
| 36 | }; |
| 37 | std::tuple<X0b> t0b(std::allocator_arg, a); |
| 38 | std::tuple<X0b, X0b> t00b(std::allocator_arg, a); |
| 39 | |
| 40 | struct X1a { |
| 41 | using allocator_type = Alloc; |
| 42 | /* not constexpr */ X1a(int) { } |
| 43 | constexpr X1a(int, allocator_type) { } |
| 44 | }; |
| 45 | std::tuple<X1a> t1a(std::allocator_arg, a, 1); |
| 46 | std::tuple<X1a, X1a> t11a(std::allocator_arg, a, 1, i); |
| 47 | |
| 48 | struct X1b { |
| 49 | using allocator_type = Alloc; |
| 50 | /* not constexpr */ X1b(int) { } |
| 51 | constexpr X1b(std::allocator_arg_t, allocator_type, int) { } |
| 52 | }; |
| 53 | std::tuple<X1b> t1b(std::allocator_arg, a, 1); |
| 54 | std::tuple<X1b, X1b> t11b(std::allocator_arg, a, 1, i); |
| 55 | |
| 56 | std::tuple<X1a, X1a, X1b, X1b> t1a1b(std::allocator_arg, a, 1, i, 1, i); |
| 57 | |
| 58 | const int c = 0; |
| 59 | std::tuple<int, int> tii(std::allocator_arg, a, c, c); |
| 60 | |
| 61 | return true; |
| 62 | } |
| 63 | static_assert( construct_using_allocator() ); |