1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <set>
11 
12 // class multiset
13 
14 // multiset(multiset&& s, const allocator_type& a);
15 
16 #include <set>
17 #include <cassert>
18 
19 #include "../../../MoveOnly.h"
20 #include "../../../test_compare.h"
21 #include "../../../test_allocator.h"
22 
23 int main()
24 {
25 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
26     {
27         typedef MoveOnly V;
28         typedef test_compare<std::less<MoveOnly> > C;
29         typedef test_allocator<V> A;
30         typedef std::multiset<MoveOnly, C, A> M;
31         typedef std::move_iterator<V*> I;
32         V a1[] =
33         {
34             V(1),
35             V(1),
36             V(1),
37             V(2),
38             V(2),
39             V(2),
40             V(3),
41             V(3),
42             V(3)
43         };
44         M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
45         V a2[] =
46         {
47             V(1),
48             V(1),
49             V(1),
50             V(2),
51             V(2),
52             V(2),
53             V(3),
54             V(3),
55             V(3)
56         };
57         M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
58         M m3(std::move(m1), A(7));
59         assert(m3 == m2);
60         assert(m3.get_allocator() == A(7));
61         assert(m3.key_comp() == C(5));
62         assert(m1.empty());
63     }
64     {
65         typedef MoveOnly V;
66         typedef test_compare<std::less<MoveOnly> > C;
67         typedef test_allocator<V> A;
68         typedef std::multiset<MoveOnly, C, A> M;
69         typedef std::move_iterator<V*> I;
70         V a1[] =
71         {
72             V(1),
73             V(1),
74             V(1),
75             V(2),
76             V(2),
77             V(2),
78             V(3),
79             V(3),
80             V(3)
81         };
82         M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
83         V a2[] =
84         {
85             V(1),
86             V(1),
87             V(1),
88             V(2),
89             V(2),
90             V(2),
91             V(3),
92             V(3),
93             V(3)
94         };
95         M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
96         M m3(std::move(m1), A(5));
97         assert(m3 == m2);
98         assert(m3.get_allocator() == A(5));
99         assert(m3.key_comp() == C(5));
100         assert(m1.empty());
101     }
102     {
103         typedef MoveOnly V;
104         typedef test_compare<std::less<MoveOnly> > C;
105         typedef other_allocator<V> A;
106         typedef std::multiset<MoveOnly, C, A> M;
107         typedef std::move_iterator<V*> I;
108         V a1[] =
109         {
110             V(1),
111             V(1),
112             V(1),
113             V(2),
114             V(2),
115             V(2),
116             V(3),
117             V(3),
118             V(3)
119         };
120         M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
121         V a2[] =
122         {
123             V(1),
124             V(1),
125             V(1),
126             V(2),
127             V(2),
128             V(2),
129             V(3),
130             V(3),
131             V(3)
132         };
133         M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
134         M m3(std::move(m1), A(5));
135         assert(m3 == m2);
136         assert(m3.get_allocator() == A(5));
137         assert(m3.key_comp() == C(5));
138         assert(m1.empty());
139     }
140 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
141 }
142