Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / unord / unord.set / key_eq.pass.cpp
blobc66dc83aedd9a1b4b30bf9393b999f764144bd0f
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 // <unordered_set>
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_set
15 // key_equal key_eq() const;
17 #include <unordered_set>
18 #include <cassert>
20 int main(int, char**) {
21 typedef std::unordered_set<int> set_type;
23 set_type s;
25 std::pair<set_type::iterator, bool> p1 = s.insert(1);
26 std::pair<set_type::iterator, bool> p2 = s.insert(2);
28 const set_type& cs = s;
30 assert(cs.key_eq()(*p1.first, *p1.first));
31 assert(cs.key_eq()(*p2.first, *p2.first));
33 assert(!cs.key_eq()(*p1.first, *p2.first));
34 assert(!cs.key_eq()(*p2.first, *p1.first));
36 return 0;