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 // <map>
129bfdb770SEric Fiselier
139bfdb770SEric Fiselier // class map
149bfdb770SEric Fiselier
159bfdb770SEric Fiselier // template<typename K>
169bfdb770SEric Fiselier // pair<iterator,iterator> equal_range(const K& x); // C++14
179bfdb770SEric Fiselier // template<typename K>
189bfdb770SEric Fiselier // pair<const_iterator,const_iterator> equal_range(const K& x) const;
199bfdb770SEric Fiselier // // C++14
209bfdb770SEric Fiselier
219bfdb770SEric Fiselier #include <cassert>
229bfdb770SEric Fiselier #include <map>
239bfdb770SEric Fiselier #include <utility>
249bfdb770SEric Fiselier
259bfdb770SEric Fiselier struct Comp {
269bfdb770SEric Fiselier using is_transparent = void;
279bfdb770SEric Fiselier
operator ()Comp289bfdb770SEric Fiselier bool operator()(const std::pair<int, int> &lhs,
299bfdb770SEric Fiselier const std::pair<int, int> &rhs) const {
309bfdb770SEric Fiselier return lhs < rhs;
319bfdb770SEric Fiselier }
329bfdb770SEric Fiselier
operator ()Comp339bfdb770SEric Fiselier bool operator()(const std::pair<int, int> &lhs, int rhs) const {
349bfdb770SEric Fiselier return lhs.first < rhs;
359bfdb770SEric Fiselier }
369bfdb770SEric Fiselier
operator ()Comp379bfdb770SEric Fiselier bool operator()(int lhs, const std::pair<int, int> &rhs) const {
389bfdb770SEric Fiselier return lhs < rhs.first;
399bfdb770SEric Fiselier }
409bfdb770SEric Fiselier };
419bfdb770SEric Fiselier
main(int,char **)422df59c50SJF Bastien int main(int, char**) {
439bfdb770SEric Fiselier std::map<std::pair<int, int>, int, Comp> s{
449bfdb770SEric Fiselier {{2, 1}, 1}, {{1, 2}, 2}, {{1, 3}, 3}, {{1, 4}, 4}, {{2, 2}, 5}};
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.first == 1);
519bfdb770SEric Fiselier nels++;
529bfdb770SEric Fiselier }
539bfdb770SEric Fiselier
549bfdb770SEric Fiselier assert(nels == 3);
552df59c50SJF Bastien
562df59c50SJF Bastien return 0;
579bfdb770SEric Fiselier }
58