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 Hash, class Pred, class Alloc>
13 // operator==(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
14 // const unordered_multiset<Key, Hash, Pred, Alloc>& y);
16 // template <class Key, class Hash, class Pred, class Alloc>
18 // operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
19 // const unordered_multiset<Key, Hash, Pred, Alloc>& y);
21 #include <unordered_set>
25 #include "test_macros.h"
26 #include "min_allocator.h"
28 #include "test_comparisons.h"
33 typedef std::unordered_multiset
<int> C
;
49 const C
c1(std::begin(a
), std::end(a
));
55 typedef std::unordered_multiset
<int> C
;
71 const C
c1(std::begin(a
), std::end(a
));
77 typedef std::unordered_multiset
<int> C
;
93 C
c1(std::begin(a
), std::end(a
));
105 #if TEST_STD_VER >= 11
107 typedef std::unordered_multiset
<int, std::hash
<int>,
108 std::equal_to
<int>, min_allocator
<int>> C
;
124 const C
c1(std::begin(a
), std::end(a
));
130 typedef std::unordered_multiset
<int, std::hash
<int>,
131 std::equal_to
<int>, min_allocator
<int>> C
;
147 const C
c1(std::begin(a
), std::end(a
));
153 typedef std::unordered_multiset
<int, std::hash
<int>,
154 std::equal_to
<int>, min_allocator
<int>> C
;
170 C
c1(std::begin(a
), std::end(a
));
184 // Make sure we take into account the number of times that a key repeats into equality.
186 int a
[] = {1, 1, 1, 2};
187 int b
[] = {1, 1, 1, 1, 2};
189 std::unordered_multiset
<int> c1(std::begin(a
), std::end(a
));
190 std::unordered_multiset
<int> c2(std::begin(b
), std::end(b
));
191 assert(testEquality(c1
, c2
, false));
194 // Make sure we behave properly when a custom key predicate is provided.
199 struct HashModuloOddness
{
200 std::size_t operator()(int x
) const { return std::hash
<int>()(x
% 2); }
203 struct CompareModuloOddness
{
204 bool operator()(int x
, int y
) const { return (x
% 2) == (y
% 2); }
207 using Set
= std::unordered_multiset
<int, HashModuloOddness
, CompareModuloOddness
>;
208 Set
c1(std::begin(a
), std::end(a
));
209 Set
c2(std::begin(b
), std::end(b
));
211 assert(testEquality(c1
, c2
, false));