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

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