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 // UNSUPPORTED: c++98, c++03, c++11
10 
11 // <map>
12 
13 // class map
14 
15 // template<typename K>
16 //         pair<iterator,iterator>             equal_range(const K& x); // C++14
17 // template<typename K>
18 //         pair<const_iterator,const_iterator> equal_range(const K& x) const;
19 //         // C++14
20 
21 #include <cassert>
22 #include <map>
23 #include <utility>
24 
25 #include "min_allocator.h"
26 #include "private_constructor.hpp"
27 #include "test_macros.h"
28 
29 struct Comp {
30   using is_transparent = void;
31 
32   bool operator()(const std::pair<int, int> &lhs,
33                   const std::pair<int, int> &rhs) const {
34     return lhs < rhs;
35   }
36 
37   bool operator()(const std::pair<int, int> &lhs, int rhs) const {
38     return lhs.first < rhs;
39   }
40 
41   bool operator()(int lhs, const std::pair<int, int> &rhs) const {
42     return lhs < rhs.first;
43   }
44 };
45 
46 int main(int, char**) {
47   std::map<std::pair<int, int>, int, Comp> s{
48       {{2, 1}, 1}, {{1, 2}, 2}, {{1, 3}, 3}, {{1, 4}, 4}, {{2, 2}, 5}};
49 
50   auto er = s.equal_range(1);
51   long nels = 0;
52 
53   for (auto it = er.first; it != er.second; it++) {
54     assert(it->first.first == 1);
55     nels++;
56   }
57 
58   assert(nels == 3);
59 
60   return 0;
61 }
62