| 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 | // <unordered_set> |
| 10 | |
| 11 | // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, |
| 12 | // class Alloc = allocator<Value>> |
| 13 | // class unordered_multiset |
| 14 | |
| 15 | // key_equal key_eq() const; |
| 16 | |
| 17 | #include <unordered_set> |
| 18 | #include <cassert> |
| 19 | |
| 20 | int main(int, char**) { |
| 21 | typedef std::unordered_multiset<int> set_type; |
| 22 | set_type s; |
| 23 | |
| 24 | set_type::iterator i1 = s.insert(x: 1); |
| 25 | set_type::iterator i2 = s.insert(x: 1); |
| 26 | set_type::iterator i3 = s.insert(x: 2); |
| 27 | |
| 28 | const set_type& cs = s; |
| 29 | |
| 30 | assert(cs.key_eq()(*i1, *i1)); |
| 31 | assert(cs.key_eq()(*i2, *i2)); |
| 32 | assert(cs.key_eq()(*i3, *i3)); |
| 33 | |
| 34 | assert(cs.key_eq()(*i1, *i2)); |
| 35 | assert(cs.key_eq()(*i2, *i1)); |
| 36 | |
| 37 | assert(!cs.key_eq()(*i1, *i3)); |
| 38 | assert(!cs.key_eq()(*i3, *i1)); |
| 39 | |
| 40 | assert(!cs.key_eq()(*i2, *i3)); |
| 41 | assert(!cs.key_eq()(*i3, *i2)); |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |