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 // UNSUPPORTED: c++98, c++03
11
12 // <set>
13
14 // class multiset
15
16 // multiset(multiset&& s);
17
18 #include <set>
19 #include <cassert>
20
21 #include "../../../test_compare.h"
22 #include "test_allocator.h"
23 #include "min_allocator.h"
24
main()25 int main()
26 {
27 {
28 typedef int V;
29 typedef test_compare<std::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(distance(m.begin(), m.end()) == 0);
37
38 assert(mo.get_allocator() == A(test_alloc_base::moved_value));
39 assert(mo.key_comp() == C(5));
40 assert(mo.size() == 0);
41 assert(distance(mo.begin(), mo.end()) == 0);
42 }
43 {
44 typedef int V;
45 V ar[] =
46 {
47 1,
48 1,
49 1,
50 2,
51 2,
52 2,
53 3,
54 3,
55 3
56 };
57 typedef test_compare<std::less<int> > C;
58 typedef test_allocator<V> A;
59 std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
60 std::multiset<int, C, A> m = std::move(mo);
61 assert(m.get_allocator() == A(7));
62 assert(m.key_comp() == C(5));
63 assert(m.size() == 9);
64 assert(distance(m.begin(), m.end()) == 9);
65 assert(*next(m.begin(), 0) == 1);
66 assert(*next(m.begin(), 1) == 1);
67 assert(*next(m.begin(), 2) == 1);
68 assert(*next(m.begin(), 3) == 2);
69 assert(*next(m.begin(), 4) == 2);
70 assert(*next(m.begin(), 5) == 2);
71 assert(*next(m.begin(), 6) == 3);
72 assert(*next(m.begin(), 7) == 3);
73 assert(*next(m.begin(), 8) == 3);
74
75 assert(mo.get_allocator() == A(test_alloc_base::moved_value));
76 assert(mo.key_comp() == C(5));
77 assert(mo.size() == 0);
78 assert(distance(mo.begin(), mo.end()) == 0);
79 }
80 {
81 typedef int V;
82 V ar[] =
83 {
84 1,
85 1,
86 1,
87 2,
88 2,
89 2,
90 3,
91 3,
92 3
93 };
94 typedef test_compare<std::less<int> > C;
95 typedef min_allocator<V> A;
96 std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
97 std::multiset<int, C, A> m = std::move(mo);
98 assert(m.get_allocator() == A());
99 assert(m.key_comp() == C(5));
100 assert(m.size() == 9);
101 assert(distance(m.begin(), m.end()) == 9);
102 assert(*next(m.begin(), 0) == 1);
103 assert(*next(m.begin(), 1) == 1);
104 assert(*next(m.begin(), 2) == 1);
105 assert(*next(m.begin(), 3) == 2);
106 assert(*next(m.begin(), 4) == 2);
107 assert(*next(m.begin(), 5) == 2);
108 assert(*next(m.begin(), 6) == 3);
109 assert(*next(m.begin(), 7) == 3);
110 assert(*next(m.begin(), 8) == 3);
111
112 assert(mo.get_allocator() == A());
113 assert(mo.key_comp() == C(5));
114 assert(mo.size() == 0);
115 assert(distance(mo.begin(), mo.end()) == 0);
116 }
117 }
118