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, c++14, c++17
10
11// <set>
12
13// class set
14
15// template<typename K> bool contains(const K& x) const; // C++20
16
17#include <cassert>
18#include <set>
19#include <utility>
20
21struct Comp {
22 using is_transparent = void;
23
24 bool operator()(const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const { return lhs < rhs; }
25
26 bool operator()(const std::pair<int, int>& lhs, int rhs) const { return lhs.first < rhs; }
27
28 bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }
29};
30
31template <typename Container>
32void test() {
33 Container s{{2, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}};
34
35 assert(s.contains(1));
36 assert(!s.contains(-1));
37}
38
39int main(int, char**) {
40 test<std::set<std::pair<int, int>, Comp> >();
41 test<std::multiset<std::pair<int, int>, Comp> >();
42
43 return 0;
44}
45

source code of libcxx/test/std/containers/associative/set/contains_transparent.pass.cpp