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, const allocator_type& a);
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 typedef int V;
25 V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
26 typedef test_less<int> C;
27 typedef test_allocator<V> A;
28 std::multiset<int, C, A> mo(ar, ar + sizeof(ar) / sizeof(ar[0]), C(5), A(7));
29 std::multiset<int, C, A> m(mo, A(3));
30 assert(m.get_allocator() == A(3));
31 assert(m.key_comp() == C(5));
32 assert(m.size() == 9);
33 assert(std::distance(m.begin(), m.end()) == 9);
34 assert(*std::next(m.begin(), 0) == 1);
35 assert(*std::next(m.begin(), 1) == 1);
36 assert(*std::next(m.begin(), 2) == 1);
37 assert(*std::next(m.begin(), 3) == 2);
38 assert(*std::next(m.begin(), 4) == 2);
39 assert(*std::next(m.begin(), 5) == 2);
40 assert(*std::next(m.begin(), 6) == 3);
41 assert(*std::next(m.begin(), 7) == 3);
42 assert(*std::next(m.begin(), 8) == 3);
43
44 assert(mo.get_allocator() == A(7));
45 assert(mo.key_comp() == C(5));
46 assert(mo.size() == 9);
47 assert(std::distance(mo.begin(), mo.end()) == 9);
48 assert(*std::next(mo.begin(), 0) == 1);
49 assert(*std::next(mo.begin(), 1) == 1);
50 assert(*std::next(mo.begin(), 2) == 1);
51 assert(*std::next(mo.begin(), 3) == 2);
52 assert(*std::next(mo.begin(), 4) == 2);
53 assert(*std::next(mo.begin(), 5) == 2);
54 assert(*std::next(mo.begin(), 6) == 3);
55 assert(*std::next(mo.begin(), 7) == 3);
56 assert(*std::next(mo.begin(), 8) == 3);
57
58 return 0;
59}
60

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