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

source code of libcxx/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp