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