1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03, c++11
11 
12 // <set>
13 
14 // class set
15 
16 // template<typename K>
17 //     pair<iterator,iterator>             equal_range(const K& x);        //
18 //     C++14
19 // template<typename K>
20 //     pair<const_iterator,const_iterator> equal_range(const K& x) const;  //
21 //     C++14
22 
23 #include <cassert>
24 #include <set>
25 #include <utility>
26 
27 #include "min_allocator.h"
28 #include "private_constructor.hpp"
29 #include "test_macros.h"
30 
31 struct Comp {
32   using is_transparent = void;
33 
operator ()Comp34   bool operator()(const std::pair<int, int> &lhs,
35                   const std::pair<int, int> &rhs) const {
36     return lhs < rhs;
37   }
38 
operator ()Comp39   bool operator()(const std::pair<int, int> &lhs, int rhs) const {
40     return lhs.first < rhs;
41   }
42 
operator ()Comp43   bool operator()(int lhs, const std::pair<int, int> &rhs) const {
44     return lhs < rhs.first;
45   }
46 };
47 
main()48 int main() {
49   std::set<std::pair<int, int>, Comp> s{{2, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}};
50 
51   auto er = s.equal_range(1);
52   long nels = 0;
53 
54   for (auto it = er.first; it != er.second; it++) {
55     assert(it->first == 1);
56     nels++;
57   }
58 
59   assert(nels == 3);
60 }
61