Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / associative / set / contains_transparent.pass.cpp
blobe4caa0b7128b467f053262af401180fd0fe7aaca
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // <set>
13 // class set
15 // template<typename K> bool contains(const K& x) const; // C++20
17 #include <cassert>
18 #include <set>
19 #include <utility>
21 struct Comp {
22 using is_transparent = void;
24 bool operator()(const std::pair<int, int>& lhs,
25 const std::pair<int, int>& rhs) const {
26 return lhs < rhs;
29 bool operator()(const std::pair<int, int>& lhs, int rhs) const {
30 return lhs.first < rhs;
33 bool operator()(int lhs, const std::pair<int, int>& rhs) const {
34 return lhs < rhs.first;
38 template <typename Container>
39 void test() {
40 Container s{{2, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}};
42 assert(s.contains(1));
43 assert(!s.contains(-1));
46 int main(int, char**) {
47 test<std::set<std::pair<int, int>, Comp> >();
48 test<std::multiset<std::pair<int, int>, Comp> >();
50 return 0;