1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
13 // template <class InputIterator>
14 // map(InputIterator first, InputIterator last,
15 // const key_compare& comp, const allocator_type& a);
20 #include "test_macros.h"
21 #include "../../../test_compare.h"
22 #include "test_allocator.h"
23 #include "min_allocator.h"
28 typedef std::pair
<const int, double> V
;
41 typedef test_less
<int> C
;
42 typedef test_allocator
<V
> A
;
43 std::map
<int, double, C
, A
> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5), A(7));
44 assert(m
.get_allocator() == A(7));
45 assert(m
.key_comp() == C(5));
46 assert(m
.size() == 3);
47 assert(std::distance(m
.begin(), m
.end()) == 3);
48 assert(*m
.begin() == V(1, 1));
49 assert(*std::next(m
.begin()) == V(2, 1));
50 assert(*std::next(m
.begin(), 2) == V(3, 1));
52 #if TEST_STD_VER >= 11
54 typedef std::pair
<const int, double> V
;
67 typedef test_less
<int> C
;
68 typedef min_allocator
<V
> A
;
69 std::map
<int, double, C
, A
> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5), A());
70 assert(m
.get_allocator() == A());
71 assert(m
.key_comp() == C(5));
72 assert(m
.size() == 3);
73 assert(std::distance(m
.begin(), m
.end()) == 3);
74 assert(*m
.begin() == V(1, 1));
75 assert(*std::next(m
.begin()) == V(2, 1));
76 assert(*std::next(m
.begin(), 2) == V(3, 1));
80 typedef std::pair
<const int, double> V
;
94 typedef min_allocator
<V
> A
;
95 typedef test_less
<int> C
;
97 std::map
<int, double, C
, A
> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), a
);
99 assert(m
.size() == 3);
100 assert(std::distance(m
.begin(), m
.end()) == 3);
101 assert(*m
.begin() == V(1, 1));
102 assert(*std::next(m
.begin()) == V(2, 1));
103 assert(*std::next(m
.begin(), 2) == V(3, 1));
104 assert(m
.get_allocator() == a
);
107 typedef explicit_allocator
<V
> A
;
108 typedef test_less
<int> C
;
110 std::map
<int, double, C
, A
> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), a
);
112 assert(m
.size() == 3);
113 assert(std::distance(m
.begin(), m
.end()) == 3);
114 assert(*m
.begin() == V(1, 1));
115 assert(*std::next(m
.begin()) == V(2, 1));
116 assert(*std::next(m
.begin(), 2) == V(3, 1));
117 assert(m
.get_allocator() == a
);