1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <unordered_set> 11 12 // template <class Key, class Hash, class Pred, class Alloc> 13 // bool 14 // operator==(const unordered_multiset<Key, Hash, Pred, Alloc>& x, 15 // const unordered_multiset<Key, Hash, Pred, Alloc>& y); 16 // 17 // template <class Key, class Hash, class Pred, class Alloc> 18 // bool 19 // operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>& x, 20 // const unordered_multiset<Key, Hash, Pred, Alloc>& y); 21 22 #include <unordered_set> 23 #include <cassert> 24 25 #include "min_allocator.h" 26 27 int main() 28 { 29 { 30 typedef std::unordered_multiset<int> C; 31 typedef int P; 32 P a[] = 33 { 34 P(10), 35 P(20), 36 P(20), 37 P(30), 38 P(40), 39 P(50), 40 P(50), 41 P(50), 42 P(60), 43 P(70), 44 P(80) 45 }; 46 const C c1(std::begin(a), std::end(a)); 47 const C c2; 48 assert(!(c1 == c2)); 49 assert( (c1 != c2)); 50 } 51 { 52 typedef std::unordered_multiset<int> C; 53 typedef int P; 54 P a[] = 55 { 56 P(10), 57 P(20), 58 P(20), 59 P(30), 60 P(40), 61 P(50), 62 P(50), 63 P(50), 64 P(60), 65 P(70), 66 P(80) 67 }; 68 const C c1(std::begin(a), std::end(a)); 69 const C c2 = c1; 70 assert( (c1 == c2)); 71 assert(!(c1 != c2)); 72 } 73 { 74 typedef std::unordered_multiset<int> C; 75 typedef int P; 76 P a[] = 77 { 78 P(10), 79 P(20), 80 P(20), 81 P(30), 82 P(40), 83 P(50), 84 P(50), 85 P(50), 86 P(60), 87 P(70), 88 P(80) 89 }; 90 C c1(std::begin(a), std::end(a)); 91 C c2 = c1; 92 c2.rehash(30); 93 assert( (c1 == c2)); 94 assert(!(c1 != c2)); 95 c2.insert(P(90)); 96 assert(!(c1 == c2)); 97 assert( (c1 != c2)); 98 c1.insert(P(90)); 99 assert( (c1 == c2)); 100 assert(!(c1 != c2)); 101 } 102 #if TEST_STD_VER >= 11 103 { 104 typedef std::unordered_multiset<int, std::hash<int>, 105 std::equal_to<int>, min_allocator<int>> C; 106 typedef int P; 107 P a[] = 108 { 109 P(10), 110 P(20), 111 P(20), 112 P(30), 113 P(40), 114 P(50), 115 P(50), 116 P(50), 117 P(60), 118 P(70), 119 P(80) 120 }; 121 const C c1(std::begin(a), std::end(a)); 122 const C c2; 123 assert(!(c1 == c2)); 124 assert( (c1 != c2)); 125 } 126 { 127 typedef std::unordered_multiset<int, std::hash<int>, 128 std::equal_to<int>, min_allocator<int>> C; 129 typedef int P; 130 P a[] = 131 { 132 P(10), 133 P(20), 134 P(20), 135 P(30), 136 P(40), 137 P(50), 138 P(50), 139 P(50), 140 P(60), 141 P(70), 142 P(80) 143 }; 144 const C c1(std::begin(a), std::end(a)); 145 const C c2 = c1; 146 assert( (c1 == c2)); 147 assert(!(c1 != c2)); 148 } 149 { 150 typedef std::unordered_multiset<int, std::hash<int>, 151 std::equal_to<int>, min_allocator<int>> C; 152 typedef int P; 153 P a[] = 154 { 155 P(10), 156 P(20), 157 P(20), 158 P(30), 159 P(40), 160 P(50), 161 P(50), 162 P(50), 163 P(60), 164 P(70), 165 P(80) 166 }; 167 C c1(std::begin(a), std::end(a)); 168 C c2 = c1; 169 c2.rehash(30); 170 assert( (c1 == c2)); 171 assert(!(c1 != c2)); 172 c2.insert(P(90)); 173 assert(!(c1 == c2)); 174 assert( (c1 != c2)); 175 c1.insert(P(90)); 176 assert( (c1 == c2)); 177 assert(!(c1 != c2)); 178 } 179 #endif 180 } 181