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::multiset
<int>::value_type
;
10 static_assert(std::is_same_v
<
11 decltype(std::multiset
{1, 2, 3}),
14 static_assert(std::is_same_v
<
15 decltype(std::multiset
{1, 2, 3}),
18 static_assert(std::is_same_v
<
19 decltype(std::multiset
{{1, 2, 3}, std::less
<int>{}, {}}),
22 static_assert(std::is_same_v
<
23 decltype(std::multiset
{{1, 2, 3}, std::less
<int>{}}),
26 static_assert(std::is_same_v
<
27 decltype(std::multiset
{{1, 2, 3}, SimpleAllocator
<int>{}}),
28 std::multiset
<int, std::less
<int>, SimpleAllocator
<int>>>);
30 static_assert(std::is_same_v
<
31 decltype(std::multiset
{{1, 2, 3}, {}, SimpleAllocator
<int>{}}),
32 std::multiset
<int, std::less
<int>, SimpleAllocator
<int>>>);
38 static_assert(std::is_same_v
<
39 decltype(std::multiset(x
.begin(), x
.end())),
42 static_assert(std::is_same_v
<
43 decltype(std::multiset
{x
.begin(), x
.end(),
45 std::allocator
<int>{}}),
48 static_assert(std::is_same_v
<
49 decltype(std::multiset
{x
.begin(), x
.end(),
50 std::less
<int>{}, {}}),
53 static_assert(std::is_same_v
<
54 decltype(std::multiset(x
.begin(), x
.end(),
58 static_assert(std::is_same_v
<
59 decltype(std::multiset
{x
.begin(), x
.end(),
60 std::allocator
<int>{}}),
63 static_assert(std::is_same_v
<
64 decltype(std::multiset
{x
.begin(), x
.end(),
65 SimpleAllocator
<int>{}}),
66 std::multiset
<int, std::less
<int>, SimpleAllocator
<int>>>);
68 static_assert(std::is_same_v
<
69 decltype(std::multiset
{x
.begin(), x
.end(),
71 std::allocator
<int>{}}),
74 static_assert(std::is_same_v
<
75 decltype(std::multiset
{x
.begin(), x
.end(),
77 SimpleAllocator
<int>{}}),
78 std::multiset
<int, std::less
<int>, SimpleAllocator
<int>>>);
81 using __gnu_test::test_container
;
82 using __gnu_test::input_iterator_wrapper
;
87 test_container
<value_type
, input_iterator_wrapper
> x(array
);
89 static_assert(std::is_same_v
<
90 decltype(std::multiset(x
.begin(), x
.end())),
93 static_assert(std::is_same_v
<
94 decltype(std::multiset
{x
.begin(), x
.end(),
96 std::allocator
<value_type
>{}}),
99 static_assert(std::is_same_v
<
100 decltype(std::multiset
{x
.begin(), x
.end(),
101 std::less
<int>{}, {}}),
102 std::multiset
<int>>);
104 static_assert(std::is_same_v
<
105 decltype(std::multiset(x
.begin(), x
.end(),
107 std::multiset
<int>>);
109 static_assert(std::is_same_v
<
110 decltype(std::multiset
{x
.begin(), x
.end(),
111 std::allocator
<value_type
>{}}),
112 std::multiset
<int>>);
114 static_assert(std::is_same_v
<
115 decltype(std::multiset
{x
.begin(), x
.end(),
116 SimpleAllocator
<value_type
>{}}),
117 std::multiset
<int, std::less
<int>,
118 SimpleAllocator
<value_type
>>>);
120 static_assert(std::is_same_v
<
121 decltype(std::multiset
{x
.begin(), x
.end(),
123 std::allocator
<value_type
>{}}),
124 std::multiset
<int>>);
126 static_assert(std::is_same_v
<
127 decltype(std::multiset
{x
.begin(), x
.end(),
129 SimpleAllocator
<value_type
>{}}),
130 std::multiset
<int, std::less
<int>,
131 SimpleAllocator
<value_type
>>>);
134 template<typename T
, typename U
> struct require_same
;
135 template<typename T
> struct require_same
<T
, T
> { using type
= void; };
137 template<typename T
, typename U
>
138 typename require_same
<T
, U
>::type
144 struct Alloc
: __gnu_test::SimpleAllocator
<T
>
149 Alloc(const Alloc
<U
>&) { }
155 // P1518R2 - Stop overconstraining allocators in container deduction guides.
156 // This is a C++23 feature but we support it for C++17 too.
158 using MSet
= std::multiset
<unsigned, std::greater
<>, Alloc
<unsigned>>;
162 std::multiset
s1(s
, p
);
163 check_type
<MSet
>(s1
);
165 std::multiset
s2(std::move(s
), p
);
166 check_type
<MSet
>(s2
);