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