19bfdb770SEric Fiselier //===----------------------------------------------------------------------===//
29bfdb770SEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
69bfdb770SEric Fiselier //
79bfdb770SEric Fiselier //===----------------------------------------------------------------------===//
89bfdb770SEric Fiselier 
9*31cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11
109bfdb770SEric Fiselier 
119bfdb770SEric Fiselier // <set>
129bfdb770SEric Fiselier 
139bfdb770SEric Fiselier // class set
149bfdb770SEric Fiselier 
159bfdb770SEric Fiselier // template<typename K>
169bfdb770SEric Fiselier //     pair<iterator,iterator>             equal_range(const K& x);        //
179bfdb770SEric Fiselier //     C++14
189bfdb770SEric Fiselier // template<typename K>
199bfdb770SEric Fiselier //     pair<const_iterator,const_iterator> equal_range(const K& x) const;  //
209bfdb770SEric Fiselier //     C++14
219bfdb770SEric Fiselier 
229bfdb770SEric Fiselier #include <cassert>
239bfdb770SEric Fiselier #include <set>
249bfdb770SEric Fiselier #include <utility>
259bfdb770SEric Fiselier 
269bfdb770SEric Fiselier struct Comp {
279bfdb770SEric Fiselier   using is_transparent = void;
289bfdb770SEric Fiselier 
operator ()Comp299bfdb770SEric Fiselier   bool operator()(const std::pair<int, int> &lhs,
309bfdb770SEric Fiselier                   const std::pair<int, int> &rhs) const {
319bfdb770SEric Fiselier     return lhs < rhs;
329bfdb770SEric Fiselier   }
339bfdb770SEric Fiselier 
operator ()Comp349bfdb770SEric Fiselier   bool operator()(const std::pair<int, int> &lhs, int rhs) const {
359bfdb770SEric Fiselier     return lhs.first < rhs;
369bfdb770SEric Fiselier   }
379bfdb770SEric Fiselier 
operator ()Comp389bfdb770SEric Fiselier   bool operator()(int lhs, const std::pair<int, int> &rhs) const {
399bfdb770SEric Fiselier     return lhs < rhs.first;
409bfdb770SEric Fiselier   }
419bfdb770SEric Fiselier };
429bfdb770SEric Fiselier 
main(int,char **)432df59c50SJF Bastien int main(int, char**) {
449bfdb770SEric Fiselier   std::set<std::pair<int, int>, Comp> s{{2, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}};
459bfdb770SEric Fiselier 
469bfdb770SEric Fiselier   auto er = s.equal_range(1);
479bfdb770SEric Fiselier   long nels = 0;
489bfdb770SEric Fiselier 
499bfdb770SEric Fiselier   for (auto it = er.first; it != er.second; it++) {
509bfdb770SEric Fiselier     assert(it->first == 1);
519bfdb770SEric Fiselier     nels++;
529bfdb770SEric Fiselier   }
539bfdb770SEric Fiselier 
549bfdb770SEric Fiselier   assert(nels == 3);
552df59c50SJF Bastien 
562df59c50SJF Bastien   return 0;
579bfdb770SEric Fiselier }
58