1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
15 // multiset(multiset&& s, const allocator_type& a);
21 #include "test_macros.h"
23 #include "../../../test_compare.h"
24 #include "test_allocator.h"
31 typedef test_less
<MoveOnly
> C
;
32 typedef test_allocator
<V
> A
;
33 typedef std::multiset
<MoveOnly
, C
, A
> M
;
34 typedef std::move_iterator
<V
*> I
;
47 M
m1(I(a1
), I(a1
+sizeof(a1
)/sizeof(a1
[0])), C(5), A(7));
60 M
m2(I(a2
), I(a2
+sizeof(a2
)/sizeof(a2
[0])), C(5), A(7));
61 M
m3(std::move(m1
), A(7));
63 assert(m3
.get_allocator() == A(7));
64 assert(m3
.key_comp() == C(5));
65 LIBCPP_ASSERT(m1
.empty());
69 typedef test_less
<MoveOnly
> C
;
70 typedef test_allocator
<V
> A
;
71 typedef std::multiset
<MoveOnly
, C
, A
> M
;
72 typedef std::move_iterator
<V
*> I
;
85 M
m1(I(a1
), I(a1
+sizeof(a1
)/sizeof(a1
[0])), C(5), A(7));
98 M
m2(I(a2
), I(a2
+sizeof(a2
)/sizeof(a2
[0])), C(5), A(7));
99 M
m3(std::move(m1
), A(5));
101 assert(m3
.get_allocator() == A(5));
102 assert(m3
.key_comp() == C(5));
103 LIBCPP_ASSERT(m1
.empty());
107 typedef test_less
<MoveOnly
> C
;
108 typedef other_allocator
<V
> A
;
109 typedef std::multiset
<MoveOnly
, C
, A
> M
;
110 typedef std::move_iterator
<V
*> I
;
123 M
m1(I(a1
), I(a1
+sizeof(a1
)/sizeof(a1
[0])), C(5), A(7));
136 M
m2(I(a2
), I(a2
+sizeof(a2
)/sizeof(a2
[0])), C(5), A(7));
137 M
m3(std::move(m1
), A(5));
139 assert(m3
.get_allocator() == A(5));
140 assert(m3
.key_comp() == C(5));
141 LIBCPP_ASSERT(m1
.empty());
144 typedef Counter
<int> V
;
145 typedef std::less
<V
> C
;
146 typedef test_allocator
<V
> A
;
147 typedef std::multiset
<V
, C
, A
> M
;
149 Counter_base::gConstructed
= 0;
163 const std::size_t num
= sizeof(a1
)/sizeof(a1
[0]);
164 assert(Counter_base::gConstructed
== num
);
166 M
m1(I(a1
), I(a1
+num
), C(), A());
167 assert(Counter_base::gConstructed
== 2*num
);
171 assert(Counter_base::gConstructed
== 3*num
);
173 M
m3(std::move(m1
), A());
175 LIBCPP_ASSERT(m1
.empty());
176 assert(Counter_base::gConstructed
>= (int)(3*num
));
177 assert(Counter_base::gConstructed
<= (int)(4*num
));
180 M
m4(std::move(m2
), A(5));
181 assert(Counter_base::gConstructed
>= (int)(3*num
));
182 assert(Counter_base::gConstructed
<= (int)(5*num
));
184 LIBCPP_ASSERT(m2
.empty());
186 assert(Counter_base::gConstructed
>= (int)(2*num
));
187 assert(Counter_base::gConstructed
<= (int)(4*num
));
189 assert(Counter_base::gConstructed
== 0);