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);
20 #include "test_macros.h"
21 #include "../../../test_compare.h"
22 #include "min_allocator.h"
27 typedef std::pair
<const int, double> V
;
40 typedef test_less
<int> C
;
41 std::multimap
<int, double, C
> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5));
42 assert(m
.key_comp() == C(5));
43 assert(m
.size() == 9);
44 assert(std::distance(m
.begin(), m
.end()) == 9);
45 assert(*m
.begin() == V(1, 1));
46 assert(*std::next(m
.begin()) == V(1, 1.5));
47 assert(*std::next(m
.begin(), 2) == V(1, 2));
48 assert(*std::next(m
.begin(), 3) == V(2, 1));
49 assert(*std::next(m
.begin(), 4) == V(2, 1.5));
50 assert(*std::next(m
.begin(), 5) == V(2, 2));
51 assert(*std::next(m
.begin(), 6) == V(3, 1));
52 assert(*std::next(m
.begin(), 7) == V(3, 1.5));
53 assert(*std::next(m
.begin(), 8) == V(3, 2));
55 #if TEST_STD_VER >= 11
57 typedef std::pair
<const int, double> V
;
70 typedef test_less
<int> C
;
71 std::multimap
<int, double, C
, min_allocator
<V
>> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5));
72 assert(m
.key_comp() == C(5));
73 assert(m
.size() == 9);
74 assert(std::distance(m
.begin(), m
.end()) == 9);
75 assert(*m
.begin() == V(1, 1));
76 assert(*std::next(m
.begin()) == V(1, 1.5));
77 assert(*std::next(m
.begin(), 2) == V(1, 2));
78 assert(*std::next(m
.begin(), 3) == V(2, 1));
79 assert(*std::next(m
.begin(), 4) == V(2, 1.5));
80 assert(*std::next(m
.begin(), 5) == V(2, 2));
81 assert(*std::next(m
.begin(), 6) == V(3, 1));
82 assert(*std::next(m
.begin(), 7) == V(3, 1.5));
83 assert(*std::next(m
.begin(), 8) == V(3, 2));