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 //===----------------------------------------------------------------------===//
11 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
12 // class Alloc = allocator<pair<const Key, T>>>
13 // class unordered_multimap
15 // pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
17 #include <unordered_map>
23 #include "test_macros.h"
24 #include "min_allocator.h"
29 typedef std::unordered_multimap
<int, std::string
> C
;
30 typedef C::const_iterator I
;
31 typedef std::pair
<int, std::string
> P
;
45 const C
c(std::begin(a
), std::end(a
));
46 std::pair
<I
, I
> r
= c
.equal_range(30);
47 assert(std::distance(r
.first
, r
.second
) == 1);
48 assert(r
.first
->first
== 30);
49 assert(r
.first
->second
== "thirty");
51 assert(std::distance(r
.first
, r
.second
) == 0);
52 r
= c
.equal_range(50);
53 std::set
<std::string
> s
;
57 for ( int i
= 0; i
< 3; ++i
)
59 assert(r
.first
->first
== 50);
60 assert(s
.find(r
.first
->second
) != s
.end());
61 s
.erase(s
.find(r
.first
->second
));
65 #if TEST_STD_VER >= 11
67 typedef std::unordered_multimap
<int, std::string
, std::hash
<int>, std::equal_to
<int>,
68 min_allocator
<std::pair
<const int, std::string
>>> C
;
69 typedef C::const_iterator I
;
70 typedef std::pair
<int, std::string
> P
;
84 const C
c(std::begin(a
), std::end(a
));
85 std::pair
<I
, I
> r
= c
.equal_range(30);
86 assert(std::distance(r
.first
, r
.second
) == 1);
87 assert(r
.first
->first
== 30);
88 assert(r
.first
->second
== "thirty");
90 assert(std::distance(r
.first
, r
.second
) == 0);
91 r
= c
.equal_range(50);
92 std::set
<std::string
> s
;
96 for ( int i
= 0; i
< 3; ++i
)
98 assert(r
.first
->first
== 50);
99 assert(s
.find(r
.first
->second
) != s
.end());
100 s
.erase(s
.find(r
.first
->second
));