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