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// <unordered_set>
10
11// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12// class Alloc = allocator<Value>>
13// class unordered_set
14
15// pair<iterator, iterator> equal_range(const key_type& k);
16
17#include <unordered_set>
18#include <cassert>
19
20#include "test_macros.h"
21#include "min_allocator.h"
22
23int main(int, char**) {
24 {
25 typedef std::unordered_set<int> C;
26 typedef C::iterator I;
27 typedef int P;
28 P a[] = {P(10), P(20), P(30), P(40), P(50), P(50), P(50), P(60), P(70), P(80)};
29 C c(std::begin(arr&: a), std::end(arr&: a));
30 std::pair<I, I> r = c.equal_range(x: 30);
31 assert(std::distance(r.first, r.second) == 1);
32 assert(*r.first == 30);
33 r = c.equal_range(x: 5);
34 assert(std::distance(r.first, r.second) == 0);
35 r = c.equal_range(x: 50);
36 assert(std::distance(r.first, r.second) == 1);
37 assert(*r.first == 50);
38 }
39#if TEST_STD_VER >= 11
40 {
41 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
42 typedef C::iterator I;
43 typedef int P;
44 P a[] = {P(10), P(20), P(30), P(40), P(50), P(50), P(50), P(60), P(70), P(80)};
45 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 == 30);
49 r = c.equal_range(5);
50 assert(std::distance(r.first, r.second) == 0);
51 r = c.equal_range(50);
52 assert(std::distance(r.first, r.second) == 1);
53 assert(*r.first == 50);
54 }
55#endif
56
57 return 0;
58}
59

source code of libcxx/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp