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 set
14
15 // template<typename K>
16 // iterator lower_bound(const K& x); // C++14
17 // template<typename K>
18 // const_iterator lower_bound(const K& x) const; // C++14
19
20 #include <cassert>
21 #include <set>
22 #include <utility>
23
24 #include "min_allocator.h"
25 #include "private_constructor.h"
26 #include "test_macros.h"
27
28 struct Comp {
29 using is_transparent = void;
30
operator ()Comp31 bool operator()(const std::pair<int, int> &lhs,
32 const std::pair<int, int> &rhs) const {
33 return lhs < rhs;
34 }
35
operator ()Comp36 bool operator()(const std::pair<int, int> &lhs, int rhs) const {
37 return lhs.first < rhs;
38 }
39
operator ()Comp40 bool operator()(int lhs, const std::pair<int, int> &rhs) const {
41 return lhs < rhs.first;
42 }
43 };
44
main(int,char **)45 int main(int, char**) {
46 std::set<std::pair<int, int>, Comp> s{{2, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}};
47
48 auto cnt = s.count(1);
49 assert(cnt == 3);
50
51 return 0;
52 }
53