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