1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class Key, class T, class Hash, class Pred, class Alloc>
13 // operator==(const unordered_multiset<Key, T, Hash, Pred, Alloc>& x,
14 // const unordered_multiset<Key, T, Hash, Pred, Alloc>& y);
16 // template <class Key, class T, class Hash, class Pred, class Alloc>
18 // operator!=(const unordered_multiset<Key, T, Hash, Pred, Alloc>& x,
19 // const unordered_multiset<Key, T, Hash, Pred, Alloc>& y);
21 // Implements paper: http://wg21.link/p0809
27 #include <unordered_set>
30 std::size_t hash_identity(T val
) {
34 std::size_t hash_neg(T val
) {
35 return std::numeric_limits
<T
>::max() - val
;
38 std::size_t hash_scale(T val
) {
42 std::size_t hash_even(T val
) {
43 return val
& 1 ? 1 : 0;
46 std::size_t hash_same(T
/*val*/) {
51 std::size_t hash_identity(T
* val
) {
55 std::size_t hash_neg(T
* val
) {
56 return std::numeric_limits
<T
>::max() - *val
;
59 std::size_t hash_scale(T
* val
) {
63 std::size_t hash_even(T
* val
) {
64 return *val
& 1 ? 1 : 0;
67 template <class T
, std::size_t N
>
68 void test(T (&vals
)[N
]) {
69 using Hash
= std::size_t (*)(T
);
70 using C
= std::unordered_multiset
<T
, Hash
, std::equal_to
<T
> >;
72 C
c1(std::begin(vals
), std::end(vals
), 0, hash_identity
);
73 C
c2(std::begin(vals
), std::end(vals
), 0, hash_neg
);
74 C
c3(std::begin(vals
), std::end(vals
), 0, hash_scale
);
75 C
c4(std::begin(vals
), std::end(vals
), 0, hash_even
);
76 C
c5(std::begin(vals
), std::end(vals
), 0, hash_same
);
109 int main(int, char**) {
111 std::size_t vals
[] = {
120 8, 8, 8, 8, 8, 8, 8, 8,
121 9, 9, 9, 9, 9, 9, 9, 9, 9,
128 bool vals
[] = {true, false};
132 char* vals
[] = {(char*)("a"), (char*)("b"), (char*)("cde")};