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