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);
20 #include "test_macros.h"
21 #include "../../../test_compare.h"
22 #include "test_allocator.h"
23 #include "min_allocator.h"
29 typedef test_less
<int> C
;
30 typedef test_allocator
<V
> A
;
31 std::multiset
<int, C
, A
> mo(C(5), A(7));
32 std::multiset
<int, C
, A
> m
= std::move(mo
);
33 assert(m
.get_allocator() == A(7));
34 assert(m
.key_comp() == C(5));
35 assert(m
.size() == 0);
36 assert(std::distance(m
.begin(), m
.end()) == 0);
38 assert(mo
.get_allocator() == A(7));
39 assert(mo
.get_allocator().get_id() == test_alloc_base::moved_value
);
40 assert(mo
.key_comp() == C(5));
41 assert(mo
.size() == 0);
42 assert(std::distance(mo
.begin(), mo
.end()) == 0);
58 typedef test_less
<int> C
;
59 typedef test_allocator
<V
> A
;
60 std::multiset
<int, C
, A
> mo(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5), A(7));
61 std::multiset
<int, C
, A
> m
= std::move(mo
);
62 assert(m
.get_allocator() == A(7));
63 assert(m
.key_comp() == C(5));
64 assert(m
.size() == 9);
65 assert(std::distance(m
.begin(), m
.end()) == 9);
66 assert(*std::next(m
.begin(), 0) == 1);
67 assert(*std::next(m
.begin(), 1) == 1);
68 assert(*std::next(m
.begin(), 2) == 1);
69 assert(*std::next(m
.begin(), 3) == 2);
70 assert(*std::next(m
.begin(), 4) == 2);
71 assert(*std::next(m
.begin(), 5) == 2);
72 assert(*std::next(m
.begin(), 6) == 3);
73 assert(*std::next(m
.begin(), 7) == 3);
74 assert(*std::next(m
.begin(), 8) == 3);
76 assert(mo
.get_allocator() == A(7));
77 assert(mo
.get_allocator().get_id() == test_alloc_base::moved_value
);
78 assert(mo
.key_comp() == C(5));
79 assert(mo
.size() == 0);
80 assert(std::distance(mo
.begin(), mo
.end()) == 0);
96 typedef test_less
<int> C
;
97 typedef min_allocator
<V
> A
;
98 std::multiset
<int, C
, A
> mo(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5), A());
99 std::multiset
<int, C
, A
> m
= std::move(mo
);
100 assert(m
.get_allocator() == A());
101 assert(m
.key_comp() == C(5));
102 assert(m
.size() == 9);
103 assert(std::distance(m
.begin(), m
.end()) == 9);
104 assert(*std::next(m
.begin(), 0) == 1);
105 assert(*std::next(m
.begin(), 1) == 1);
106 assert(*std::next(m
.begin(), 2) == 1);
107 assert(*std::next(m
.begin(), 3) == 2);
108 assert(*std::next(m
.begin(), 4) == 2);
109 assert(*std::next(m
.begin(), 5) == 2);
110 assert(*std::next(m
.begin(), 6) == 3);
111 assert(*std::next(m
.begin(), 7) == 3);
112 assert(*std::next(m
.begin(), 8) == 3);
114 assert(mo
.get_allocator() == A());
115 assert(mo
.key_comp() == C(5));
116 assert(mo
.size() == 0);
117 assert(std::distance(mo
.begin(), mo
.end()) == 0);