llvm-project
57 строк · 1.4 Кб
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++03, c++11
10
11// <set>
12
13// class multiset
14
15// template<typename K>
16// pair<iterator,iterator> equal_range(const K& x); //
17// 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 <set>24#include <utility>25
26struct Comp {27using is_transparent = void;28
29bool operator()(const std::pair<int, int> &lhs,30const std::pair<int, int> &rhs) const {31return lhs < rhs;32}33
34bool operator()(const std::pair<int, int> &lhs, int rhs) const {35return lhs.first < rhs;36}37
38bool operator()(int lhs, const std::pair<int, int> &rhs) const {39return lhs < rhs.first;40}41};42
43int main(int, char**) {44std::multiset<std::pair<int, int>, Comp> s{{2, 1}, {1, 1}, {1, 1}, {1, 1}, {2, 2}};45
46auto er = s.equal_range(1);47long nels = 0;48
49for (auto it = er.first; it != er.second; it++) {50assert(it->first == 1);51nels++;52}53
54assert(nels == 3);55
56return 0;57}
58