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 // <map>
13 
14 // class multimap
15 
16 // template<typename K>
17 //         pair<iterator,iterator>             equal_range(const K& x); // C++14
18 // template<typename K>
19 //         pair<const_iterator,const_iterator> equal_range(const K& x) const;
20 //         // C++14
21 
22 #include <cassert>
23 #include <map>
24 #include <utility>
25 
26 #include "min_allocator.h"
27 #include "private_constructor.hpp"
28 #include "test_macros.h"
29 
30 struct Comp {
31   using is_transparent = void;
32 
operator ()Comp33   bool operator()(const std::pair<int, int> &lhs,
34                   const std::pair<int, int> &rhs) const {
35     return lhs < rhs;
36   }
37 
operator ()Comp38   bool operator()(const std::pair<int, int> &lhs, int rhs) const {
39     return lhs.first < rhs;
40   }
41 
operator ()Comp42   bool operator()(int lhs, const std::pair<int, int> &rhs) const {
43     return lhs < rhs.first;
44   }
45 };
46 
main()47 int main() {
48   std::multimap<std::pair<int, int>, int, Comp> s{
49       {{2, 1}, 1}, {{1, 1}, 2}, {{1, 1}, 3}, {{1, 1}, 4}, {{2, 2}, 5}};
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.first == 1);
56     nels++;
57   }
58 
59   assert(nels == 3);
60 }
61