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 // multimap(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::multimap
<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() == 9);
47 assert(std::distance(m
.begin(), m
.end()) == 9);
48 assert(*m
.begin() == V(1, 1));
49 assert(*std::next(m
.begin()) == V(1, 1.5));
50 assert(*std::next(m
.begin(), 2) == V(1, 2));
51 assert(*std::next(m
.begin(), 3) == V(2, 1));
52 assert(*std::next(m
.begin(), 4) == V(2, 1.5));
53 assert(*std::next(m
.begin(), 5) == V(2, 2));
54 assert(*std::next(m
.begin(), 6) == V(3, 1));
55 assert(*std::next(m
.begin(), 7) == V(3, 1.5));
56 assert(*std::next(m
.begin(), 8) == V(3, 2));
58 #if TEST_STD_VER >= 11
60 typedef std::pair
<const int, double> V
;
73 typedef test_less
<int> C
;
74 typedef min_allocator
<V
> A
;
75 std::multimap
<int, double, C
, A
> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5), A());
76 assert(m
.get_allocator() == A());
77 assert(m
.key_comp() == C(5));
78 assert(m
.size() == 9);
79 assert(std::distance(m
.begin(), m
.end()) == 9);
80 assert(*m
.begin() == V(1, 1));
81 assert(*std::next(m
.begin()) == V(1, 1.5));
82 assert(*std::next(m
.begin(), 2) == V(1, 2));
83 assert(*std::next(m
.begin(), 3) == V(2, 1));
84 assert(*std::next(m
.begin(), 4) == V(2, 1.5));
85 assert(*std::next(m
.begin(), 5) == V(2, 2));
86 assert(*std::next(m
.begin(), 6) == V(3, 1));
87 assert(*std::next(m
.begin(), 7) == V(3, 1.5));
88 assert(*std::next(m
.begin(), 8) == V(3, 2));
91 typedef std::pair
<const int, double> V
;
104 typedef test_less
<int> C
;
105 typedef explicit_allocator
<V
> A
;
106 std::multimap
<int, double, C
, A
> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5), A
{});
107 assert(m
.get_allocator() == A
{});
108 assert(m
.key_comp() == C(5));
109 assert(m
.size() == 9);
110 assert(std::distance(m
.begin(), m
.end()) == 9);
111 assert(*m
.begin() == V(1, 1));
112 assert(*std::next(m
.begin()) == V(1, 1.5));
113 assert(*std::next(m
.begin(), 2) == V(1, 2));
114 assert(*std::next(m
.begin(), 3) == V(2, 1));
115 assert(*std::next(m
.begin(), 4) == V(2, 1.5));
116 assert(*std::next(m
.begin(), 5) == V(2, 2));
117 assert(*std::next(m
.begin(), 6) == V(3, 1));
118 assert(*std::next(m
.begin(), 7) == V(3, 1.5));
119 assert(*std::next(m
.begin(), 8) == V(3, 2));