1 // { dg-do compile { target c++17 } }
4 #include <testsuite_allocator.h>
5 #include <testsuite_iterators.h>
7 using __gnu_test::SimpleAllocator
;
8 using value_type
= std::set
<int>::value_type
;
10 static_assert(std::is_same_v
<
11 decltype(std::set
{1, 2, 3}),
14 static_assert(std::is_same_v
<
15 decltype(std::set
{1, 2, 3}),
18 static_assert(std::is_same_v
<
19 decltype(std::set
{{1, 2, 3},
20 std::less
<int>{}, {}}),
23 static_assert(std::is_same_v
<
24 decltype(std::set
{{1, 2, 3},
28 static_assert(std::is_same_v
<
29 decltype(std::set
{{1, 2, 3},
30 SimpleAllocator
<int>{}}),
31 std::set
<int, std::less
<int>,
32 SimpleAllocator
<int>>>);
34 static_assert(std::is_same_v
<
35 decltype(std::set
{{1, 2, 3},
36 {}, SimpleAllocator
<int>{}}),
37 std::set
<int, std::less
<int>,
38 SimpleAllocator
<int>>>);
44 static_assert(std::is_same_v
<
45 decltype(std::set(x
.begin(), x
.end())),
48 static_assert(std::is_same_v
<
49 decltype(std::set
{x
.begin(), x
.end(),
51 std::allocator
<int>{}}),
54 static_assert(std::is_same_v
<
55 decltype(std::set
{x
.begin(), x
.end(),
56 std::less
<int>{}, {}}),
59 static_assert(std::is_same_v
<
60 decltype(std::set(x
.begin(), x
.end(),
64 static_assert(std::is_same_v
<
65 decltype(std::set
{x
.begin(), x
.end(),
67 std::allocator
<int>{}}),
70 static_assert(std::is_same_v
<
71 decltype(std::set
{x
.begin(), x
.end(),
72 SimpleAllocator
<int>{}}),
73 std::set
<int, std::less
<int>, SimpleAllocator
<int>>>);
75 static_assert(std::is_same_v
<
76 decltype(std::set
{x
.begin(), x
.end(),
78 SimpleAllocator
<int>{}}),
79 std::set
<int, std::less
<int>, SimpleAllocator
<int>>>);
82 using __gnu_test::test_container
;
83 using __gnu_test::input_iterator_wrapper
;
88 test_container
<value_type
, input_iterator_wrapper
> x(array
);
90 static_assert(std::is_same_v
<
91 decltype(std::set(x
.begin(), x
.end())),
94 static_assert(std::is_same_v
<
95 decltype(std::set
{x
.begin(), x
.end(),
97 std::allocator
<value_type
>{}}),
100 static_assert(std::is_same_v
<
101 decltype(std::set
{x
.begin(), x
.end(),
102 std::less
<int>{}, {}}),
105 static_assert(std::is_same_v
<
106 decltype(std::set(x
.begin(), x
.end(),
110 static_assert(std::is_same_v
<
111 decltype(std::set
{x
.begin(), x
.end(),
112 std::allocator
<value_type
>{}}),
115 static_assert(std::is_same_v
<
116 decltype(std::set
{x
.begin(), x
.end(),
117 SimpleAllocator
<value_type
>{}}),
118 std::set
<int, std::less
<int>,
119 SimpleAllocator
<value_type
>>>);
121 static_assert(std::is_same_v
<
122 decltype(std::set
{x
.begin(), x
.end(),
124 std::allocator
<value_type
>{}}),
127 static_assert(std::is_same_v
<
128 decltype(std::set
{x
.begin(), x
.end(),
130 SimpleAllocator
<value_type
>{}}),
131 std::set
<int, std::less
<int>,
132 SimpleAllocator
<value_type
>>>);
135 template<typename T
, typename U
> struct require_same
;
136 template<typename T
> struct require_same
<T
, T
> { using type
= void; };
138 template<typename T
, typename U
>
139 typename require_same
<T
, U
>::type
145 struct Alloc
: __gnu_test::SimpleAllocator
<T
>
150 Alloc(const Alloc
<U
>&) { }
156 // P1518R2 - Stop overconstraining allocators in container deduction guides.
157 // This is a C++23 feature but we support it for C++17 too.
159 using Set
= std::set
<unsigned, std::greater
<>, Alloc
<unsigned>>;
166 std::set
s2(std::move(s
), p
);