1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_UNORDERED_SET
11#define _LIBCPP_UNORDERED_SET
12
13// clang-format off
14
15/*
16
17 unordered_set synopsis
18
19#include <initializer_list>
20
21namespace std
22{
23
24template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
25 class Alloc = allocator<Value>>
26class unordered_set
27{
28public:
29 // types
30 typedef Value key_type;
31 typedef key_type value_type;
32 typedef Hash hasher;
33 typedef Pred key_equal;
34 typedef Alloc allocator_type;
35 typedef value_type& reference;
36 typedef const value_type& const_reference;
37 typedef typename allocator_traits<allocator_type>::pointer pointer;
38 typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
39 typedef typename allocator_traits<allocator_type>::size_type size_type;
40 typedef typename allocator_traits<allocator_type>::difference_type difference_type;
41
42 typedef /unspecified/ iterator;
43 typedef /unspecified/ const_iterator;
44 typedef /unspecified/ local_iterator;
45 typedef /unspecified/ const_local_iterator;
46
47 typedef unspecified node_type unspecified; // C++17
48 typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
49
50 unordered_set()
51 noexcept(
52 is_nothrow_default_constructible<hasher>::value &&
53 is_nothrow_default_constructible<key_equal>::value &&
54 is_nothrow_default_constructible<allocator_type>::value);
55 explicit unordered_set(size_type n, const hasher& hf = hasher(),
56 const key_equal& eql = key_equal(),
57 const allocator_type& a = allocator_type());
58 template <class InputIterator>
59 unordered_set(InputIterator f, InputIterator l,
60 size_type n = 0, const hasher& hf = hasher(),
61 const key_equal& eql = key_equal(),
62 const allocator_type& a = allocator_type());
63 template<container-compatible-range<value_type> R>
64 unordered_set(from_range_t, R&& rg, size_type n = see below,
65 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
66 const allocator_type& a = allocator_type()); // C++23
67 explicit unordered_set(const allocator_type&);
68 unordered_set(const unordered_set&);
69 unordered_set(const unordered_set&, const Allocator&);
70 unordered_set(unordered_set&&)
71 noexcept(
72 is_nothrow_move_constructible<hasher>::value &&
73 is_nothrow_move_constructible<key_equal>::value &&
74 is_nothrow_move_constructible<allocator_type>::value);
75 unordered_set(unordered_set&&, const Allocator&);
76 unordered_set(initializer_list<value_type>, size_type n = 0,
77 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
78 const allocator_type& a = allocator_type());
79 unordered_set(size_type n, const allocator_type& a);
80 unordered_set(size_type n, const hasher& hf, const allocator_type& a);
81 template <class InputIterator>
82 unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a);
83 template <class InputIterator>
84 unordered_set(InputIterator f, InputIterator l, size_type n,
85 const hasher& hf, const allocator_type& a);
86 template<container-compatible-range<value_type> R>
87 unordered_set(from_range_t, R&& rg, size_type n, const allocator_type& a)
88 : unordered_set(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
89 template<container-compatible-range<value_type> R>
90 unordered_set(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
91 : unordered_set(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
92 unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a);
93 unordered_set(initializer_list<value_type> il, size_type n,
94 const hasher& hf, const allocator_type& a);
95 ~unordered_set();
96 unordered_set& operator=(const unordered_set&);
97 unordered_set& operator=(unordered_set&&)
98 noexcept(
99 allocator_type::propagate_on_container_move_assignment::value &&
100 is_nothrow_move_assignable<allocator_type>::value &&
101 is_nothrow_move_assignable<hasher>::value &&
102 is_nothrow_move_assignable<key_equal>::value);
103 unordered_set& operator=(initializer_list<value_type>);
104
105 allocator_type get_allocator() const noexcept;
106
107 bool empty() const noexcept;
108 size_type size() const noexcept;
109 size_type max_size() const noexcept;
110
111 iterator begin() noexcept;
112 iterator end() noexcept;
113 const_iterator begin() const noexcept;
114 const_iterator end() const noexcept;
115 const_iterator cbegin() const noexcept;
116 const_iterator cend() const noexcept;
117
118 template <class... Args>
119 pair<iterator, bool> emplace(Args&&... args);
120 template <class... Args>
121 iterator emplace_hint(const_iterator position, Args&&... args);
122 pair<iterator, bool> insert(const value_type& obj);
123 pair<iterator, bool> insert(value_type&& obj);
124 iterator insert(const_iterator hint, const value_type& obj);
125 iterator insert(const_iterator hint, value_type&& obj);
126 template <class InputIterator>
127 void insert(InputIterator first, InputIterator last);
128 template<container-compatible-range<value_type> R>
129 void insert_range(R&& rg); // C++23
130 void insert(initializer_list<value_type>);
131
132 node_type extract(const_iterator position); // C++17
133 node_type extract(const key_type& x); // C++17
134 insert_return_type insert(node_type&& nh); // C++17
135 iterator insert(const_iterator hint, node_type&& nh); // C++17
136
137 iterator erase(const_iterator position);
138 iterator erase(iterator position); // C++14
139 size_type erase(const key_type& k);
140 iterator erase(const_iterator first, const_iterator last);
141 void clear() noexcept;
142
143 template<class H2, class P2>
144 void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17
145 template<class H2, class P2>
146 void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17
147 template<class H2, class P2>
148 void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17
149 template<class H2, class P2>
150 void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17
151
152 void swap(unordered_set&)
153 noexcept(allocator_traits<Allocator>::is_always_equal::value &&
154 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
155 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
156
157 hasher hash_function() const;
158 key_equal key_eq() const;
159
160 iterator find(const key_type& k);
161 const_iterator find(const key_type& k) const;
162 template<typename K>
163 iterator find(const K& x); // C++20
164 template<typename K>
165 const_iterator find(const K& x) const; // C++20
166 size_type count(const key_type& k) const;
167 template<typename K>
168 size_type count(const K& k) const; // C++20
169 bool contains(const key_type& k) const; // C++20
170 template<typename K>
171 bool contains(const K& k) const; // C++20
172 pair<iterator, iterator> equal_range(const key_type& k);
173 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
174 template<typename K>
175 pair<iterator, iterator> equal_range(const K& k); // C++20
176 template<typename K>
177 pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
178
179 size_type bucket_count() const noexcept;
180 size_type max_bucket_count() const noexcept;
181
182 size_type bucket_size(size_type n) const;
183 size_type bucket(const key_type& k) const;
184
185 local_iterator begin(size_type n);
186 local_iterator end(size_type n);
187 const_local_iterator begin(size_type n) const;
188 const_local_iterator end(size_type n) const;
189 const_local_iterator cbegin(size_type n) const;
190 const_local_iterator cend(size_type n) const;
191
192 float load_factor() const noexcept;
193 float max_load_factor() const noexcept;
194 void max_load_factor(float z);
195 void rehash(size_type n);
196 void reserve(size_type n);
197};
198
199template<class InputIterator,
200 class Hash = hash<typename iterator_traits<InputIterator>::value_type>,
201 class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>,
202 class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
203unordered_set(InputIterator, InputIterator, typename see below::size_type = see below,
204 Hash = Hash(), Pred = Pred(), Allocator = Allocator())
205 -> unordered_set<typename iterator_traits<InputIterator>::value_type,
206 Hash, Pred, Allocator>; // C++17
207
208template<ranges::input_range R,
209 class Hash = hash<ranges::range_value_t<R>>,
210 class Pred = equal_to<ranges::range_value_t<R>>,
211 class Allocator = allocator<ranges::range_value_t<R>>>
212 unordered_set(from_range_t, R&&, typename see below::size_type = see below, Hash = Hash(), Pred = Pred(), Allocator = Allocator())
213 -> unordered_set<ranges::range_value_t<R>, Hash, Pred, Allocator>; // C++23
214
215template<class T, class Hash = hash<T>,
216 class Pred = equal_to<T>, class Allocator = allocator<T>>
217unordered_set(initializer_list<T>, typename see below::size_type = see below,
218 Hash = Hash(), Pred = Pred(), Allocator = Allocator())
219 -> unordered_set<T, Hash, Pred, Allocator>; // C++17
220
221template<class InputIterator, class Allocator>
222unordered_set(InputIterator, InputIterator, typename see below::size_type, Allocator)
223 -> unordered_set<typename iterator_traits<InputIterator>::value_type,
224 hash<typename iterator_traits<InputIterator>::value_type>,
225 equal_to<typename iterator_traits<InputIterator>::value_type>,
226 Allocator>; // C++17
227
228template<class InputIterator, class Hash, class Allocator>
229unordered_set(InputIterator, InputIterator, typename see below::size_type,
230 Hash, Allocator)
231 -> unordered_set<typename iterator_traits<InputIterator>::value_type, Hash,
232 equal_to<typename iterator_traits<InputIterator>::value_type>,
233 Allocator>; // C++17
234
235template<ranges::input_range R, class Allocator>
236 unordered_set(from_range_t, R&&, typename see below::size_type, Allocator)
237 -> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
238 equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
239
240template<ranges::input_range R, class Allocator>
241 unordered_set(from_range_t, R&&, Allocator)
242 -> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
243 equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
244
245template<ranges::input_range R, class Hash, class Allocator>
246 unordered_set(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
247 -> unordered_set<ranges::range_value_t<R>, Hash,
248 equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
249
250template<class T, class Allocator>
251unordered_set(initializer_list<T>, typename see below::size_type, Allocator)
252 -> unordered_set<T, hash<T>, equal_to<T>, Allocator>; // C++17
253
254template<class T, class Hash, class Allocator>
255unordered_set(initializer_list<T>, typename see below::size_type, Hash, Allocator)
256 -> unordered_set<T, Hash, equal_to<T>, Allocator>; // C++17
257
258template <class Value, class Hash, class Pred, class Alloc>
259 void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
260 unordered_set<Value, Hash, Pred, Alloc>& y)
261 noexcept(noexcept(x.swap(y)));
262
263template <class Value, class Hash, class Pred, class Alloc>
264 bool
265 operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
266 const unordered_set<Value, Hash, Pred, Alloc>& y);
267
268template <class Value, class Hash, class Pred, class Alloc>
269 bool
270 operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
271 const unordered_set<Value, Hash, Pred, Alloc>& y); // removed in C++20
272
273template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
274 class Alloc = allocator<Value>>
275class unordered_multiset
276{
277public:
278 // types
279 typedef Value key_type;
280 typedef key_type value_type;
281 typedef Hash hasher;
282 typedef Pred key_equal;
283 typedef Alloc allocator_type;
284 typedef value_type& reference;
285 typedef const value_type& const_reference;
286 typedef typename allocator_traits<allocator_type>::pointer pointer;
287 typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
288 typedef typename allocator_traits<allocator_type>::size_type size_type;
289 typedef typename allocator_traits<allocator_type>::difference_type difference_type;
290
291 typedef /unspecified/ iterator;
292 typedef /unspecified/ const_iterator;
293 typedef /unspecified/ local_iterator;
294 typedef /unspecified/ const_local_iterator;
295
296 typedef unspecified node_type unspecified; // C++17
297
298 unordered_multiset()
299 noexcept(
300 is_nothrow_default_constructible<hasher>::value &&
301 is_nothrow_default_constructible<key_equal>::value &&
302 is_nothrow_default_constructible<allocator_type>::value);
303 explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
304 const key_equal& eql = key_equal(),
305 const allocator_type& a = allocator_type());
306 template <class InputIterator>
307 unordered_multiset(InputIterator f, InputIterator l,
308 size_type n = 0, const hasher& hf = hasher(),
309 const key_equal& eql = key_equal(),
310 const allocator_type& a = allocator_type());
311 template<container-compatible-range<value_type> R>
312 unordered_multiset(from_range_t, R&& rg, size_type n = see below,
313 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
314 const allocator_type& a = allocator_type()); // C++23
315 explicit unordered_multiset(const allocator_type&);
316 unordered_multiset(const unordered_multiset&);
317 unordered_multiset(const unordered_multiset&, const Allocator&);
318 unordered_multiset(unordered_multiset&&)
319 noexcept(
320 is_nothrow_move_constructible<hasher>::value &&
321 is_nothrow_move_constructible<key_equal>::value &&
322 is_nothrow_move_constructible<allocator_type>::value);
323 unordered_multiset(unordered_multiset&&, const Allocator&);
324 unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
325 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
326 const allocator_type& a = allocator_type());
327 unordered_multiset(size_type n, const allocator_type& a);
328 unordered_multiset(size_type n, const hasher& hf, const allocator_type& a);
329 template <class InputIterator>
330 unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a);
331 template <class InputIterator>
332 unordered_multiset(InputIterator f, InputIterator l, size_type n,
333 const hasher& hf, const allocator_type& a);
334 template<container-compatible-range<value_type> R>
335 unordered_multiset(from_range_t, R&& rg, size_type n, const allocator_type& a)
336 : unordered_multiset(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
337 template<container-compatible-range<value_type> R>
338 unordered_multiset(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
339 : unordered_multiset(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
340 unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a);
341 unordered_multiset(initializer_list<value_type> il, size_type n,
342 const hasher& hf, const allocator_type& a);
343 ~unordered_multiset();
344 unordered_multiset& operator=(const unordered_multiset&);
345 unordered_multiset& operator=(unordered_multiset&&)
346 noexcept(
347 allocator_type::propagate_on_container_move_assignment::value &&
348 is_nothrow_move_assignable<allocator_type>::value &&
349 is_nothrow_move_assignable<hasher>::value &&
350 is_nothrow_move_assignable<key_equal>::value);
351 unordered_multiset& operator=(initializer_list<value_type>);
352
353 allocator_type get_allocator() const noexcept;
354
355 bool empty() const noexcept;
356 size_type size() const noexcept;
357 size_type max_size() const noexcept;
358
359 iterator begin() noexcept;
360 iterator end() noexcept;
361 const_iterator begin() const noexcept;
362 const_iterator end() const noexcept;
363 const_iterator cbegin() const noexcept;
364 const_iterator cend() const noexcept;
365
366 template <class... Args>
367 iterator emplace(Args&&... args);
368 template <class... Args>
369 iterator emplace_hint(const_iterator position, Args&&... args);
370 iterator insert(const value_type& obj);
371 iterator insert(value_type&& obj);
372 iterator insert(const_iterator hint, const value_type& obj);
373 iterator insert(const_iterator hint, value_type&& obj);
374 template <class InputIterator>
375 void insert(InputIterator first, InputIterator last);
376 template<container-compatible-range<value_type> R>
377 void insert_range(R&& rg); // C++23
378 void insert(initializer_list<value_type>);
379
380 node_type extract(const_iterator position); // C++17
381 node_type extract(const key_type& x); // C++17
382 iterator insert(node_type&& nh); // C++17
383 iterator insert(const_iterator hint, node_type&& nh); // C++17
384
385 iterator erase(const_iterator position);
386 iterator erase(iterator position); // C++14
387 size_type erase(const key_type& k);
388 iterator erase(const_iterator first, const_iterator last);
389 void clear() noexcept;
390
391 template<class H2, class P2>
392 void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17
393 template<class H2, class P2>
394 void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17
395 template<class H2, class P2>
396 void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17
397 template<class H2, class P2>
398 void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17
399
400 void swap(unordered_multiset&)
401 noexcept(allocator_traits<Allocator>::is_always_equal::value &&
402 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
403 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
404
405 hasher hash_function() const;
406 key_equal key_eq() const;
407
408 iterator find(const key_type& k);
409 const_iterator find(const key_type& k) const;
410 template<typename K>
411 iterator find(const K& x); // C++20
412 template<typename K>
413 const_iterator find(const K& x) const; // C++20
414 size_type count(const key_type& k) const;
415 template<typename K>
416 size_type count(const K& k) const; // C++20
417 bool contains(const key_type& k) const; // C++20
418 template<typename K>
419 bool contains(const K& k) const; // C++20
420 pair<iterator, iterator> equal_range(const key_type& k);
421 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
422 template<typename K>
423 pair<iterator, iterator> equal_range(const K& k); // C++20
424 template<typename K>
425 pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
426
427 size_type bucket_count() const noexcept;
428 size_type max_bucket_count() const noexcept;
429
430 size_type bucket_size(size_type n) const;
431 size_type bucket(const key_type& k) const;
432
433 local_iterator begin(size_type n);
434 local_iterator end(size_type n);
435 const_local_iterator begin(size_type n) const;
436 const_local_iterator end(size_type n) const;
437 const_local_iterator cbegin(size_type n) const;
438 const_local_iterator cend(size_type n) const;
439
440 float load_factor() const noexcept;
441 float max_load_factor() const noexcept;
442 void max_load_factor(float z);
443 void rehash(size_type n);
444 void reserve(size_type n);
445};
446
447template<class InputIterator,
448 class Hash = hash<typename iterator_traits<InputIterator>::value_type>,
449 class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>,
450 class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
451unordered_multiset(InputIterator, InputIterator, see below::size_type = see below,
452 Hash = Hash(), Pred = Pred(), Allocator = Allocator())
453 -> unordered_multiset<typename iterator_traits<InputIterator>::value_type,
454 Hash, Pred, Allocator>; // C++17
455
456template<ranges::input_range R,
457 class Hash = hash<ranges::range_value_t<R>>,
458 class Pred = equal_to<ranges::range_value_t<R>>,
459 class Allocator = allocator<ranges::range_value_t<R>>>
460 unordered_multiset(from_range_t, R&&, typename see below::size_type = see below, Hash = Hash(), Pred = Pred(), Allocator = Allocator())
461 -> unordered_multiset<ranges::range_value_t<R>, Hash, Pred, Allocator>; // C++23
462
463template<class T, class Hash = hash<T>,
464 class Pred = equal_to<T>, class Allocator = allocator<T>>
465unordered_multiset(initializer_list<T>, typename see below::size_type = see below,
466 Hash = Hash(), Pred = Pred(), Allocator = Allocator())
467 -> unordered_multiset<T, Hash, Pred, Allocator>; // C++17
468
469template<class InputIterator, class Allocator>
470unordered_multiset(InputIterator, InputIterator, typename see below::size_type, Allocator)
471 -> unordered_multiset<typename iterator_traits<InputIterator>::value_type,
472 hash<typename iterator_traits<InputIterator>::value_type>,
473 equal_to<typename iterator_traits<InputIterator>::value_type>,
474 Allocator>; // C++17
475
476template<class InputIterator, class Hash, class Allocator>
477unordered_multiset(InputIterator, InputIterator, typename see below::size_type,
478 Hash, Allocator)
479 -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, Hash,
480 equal_to<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
481
482template<ranges::input_range R, class Allocator>
483 unordered_multiset(from_range_t, R&&, typename see below::size_type, Allocator)
484 -> unordered_multiset<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
485 equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
486
487template<ranges::input_range R, class Allocator>
488 unordered_multiset(from_range_t, R&&, Allocator)
489 -> unordered_multiset<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
490 equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
491
492template<ranges::input_range R, class Hash, class Allocator>
493 unordered_multiset(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
494 -> unordered_multiset<ranges::range_value_t<R>, Hash,
495 equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
496
497template<class T, class Allocator>
498unordered_multiset(initializer_list<T>, typename see below::size_type, Allocator)
499 -> unordered_multiset<T, hash<T>, equal_to<T>, Allocator>; // C++17
500
501template<class T, class Hash, class Allocator>
502unordered_multiset(initializer_list<T>, typename see below::size_type, Hash, Allocator)
503 -> unordered_multiset<T, Hash, equal_to<T>, Allocator>; // C++17
504
505template <class Value, class Hash, class Pred, class Alloc>
506 void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
507 unordered_multiset<Value, Hash, Pred, Alloc>& y)
508 noexcept(noexcept(x.swap(y)));
509
510template <class K, class T, class H, class P, class A, class Predicate>
511 typename unordered_set<K, T, H, P, A>::size_type
512 erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20
513
514template <class K, class T, class H, class P, class A, class Predicate>
515 typename unordered_multiset<K, T, H, P, A>::size_type
516 erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20
517
518
519template <class Value, class Hash, class Pred, class Alloc>
520 bool
521 operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
522 const unordered_multiset<Value, Hash, Pred, Alloc>& y);
523
524template <class Value, class Hash, class Pred, class Alloc>
525 bool
526 operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
527 const unordered_multiset<Value, Hash, Pred, Alloc>& y); // removed in C++20
528} // std
529
530*/
531
532// clang-format on
533
534#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
535# include <__cxx03/unordered_set>
536#else
537# include <__algorithm/is_permutation.h>
538# include <__assert>
539# include <__config>
540# include <__functional/hash.h>
541# include <__functional/is_transparent.h>
542# include <__functional/operations.h>
543# include <__hash_table>
544# include <__iterator/distance.h>
545# include <__iterator/erase_if_container.h>
546# include <__iterator/iterator_traits.h>
547# include <__memory/allocator.h>
548# include <__memory/allocator_traits.h>
549# include <__memory_resource/polymorphic_allocator.h>
550# include <__node_handle>
551# include <__ranges/concepts.h>
552# include <__ranges/container_compatible_range.h>
553# include <__ranges/from_range.h>
554# include <__type_traits/container_traits.h>
555# include <__type_traits/enable_if.h>
556# include <__type_traits/invoke.h>
557# include <__type_traits/is_allocator.h>
558# include <__type_traits/is_integral.h>
559# include <__type_traits/is_nothrow_constructible.h>
560# include <__type_traits/is_same.h>
561# include <__type_traits/is_swappable.h>
562# include <__type_traits/type_identity.h>
563# include <__utility/forward.h>
564# include <__utility/move.h>
565# include <__utility/pair.h>
566# include <version>
567
568// standard-mandated includes
569
570// [iterator.range]
571# include <__iterator/access.h>
572# include <__iterator/data.h>
573# include <__iterator/empty.h>
574# include <__iterator/reverse_access.h>
575# include <__iterator/size.h>
576
577// [unord.set.syn]
578# include <compare>
579# include <initializer_list>
580
581# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
582# pragma GCC system_header
583# endif
584
585_LIBCPP_PUSH_MACROS
586# include <__undef_macros>
587
588_LIBCPP_BEGIN_NAMESPACE_STD
589
590template <class _Value, class _Hash, class _Pred, class _Alloc>
591class unordered_multiset;
592
593template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >
594class unordered_set {
595public:
596 // types
597 typedef _Value key_type;
598 typedef key_type value_type;
599 typedef __type_identity_t<_Hash> hasher;
600 typedef __type_identity_t<_Pred> key_equal;
601 typedef __type_identity_t<_Alloc> allocator_type;
602 typedef value_type& reference;
603 typedef const value_type& const_reference;
604 static_assert(__check_valid_allocator<allocator_type>::value, "");
605 static_assert(is_same<value_type, typename allocator_type::value_type>::value,
606 "Allocator::value_type must be same type as value_type");
607
608private:
609 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
610
611 __table __table_;
612
613public:
614 typedef typename __table::pointer pointer;
615 typedef typename __table::const_pointer const_pointer;
616 typedef typename __table::size_type size_type;
617 typedef typename __table::difference_type difference_type;
618
619 typedef typename __table::const_iterator iterator;
620 typedef typename __table::const_iterator const_iterator;
621 typedef typename __table::const_local_iterator local_iterator;
622 typedef typename __table::const_local_iterator const_local_iterator;
623
624# if _LIBCPP_STD_VER >= 17
625 typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
626 typedef __insert_return_type<iterator, node_type> insert_return_type;
627# endif
628
629 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
630 friend class unordered_set;
631 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
632 friend class unordered_multiset;
633
634 _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
635 explicit _LIBCPP_HIDE_FROM_ABI
636 unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
637 inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const allocator_type& __a)
638 : unordered_set(__n, hasher(), key_equal(), __a) {}
639 inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
640 : unordered_set(__n, __hf, key_equal(), __a) {}
641 _LIBCPP_HIDE_FROM_ABI
642 unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
643 template <class _InputIterator>
644 _LIBCPP_HIDE_FROM_ABI unordered_set(_InputIterator __first, _InputIterator __last);
645 template <class _InputIterator>
646 _LIBCPP_HIDE_FROM_ABI
647 unordered_set(_InputIterator __first,
648 _InputIterator __last,
649 size_type __n,
650 const hasher& __hf = hasher(),
651 const key_equal& __eql = key_equal());
652 template <class _InputIterator>
653 _LIBCPP_HIDE_FROM_ABI unordered_set(
654 _InputIterator __first,
655 _InputIterator __last,
656 size_type __n,
657 const hasher& __hf,
658 const key_equal& __eql,
659 const allocator_type& __a);
660
661# if _LIBCPP_STD_VER >= 23
662 template <_ContainerCompatibleRange<value_type> _Range>
663 _LIBCPP_HIDE_FROM_ABI unordered_set(
664 from_range_t,
665 _Range&& __range,
666 size_type __n = /*implementation-defined*/ 0,
667 const hasher& __hf = hasher(),
668 const key_equal& __eql = key_equal(),
669 const allocator_type& __a = allocator_type())
670 : __table_(__hf, __eql, __a) {
671 if (__n > 0) {
672 __table_.__rehash_unique(__n);
673 }
674 insert_range(std::forward<_Range>(__range));
675 }
676# endif
677
678 template <class _InputIterator>
679 inline _LIBCPP_HIDE_FROM_ABI
680 unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
681 : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
682 template <class _InputIterator>
683 _LIBCPP_HIDE_FROM_ABI unordered_set(
684 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
685 : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
686
687# if _LIBCPP_STD_VER >= 23
688 template <_ContainerCompatibleRange<value_type> _Range>
689 _LIBCPP_HIDE_FROM_ABI unordered_set(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
690 : unordered_set(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
691
692 template <_ContainerCompatibleRange<value_type> _Range>
693 _LIBCPP_HIDE_FROM_ABI
694 unordered_set(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
695 : unordered_set(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
696# endif
697
698 _LIBCPP_HIDE_FROM_ABI explicit unordered_set(const allocator_type& __a);
699 _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u) = default;
700 _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u, const allocator_type& __a);
701# ifndef _LIBCPP_CXX03_LANG
702 _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u) = default;
703 _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u, const allocator_type& __a);
704 _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il);
705 _LIBCPP_HIDE_FROM_ABI
706 unordered_set(initializer_list<value_type> __il,
707 size_type __n,
708 const hasher& __hf = hasher(),
709 const key_equal& __eql = key_equal());
710 _LIBCPP_HIDE_FROM_ABI unordered_set(
711 initializer_list<value_type> __il,
712 size_type __n,
713 const hasher& __hf,
714 const key_equal& __eql,
715 const allocator_type& __a);
716 inline _LIBCPP_HIDE_FROM_ABI
717 unordered_set(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
718 : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
719 inline _LIBCPP_HIDE_FROM_ABI
720 unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
721 : unordered_set(__il, __n, __hf, key_equal(), __a) {}
722# endif // _LIBCPP_CXX03_LANG
723 _LIBCPP_HIDE_FROM_ABI ~unordered_set() {
724 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
725 }
726
727 _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(const unordered_set& __u) = default;
728# ifndef _LIBCPP_CXX03_LANG
729 _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(unordered_set&& __u) = default;
730 _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(initializer_list<value_type> __il);
731# endif // _LIBCPP_CXX03_LANG
732
733 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
734 return allocator_type(__table_.__node_alloc());
735 }
736
737 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
738 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
739 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
740
741 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); }
742 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); }
743 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); }
744 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); }
745 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
746 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
747
748# ifndef _LIBCPP_CXX03_LANG
749 template <class... _Args>
750 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
751 return __table_.__emplace_unique(std::forward<_Args>(__args)...);
752 }
753 template <class... _Args>
754 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator, _Args&&... __args) {
755 return __table_.__emplace_unique(std::forward<_Args>(__args)...).first;
756 }
757
758 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) {
759 return __table_.__emplace_unique(std::move(__x));
760 }
761 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { return insert(std::move(__x)).first; }
762
763 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
764# endif // _LIBCPP_CXX03_LANG
765 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__emplace_unique(__x); }
766
767 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }
768 template <class _InputIterator>
769 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
770
771# if _LIBCPP_STD_VER >= 23
772 template <_ContainerCompatibleRange<value_type> _Range>
773 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
774 for (auto&& __element : __range) {
775 __table_.__emplace_unique(std::forward<decltype(__element)>(__element));
776 }
777 }
778# endif
779
780 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); }
781 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_unique(__k); }
782 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
783 return __table_.erase(__first, __last);
784 }
785 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
786
787# if _LIBCPP_STD_VER >= 17
788 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
789 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
790 "node_type with incompatible allocator passed to unordered_set::insert()");
791 return __table_.template __node_handle_insert_unique< node_type, insert_return_type>(std::move(__nh));
792 }
793 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __h, node_type&& __nh) {
794 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
795 "node_type with incompatible allocator passed to unordered_set::insert()");
796 return __table_.template __node_handle_insert_unique<node_type>(__h, std::move(__nh));
797 }
798 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
799 return __table_.template __node_handle_extract<node_type>(__key);
800 }
801 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {
802 return __table_.template __node_handle_extract<node_type>(__it);
803 }
804
805 template <class _H2, class _P2>
806 _LIBCPP_HIDE_FROM_ABI void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source) {
807 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
808 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
809 __table_.__node_handle_merge_unique(__source.__table_);
810 }
811 template <class _H2, class _P2>
812 _LIBCPP_HIDE_FROM_ABI void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source) {
813 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
814 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
815 __table_.__node_handle_merge_unique(__source.__table_);
816 }
817 template <class _H2, class _P2>
818 _LIBCPP_HIDE_FROM_ABI void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source) {
819 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
820 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
821 __table_.__node_handle_merge_unique(__source.__table_);
822 }
823 template <class _H2, class _P2>
824 _LIBCPP_HIDE_FROM_ABI void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source) {
825 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
826 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
827 __table_.__node_handle_merge_unique(__source.__table_);
828 }
829# endif
830
831 _LIBCPP_HIDE_FROM_ABI void swap(unordered_set& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
832 __table_.swap(__u.__table_);
833 }
834
835 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function(); }
836 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq(); }
837
838 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
839 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
840# if _LIBCPP_STD_VER >= 20
841 template <class _K2,
842 class _Hasher = hasher,
843 class _Comp = key_equal,
844 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
845 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
846 return __table_.find(__k);
847 }
848 template <class _K2,
849 class _Hasher = hasher,
850 class _Comp = key_equal,
851 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
852 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
853 return __table_.find(__k);
854 }
855# endif // _LIBCPP_STD_VER >= 20
856
857 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const {
858 return __table_.__count_unique(__k);
859 }
860# if _LIBCPP_STD_VER >= 20
861 template <class _K2,
862 class _Hasher = hasher,
863 class _Comp = key_equal,
864 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
865 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
866 return __table_.__count_unique(__k);
867 }
868# endif // _LIBCPP_STD_VER >= 20
869
870# if _LIBCPP_STD_VER >= 20
871 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
872
873 template <class _K2,
874 class _Hasher = hasher,
875 class _Comp = key_equal,
876 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
877 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
878 return find(__k) != end();
879 }
880# endif // _LIBCPP_STD_VER >= 20
881
882 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
883 return __table_.__equal_range_unique(__k);
884 }
885 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
886 return __table_.__equal_range_unique(__k);
887 }
888# if _LIBCPP_STD_VER >= 20
889 template <class _K2,
890 class _Hasher = hasher,
891 class _Comp = key_equal,
892 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
893 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
894 return __table_.__equal_range_unique(__k);
895 }
896 template <class _K2,
897 class _Hasher = hasher,
898 class _Comp = key_equal,
899 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
900 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
901 return __table_.__equal_range_unique(__k);
902 }
903# endif // _LIBCPP_STD_VER >= 20
904
905 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }
906 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT {
907 return __table_.max_bucket_count();
908 }
909
910 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const {
911 return __table_.bucket_size(__n);
912 }
913 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); }
914
915 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); }
916 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); }
917 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const {
918 return __table_.cbegin(__n);
919 }
920 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); }
921 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const {
922 return __table_.cbegin(__n);
923 }
924 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); }
925
926 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); }
927 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); }
928 _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); }
929 _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_unique(__n); }
930 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); }
931};
932
933# if _LIBCPP_STD_VER >= 17
934template <class _InputIterator,
935 class _Hash = hash<__iterator_value_type<_InputIterator>>,
936 class _Pred = equal_to<__iterator_value_type<_InputIterator>>,
937 class _Allocator = allocator<__iterator_value_type<_InputIterator>>,
938 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
939 class = enable_if_t<!__is_allocator_v<_Hash>>,
940 class = enable_if_t<!is_integral<_Hash>::value>,
941 class = enable_if_t<!__is_allocator_v<_Pred>>,
942 class = enable_if_t<__is_allocator_v<_Allocator>>>
943unordered_set(_InputIterator,
944 _InputIterator,
945 typename allocator_traits<_Allocator>::size_type = 0,
946 _Hash = _Hash(),
947 _Pred = _Pred(),
948 _Allocator = _Allocator())
949 -> unordered_set<__iterator_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
950
951# if _LIBCPP_STD_VER >= 23
952template <ranges::input_range _Range,
953 class _Hash = hash<ranges::range_value_t<_Range>>,
954 class _Pred = equal_to<ranges::range_value_t<_Range>>,
955 class _Allocator = allocator<ranges::range_value_t<_Range>>,
956 class = enable_if_t<!__is_allocator_v<_Hash>>,
957 class = enable_if_t<!is_integral<_Hash>::value>,
958 class = enable_if_t<!__is_allocator_v<_Pred>>,
959 class = enable_if_t<__is_allocator_v<_Allocator>>>
960unordered_set(from_range_t,
961 _Range&&,
962 typename allocator_traits<_Allocator>::size_type = 0,
963 _Hash = _Hash(),
964 _Pred = _Pred(),
965 _Allocator = _Allocator())
966 -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
967# endif
968
969template <class _Tp,
970 class _Hash = hash<_Tp>,
971 class _Pred = equal_to<_Tp>,
972 class _Allocator = allocator<_Tp>,
973 class = enable_if_t<!__is_allocator_v<_Hash>>,
974 class = enable_if_t<!is_integral<_Hash>::value>,
975 class = enable_if_t<!__is_allocator_v<_Pred>>,
976 class = enable_if_t<__is_allocator_v<_Allocator>>>
977unordered_set(initializer_list<_Tp>,
978 typename allocator_traits<_Allocator>::size_type = 0,
979 _Hash = _Hash(),
980 _Pred = _Pred(),
981 _Allocator = _Allocator()) -> unordered_set<_Tp, _Hash, _Pred, _Allocator>;
982
983template <class _InputIterator,
984 class _Allocator,
985 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
986 class = enable_if_t<__is_allocator_v<_Allocator>>>
987unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
988 -> unordered_set<__iterator_value_type<_InputIterator>,
989 hash<__iterator_value_type<_InputIterator>>,
990 equal_to<__iterator_value_type<_InputIterator>>,
991 _Allocator>;
992
993template <class _InputIterator,
994 class _Hash,
995 class _Allocator,
996 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
997 class = enable_if_t<!__is_allocator_v<_Hash>>,
998 class = enable_if_t<!is_integral<_Hash>::value>,
999 class = enable_if_t<__is_allocator_v<_Allocator>>>
1000unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1001 -> unordered_set<__iterator_value_type<_InputIterator>,
1002 _Hash,
1003 equal_to<__iterator_value_type<_InputIterator>>,
1004 _Allocator>;
1005
1006# if _LIBCPP_STD_VER >= 23
1007
1008template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>>
1009unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
1010 -> unordered_set<ranges::range_value_t<_Range>,
1011 hash<ranges::range_value_t<_Range>>,
1012 equal_to<ranges::range_value_t<_Range>>,
1013 _Allocator>;
1014
1015template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>>
1016unordered_set(from_range_t, _Range&&, _Allocator)
1017 -> unordered_set<ranges::range_value_t<_Range>,
1018 hash<ranges::range_value_t<_Range>>,
1019 equal_to<ranges::range_value_t<_Range>>,
1020 _Allocator>;
1021
1022template <ranges::input_range _Range,
1023 class _Hash,
1024 class _Allocator,
1025 class = enable_if_t<!__is_allocator_v<_Hash>>,
1026 class = enable_if_t<!is_integral<_Hash>::value>,
1027 class = enable_if_t<__is_allocator_v<_Allocator>>>
1028unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1029 -> unordered_set<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>;
1030
1031# endif
1032
1033template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>>
1034unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
1035 -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
1036
1037template <class _Tp,
1038 class _Hash,
1039 class _Allocator,
1040 class = enable_if_t<!__is_allocator_v<_Hash>>,
1041 class = enable_if_t<!is_integral<_Hash>::value>,
1042 class = enable_if_t<__is_allocator_v<_Allocator>>>
1043unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1044 -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
1045# endif
1046
1047template <class _Value, class _Hash, class _Pred, class _Alloc>
1048unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql)
1049 : __table_(__hf, __eql) {
1050 __table_.__rehash_unique(__n);
1051}
1052
1053template <class _Value, class _Hash, class _Pred, class _Alloc>
1054unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1055 size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1056 : __table_(__hf, __eql, __a) {
1057 __table_.__rehash_unique(__n);
1058}
1059
1060template <class _Value, class _Hash, class _Pred, class _Alloc>
1061template <class _InputIterator>
1062unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(_InputIterator __first, _InputIterator __last) {
1063 insert(__first, __last);
1064}
1065
1066template <class _Value, class _Hash, class _Pred, class _Alloc>
1067template <class _InputIterator>
1068unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1069 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql)
1070 : __table_(__hf, __eql) {
1071 __table_.__rehash_unique(__n);
1072 insert(__first, __last);
1073}
1074
1075template <class _Value, class _Hash, class _Pred, class _Alloc>
1076template <class _InputIterator>
1077unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1078 _InputIterator __first,
1079 _InputIterator __last,
1080 size_type __n,
1081 const hasher& __hf,
1082 const key_equal& __eql,
1083 const allocator_type& __a)
1084 : __table_(__hf, __eql, __a) {
1085 __table_.__rehash_unique(__n);
1086 insert(__first, __last);
1087}
1088
1089template <class _Value, class _Hash, class _Pred, class _Alloc>
1090inline unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const allocator_type& __a) : __table_(__a) {}
1091
1092template <class _Value, class _Hash, class _Pred, class _Alloc>
1093unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set& __u, const allocator_type& __a)
1094 : __table_(__u.__table_, __a) {
1095 __table_.__rehash_unique(__u.bucket_count());
1096 insert(__u.begin(), __u.end());
1097}
1098
1099# ifndef _LIBCPP_CXX03_LANG
1100
1101template <class _Value, class _Hash, class _Pred, class _Alloc>
1102unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u, const allocator_type& __a)
1103 : __table_(std::move(__u.__table_), __a) {
1104 if (__a != __u.get_allocator()) {
1105 iterator __i = __u.begin();
1106 while (__u.size() != 0)
1107 __table_.__emplace_unique(std::move(__u.__table_.remove(__i++)->__get_value()));
1108 }
1109}
1110
1111template <class _Value, class _Hash, class _Pred, class _Alloc>
1112unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(initializer_list<value_type> __il) {
1113 insert(__il.begin(), __il.end());
1114}
1115
1116template <class _Value, class _Hash, class _Pred, class _Alloc>
1117unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1118 initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql)
1119 : __table_(__hf, __eql) {
1120 __table_.__rehash_unique(__n);
1121 insert(__il.begin(), __il.end());
1122}
1123
1124template <class _Value, class _Hash, class _Pred, class _Alloc>
1125unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1126 initializer_list<value_type> __il,
1127 size_type __n,
1128 const hasher& __hf,
1129 const key_equal& __eql,
1130 const allocator_type& __a)
1131 : __table_(__hf, __eql, __a) {
1132 __table_.__rehash_unique(__n);
1133 insert(__il.begin(), __il.end());
1134}
1135
1136template <class _Value, class _Hash, class _Pred, class _Alloc>
1137inline unordered_set<_Value, _Hash, _Pred, _Alloc>&
1138unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) {
1139 __table_.__assign_unique(__il.begin(), __il.end());
1140 return *this;
1141}
1142
1143# endif // _LIBCPP_CXX03_LANG
1144
1145template <class _Value, class _Hash, class _Pred, class _Alloc>
1146template <class _InputIterator>
1147inline void unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
1148 for (; __first != __last; ++__first)
1149 __table_.__emplace_unique(*__first);
1150}
1151
1152template <class _Value, class _Hash, class _Pred, class _Alloc>
1153inline _LIBCPP_HIDE_FROM_ABI void
1154swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1155 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
1156 __x.swap(__y);
1157}
1158
1159# if _LIBCPP_STD_VER >= 20
1160template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
1161inline _LIBCPP_HIDE_FROM_ABI typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type
1162erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
1163 return std::__libcpp_erase_if_container(__c, __pred);
1164}
1165# endif
1166
1167template <class _Value, class _Hash, class _Pred, class _Alloc>
1168_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1169 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) {
1170 if (__x.size() != __y.size())
1171 return false;
1172 typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator const_iterator;
1173 for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); __i != __ex; ++__i) {
1174 const_iterator __j = __y.find(*__i);
1175 if (__j == __ey || !(*__i == *__j))
1176 return false;
1177 }
1178 return true;
1179}
1180
1181# if _LIBCPP_STD_VER <= 17
1182
1183template <class _Value, class _Hash, class _Pred, class _Alloc>
1184inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1185 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) {
1186 return !(__x == __y);
1187}
1188
1189# endif
1190
1191template <class _Value, class _Hash, class _Pred, class _Alloc>
1192struct __container_traits<unordered_set<_Value, _Hash, _Pred, _Alloc> > {
1193 // http://eel.is/c++draft/unord.req.except#2
1194 // For unordered associative containers, if an exception is thrown by any operation
1195 // other than the container's hash function from within an insert or emplace function
1196 // inserting a single element, the insertion has no effect.
1197 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
1198 __is_nothrow_invocable_v<_Hash, const _Value&>;
1199
1200 static _LIBCPP_CONSTEXPR const bool __reservable = true;
1201};
1202
1203template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >
1204class unordered_multiset {
1205public:
1206 // types
1207 typedef _Value key_type;
1208 typedef key_type value_type;
1209 typedef __type_identity_t<_Hash> hasher;
1210 typedef __type_identity_t<_Pred> key_equal;
1211 typedef __type_identity_t<_Alloc> allocator_type;
1212 typedef value_type& reference;
1213 typedef const value_type& const_reference;
1214 static_assert(is_same<value_type, typename allocator_type::value_type>::value,
1215 "Allocator::value_type must be same type as value_type");
1216
1217private:
1218 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
1219
1220 __table __table_;
1221
1222public:
1223 typedef typename __table::pointer pointer;
1224 typedef typename __table::const_pointer const_pointer;
1225 typedef typename __table::size_type size_type;
1226 typedef typename __table::difference_type difference_type;
1227
1228 typedef typename __table::const_iterator iterator;
1229 typedef typename __table::const_iterator const_iterator;
1230 typedef typename __table::const_local_iterator local_iterator;
1231 typedef typename __table::const_local_iterator const_local_iterator;
1232
1233# if _LIBCPP_STD_VER >= 17
1234 typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
1235# endif
1236
1237 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1238 friend class unordered_set;
1239 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1240 friend class unordered_multiset;
1241
1242 _LIBCPP_HIDE_FROM_ABI unordered_multiset() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
1243 explicit _LIBCPP_HIDE_FROM_ABI
1244 unordered_multiset(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
1245 _LIBCPP_HIDE_FROM_ABI
1246 unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
1247 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const allocator_type& __a)
1248 : unordered_multiset(__n, hasher(), key_equal(), __a) {}
1249 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
1250 : unordered_multiset(__n, __hf, key_equal(), __a) {}
1251 template <class _InputIterator>
1252 _LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last);
1253 template <class _InputIterator>
1254 _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1255 _InputIterator __first,
1256 _InputIterator __last,
1257 size_type __n,
1258 const hasher& __hf = hasher(),
1259 const key_equal& __eql = key_equal());
1260 template <class _InputIterator>
1261 _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1262 _InputIterator __first,
1263 _InputIterator __last,
1264 size_type __n,
1265 const hasher& __hf,
1266 const key_equal& __eql,
1267 const allocator_type& __a);
1268
1269# if _LIBCPP_STD_VER >= 23
1270 template <_ContainerCompatibleRange<value_type> _Range>
1271 _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1272 from_range_t,
1273 _Range&& __range,
1274 size_type __n = /*implementation-defined*/ 0,
1275 const hasher& __hf = hasher(),
1276 const key_equal& __eql = key_equal(),
1277 const allocator_type& __a = allocator_type())
1278 : __table_(__hf, __eql, __a) {
1279 if (__n > 0) {
1280 __table_.__rehash_multi(__n);
1281 }
1282 insert_range(std::forward<_Range>(__range));
1283 }
1284# endif
1285
1286 template <class _InputIterator>
1287 inline _LIBCPP_HIDE_FROM_ABI
1288 unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
1289 : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
1290 template <class _InputIterator>
1291 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1292 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
1293 : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
1294
1295# if _LIBCPP_STD_VER >= 23
1296 template <_ContainerCompatibleRange<value_type> _Range>
1297 _LIBCPP_HIDE_FROM_ABI unordered_multiset(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
1298 : unordered_multiset(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
1299
1300 template <_ContainerCompatibleRange<value_type> _Range>
1301 _LIBCPP_HIDE_FROM_ABI
1302 unordered_multiset(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
1303 : unordered_multiset(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
1304# endif
1305
1306 _LIBCPP_HIDE_FROM_ABI explicit unordered_multiset(const allocator_type& __a);
1307 _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u) = default;
1308 _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
1309# ifndef _LIBCPP_CXX03_LANG
1310 _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u) = default;
1311 _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
1312 _LIBCPP_HIDE_FROM_ABI unordered_multiset(initializer_list<value_type> __il);
1313 _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1314 initializer_list<value_type> __il,
1315 size_type __n,
1316 const hasher& __hf = hasher(),
1317 const key_equal& __eql = key_equal());
1318 _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1319 initializer_list<value_type> __il,
1320 size_type __n,
1321 const hasher& __hf,
1322 const key_equal& __eql,
1323 const allocator_type& __a);
1324 inline _LIBCPP_HIDE_FROM_ABI
1325 unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1326 : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
1327 inline _LIBCPP_HIDE_FROM_ABI
1328 unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
1329 : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
1330# endif // _LIBCPP_CXX03_LANG
1331 _LIBCPP_HIDE_FROM_ABI ~unordered_multiset() {
1332 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
1333 }
1334
1335 _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(const unordered_multiset& __u) = default;
1336# ifndef _LIBCPP_CXX03_LANG
1337 _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(unordered_multiset&& __u) = default;
1338 _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(initializer_list<value_type> __il);
1339# endif // _LIBCPP_CXX03_LANG
1340
1341 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
1342 return allocator_type(__table_.__node_alloc());
1343 }
1344
1345 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
1346 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
1347 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
1348
1349 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); }
1350 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); }
1351 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); }
1352 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); }
1353 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
1354 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
1355
1356# ifndef _LIBCPP_CXX03_LANG
1357 template <class... _Args>
1358 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
1359 return __table_.__emplace_multi(std::forward<_Args>(__args)...);
1360 }
1361 template <class... _Args>
1362 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1363 return __table_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...);
1364 }
1365
1366 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__emplace_multi(std::move(__x)); }
1367 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) {
1368 return __table_.__emplace_hint_multi(__p, std::move(__x));
1369 }
1370 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
1371# endif // _LIBCPP_CXX03_LANG
1372
1373 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); }
1374
1375 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) {
1376 return __table_.__emplace_hint_multi(__p, __x);
1377 }
1378
1379 template <class _InputIterator>
1380 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
1381
1382# if _LIBCPP_STD_VER >= 23
1383 template <_ContainerCompatibleRange<value_type> _Range>
1384 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1385 for (auto&& __element : __range) {
1386 __table_.__emplace_multi(std::forward<decltype(__element)>(__element));
1387 }
1388 }
1389# endif
1390
1391# if _LIBCPP_STD_VER >= 17
1392 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {
1393 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
1394 "node_type with incompatible allocator passed to unordered_multiset::insert()");
1395 return __table_.template __node_handle_insert_multi<node_type>(std::move(__nh));
1396 }
1397 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {
1398 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
1399 "node_type with incompatible allocator passed to unordered_multiset::insert()");
1400 return __table_.template __node_handle_insert_multi<node_type>(__hint, std::move(__nh));
1401 }
1402 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __position) {
1403 return __table_.template __node_handle_extract<node_type>(__position);
1404 }
1405 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
1406 return __table_.template __node_handle_extract<node_type>(__key);
1407 }
1408
1409 template <class _H2, class _P2>
1410 _LIBCPP_HIDE_FROM_ABI void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source) {
1411 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1412 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
1413 return __table_.__node_handle_merge_multi(__source.__table_);
1414 }
1415 template <class _H2, class _P2>
1416 _LIBCPP_HIDE_FROM_ABI void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source) {
1417 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1418 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
1419 return __table_.__node_handle_merge_multi(__source.__table_);
1420 }
1421 template <class _H2, class _P2>
1422 _LIBCPP_HIDE_FROM_ABI void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source) {
1423 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1424 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
1425 return __table_.__node_handle_merge_multi(__source.__table_);
1426 }
1427 template <class _H2, class _P2>
1428 _LIBCPP_HIDE_FROM_ABI void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source) {
1429 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1430 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
1431 return __table_.__node_handle_merge_multi(__source.__table_);
1432 }
1433# endif
1434
1435 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); }
1436 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_multi(__k); }
1437 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
1438 return __table_.erase(__first, __last);
1439 }
1440 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
1441
1442 _LIBCPP_HIDE_FROM_ABI void swap(unordered_multiset& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
1443 __table_.swap(__u.__table_);
1444 }
1445
1446 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function(); }
1447 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq(); }
1448
1449 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
1450 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
1451# if _LIBCPP_STD_VER >= 20
1452 template <class _K2,
1453 class _Hasher = hasher,
1454 class _Comp = key_equal,
1455 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
1456 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1457 return __table_.find(__k);
1458 }
1459 template <class _K2,
1460 class _Hasher = hasher,
1461 class _Comp = key_equal,
1462 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
1463 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1464 return __table_.find(__k);
1465 }
1466# endif // _LIBCPP_STD_VER >= 20
1467
1468 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const {
1469 return __table_.__count_multi(__k);
1470 }
1471# if _LIBCPP_STD_VER >= 20
1472 template <class _K2,
1473 class _Hasher = hasher,
1474 class _Comp = key_equal,
1475 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
1476 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1477 return __table_.__count_multi(__k);
1478 }
1479# endif // _LIBCPP_STD_VER >= 20
1480
1481# if _LIBCPP_STD_VER >= 20
1482 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1483
1484 template <class _K2,
1485 class _Hasher = hasher,
1486 class _Comp = key_equal,
1487 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
1488 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1489 return find(__k) != end();
1490 }
1491# endif // _LIBCPP_STD_VER >= 20
1492
1493 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
1494 return __table_.__equal_range_multi(__k);
1495 }
1496 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
1497 return __table_.__equal_range_multi(__k);
1498 }
1499# if _LIBCPP_STD_VER >= 20
1500 template <class _K2,
1501 class _Hasher = hasher,
1502 class _Comp = key_equal,
1503 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
1504 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
1505 return __table_.__equal_range_multi(__k);
1506 }
1507 template <class _K2,
1508 class _Hasher = hasher,
1509 class _Comp = key_equal,
1510 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
1511 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
1512 return __table_.__equal_range_multi(__k);
1513 }
1514# endif // _LIBCPP_STD_VER >= 20
1515
1516 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }
1517 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT {
1518 return __table_.max_bucket_count();
1519 }
1520
1521 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const {
1522 return __table_.bucket_size(__n);
1523 }
1524 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); }
1525
1526 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); }
1527 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); }
1528 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const {
1529 return __table_.cbegin(__n);
1530 }
1531 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); }
1532 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const {
1533 return __table_.cbegin(__n);
1534 }
1535 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); }
1536
1537 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); }
1538 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); }
1539 _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); }
1540 _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_multi(__n); }
1541 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); }
1542};
1543
1544# if _LIBCPP_STD_VER >= 17
1545template <class _InputIterator,
1546 class _Hash = hash<__iterator_value_type<_InputIterator>>,
1547 class _Pred = equal_to<__iterator_value_type<_InputIterator>>,
1548 class _Allocator = allocator<__iterator_value_type<_InputIterator>>,
1549 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1550 class = enable_if_t<!__is_allocator_v<_Hash>>,
1551 class = enable_if_t<!is_integral<_Hash>::value>,
1552 class = enable_if_t<!__is_allocator_v<_Pred>>,
1553 class = enable_if_t<__is_allocator_v<_Allocator>>>
1554unordered_multiset(
1555 _InputIterator,
1556 _InputIterator,
1557 typename allocator_traits<_Allocator>::size_type = 0,
1558 _Hash = _Hash(),
1559 _Pred = _Pred(),
1560 _Allocator = _Allocator()) -> unordered_multiset<__iterator_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
1561
1562# if _LIBCPP_STD_VER >= 23
1563template <ranges::input_range _Range,
1564 class _Hash = hash<ranges::range_value_t<_Range>>,
1565 class _Pred = equal_to<ranges::range_value_t<_Range>>,
1566 class _Allocator = allocator<ranges::range_value_t<_Range>>,
1567 class = enable_if_t<!__is_allocator_v<_Hash>>,
1568 class = enable_if_t<!is_integral<_Hash>::value>,
1569 class = enable_if_t<!__is_allocator_v<_Pred>>,
1570 class = enable_if_t<__is_allocator_v<_Allocator>>>
1571unordered_multiset(
1572 from_range_t,
1573 _Range&&,
1574 typename allocator_traits<_Allocator>::size_type = 0,
1575 _Hash = _Hash(),
1576 _Pred = _Pred(),
1577 _Allocator = _Allocator()) -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
1578# endif
1579
1580template <class _Tp,
1581 class _Hash = hash<_Tp>,
1582 class _Pred = equal_to<_Tp>,
1583 class _Allocator = allocator<_Tp>,
1584 class = enable_if_t<!__is_allocator_v<_Hash>>,
1585 class = enable_if_t<!is_integral<_Hash>::value>,
1586 class = enable_if_t<!__is_allocator_v<_Pred>>,
1587 class = enable_if_t<__is_allocator_v<_Allocator>>>
1588unordered_multiset(initializer_list<_Tp>,
1589 typename allocator_traits<_Allocator>::size_type = 0,
1590 _Hash = _Hash(),
1591 _Pred = _Pred(),
1592 _Allocator = _Allocator()) -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>;
1593
1594template <class _InputIterator,
1595 class _Allocator,
1596 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1597 class = enable_if_t<__is_allocator_v<_Allocator>>>
1598unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
1599 -> unordered_multiset<__iterator_value_type<_InputIterator>,
1600 hash<__iterator_value_type<_InputIterator>>,
1601 equal_to<__iterator_value_type<_InputIterator>>,
1602 _Allocator>;
1603
1604template <class _InputIterator,
1605 class _Hash,
1606 class _Allocator,
1607 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1608 class = enable_if_t<!__is_allocator_v<_Hash>>,
1609 class = enable_if_t<!is_integral<_Hash>::value>,
1610 class = enable_if_t<__is_allocator_v<_Allocator>>>
1611unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1612 -> unordered_multiset<__iterator_value_type<_InputIterator>,
1613 _Hash,
1614 equal_to<__iterator_value_type<_InputIterator>>,
1615 _Allocator>;
1616
1617# if _LIBCPP_STD_VER >= 23
1618
1619template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>>
1620unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
1621 -> unordered_multiset<ranges::range_value_t<_Range>,
1622 hash<ranges::range_value_t<_Range>>,
1623 equal_to<ranges::range_value_t<_Range>>,
1624 _Allocator>;
1625
1626template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>>
1627unordered_multiset(from_range_t, _Range&&, _Allocator)
1628 -> unordered_multiset<ranges::range_value_t<_Range>,
1629 hash<ranges::range_value_t<_Range>>,
1630 equal_to<ranges::range_value_t<_Range>>,
1631 _Allocator>;
1632
1633template <ranges::input_range _Range,
1634 class _Hash,
1635 class _Allocator,
1636 class = enable_if_t<!__is_allocator_v<_Hash>>,
1637 class = enable_if_t<!is_integral<_Hash>::value>,
1638 class = enable_if_t<__is_allocator_v<_Allocator>>>
1639unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1640 -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>;
1641
1642# endif
1643
1644template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator_v<_Allocator>>>
1645unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
1646 -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
1647
1648template <class _Tp,
1649 class _Hash,
1650 class _Allocator,
1651 class = enable_if_t<!__is_allocator_v<_Hash>>,
1652 class = enable_if_t<!is_integral<_Hash>::value>,
1653 class = enable_if_t<__is_allocator_v<_Allocator>>>
1654unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1655 -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
1656# endif
1657
1658template <class _Value, class _Hash, class _Pred, class _Alloc>
1659unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1660 size_type __n, const hasher& __hf, const key_equal& __eql)
1661 : __table_(__hf, __eql) {
1662 __table_.__rehash_multi(__n);
1663}
1664
1665template <class _Value, class _Hash, class _Pred, class _Alloc>
1666unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1667 size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1668 : __table_(__hf, __eql, __a) {
1669 __table_.__rehash_multi(__n);
1670}
1671
1672template <class _Value, class _Hash, class _Pred, class _Alloc>
1673template <class _InputIterator>
1674unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(_InputIterator __first, _InputIterator __last) {
1675 insert(__first, __last);
1676}
1677
1678template <class _Value, class _Hash, class _Pred, class _Alloc>
1679template <class _InputIterator>
1680unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1681 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql)
1682 : __table_(__hf, __eql) {
1683 __table_.__rehash_multi(__n);
1684 insert(__first, __last);
1685}
1686
1687template <class _Value, class _Hash, class _Pred, class _Alloc>
1688template <class _InputIterator>
1689unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1690 _InputIterator __first,
1691 _InputIterator __last,
1692 size_type __n,
1693 const hasher& __hf,
1694 const key_equal& __eql,
1695 const allocator_type& __a)
1696 : __table_(__hf, __eql, __a) {
1697 __table_.__rehash_multi(__n);
1698 insert(__first, __last);
1699}
1700
1701template <class _Value, class _Hash, class _Pred, class _Alloc>
1702inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(const allocator_type& __a)
1703 : __table_(__a) {}
1704
1705template <class _Value, class _Hash, class _Pred, class _Alloc>
1706unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1707 const unordered_multiset& __u, const allocator_type& __a)
1708 : __table_(__u.__table_, __a) {
1709 __table_.__rehash_multi(__u.bucket_count());
1710 insert(__u.begin(), __u.end());
1711}
1712
1713# ifndef _LIBCPP_CXX03_LANG
1714
1715template <class _Value, class _Hash, class _Pred, class _Alloc>
1716unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1717 unordered_multiset&& __u, const allocator_type& __a)
1718 : __table_(std::move(__u.__table_), __a) {
1719 if (__a != __u.get_allocator()) {
1720 iterator __i = __u.begin();
1721 while (__u.size() != 0)
1722 __table_.__emplace_multi(std::move(__u.__table_.remove(__i++)->__get_value()));
1723 }
1724}
1725
1726template <class _Value, class _Hash, class _Pred, class _Alloc>
1727unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(initializer_list<value_type> __il) {
1728 insert(__il.begin(), __il.end());
1729}
1730
1731template <class _Value, class _Hash, class _Pred, class _Alloc>
1732unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1733 initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql)
1734 : __table_(__hf, __eql) {
1735 __table_.__rehash_multi(__n);
1736 insert(__il.begin(), __il.end());
1737}
1738
1739template <class _Value, class _Hash, class _Pred, class _Alloc>
1740unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1741 initializer_list<value_type> __il,
1742 size_type __n,
1743 const hasher& __hf,
1744 const key_equal& __eql,
1745 const allocator_type& __a)
1746 : __table_(__hf, __eql, __a) {
1747 __table_.__rehash_multi(__n);
1748 insert(__il.begin(), __il.end());
1749}
1750
1751template <class _Value, class _Hash, class _Pred, class _Alloc>
1752inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1753unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) {
1754 __table_.__assign_multi(__il.begin(), __il.end());
1755 return *this;
1756}
1757
1758# endif // _LIBCPP_CXX03_LANG
1759
1760template <class _Value, class _Hash, class _Pred, class _Alloc>
1761template <class _InputIterator>
1762inline void unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
1763 for (; __first != __last; ++__first)
1764 __table_.__emplace_multi(*__first);
1765}
1766
1767template <class _Value, class _Hash, class _Pred, class _Alloc>
1768inline _LIBCPP_HIDE_FROM_ABI void
1769swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1770 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
1771 __x.swap(__y);
1772}
1773
1774# if _LIBCPP_STD_VER >= 20
1775template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
1776inline _LIBCPP_HIDE_FROM_ABI typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type
1777erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
1778 return std::__libcpp_erase_if_container(__c, __pred);
1779}
1780# endif
1781
1782template <class _Value, class _Hash, class _Pred, class _Alloc>
1783_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1784 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) {
1785 if (__x.size() != __y.size())
1786 return false;
1787 typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator const_iterator;
1788 typedef pair<const_iterator, const_iterator> _EqRng;
1789 for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) {
1790 _EqRng __xeq = __x.equal_range(*__i);
1791 _EqRng __yeq = __y.equal_range(*__i);
1792 if (std::distance(__xeq.first, __xeq.second) != std::distance(__yeq.first, __yeq.second) ||
1793 !std::is_permutation(__xeq.first, __xeq.second, __yeq.first))
1794 return false;
1795 __i = __xeq.second;
1796 }
1797 return true;
1798}
1799
1800# if _LIBCPP_STD_VER <= 17
1801
1802template <class _Value, class _Hash, class _Pred, class _Alloc>
1803inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1804 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) {
1805 return !(__x == __y);
1806}
1807
1808# endif
1809
1810template <class _Value, class _Hash, class _Pred, class _Alloc>
1811struct __container_traits<unordered_multiset<_Value, _Hash, _Pred, _Alloc> > {
1812 // http://eel.is/c++draft/unord.req.except#2
1813 // For unordered associative containers, if an exception is thrown by any operation
1814 // other than the container's hash function from within an insert or emplace function
1815 // inserting a single element, the insertion has no effect.
1816 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
1817 __is_nothrow_invocable_v<_Hash, const _Value&>;
1818
1819 static _LIBCPP_CONSTEXPR const bool __reservable = true;
1820};
1821
1822_LIBCPP_END_NAMESPACE_STD
1823
1824# if _LIBCPP_STD_VER >= 17
1825_LIBCPP_BEGIN_NAMESPACE_STD
1826namespace pmr {
1827template <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
1828using unordered_set _LIBCPP_AVAILABILITY_PMR = std::unordered_set<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;
1829
1830template <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
1831using unordered_multiset _LIBCPP_AVAILABILITY_PMR =
1832 std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;
1833} // namespace pmr
1834_LIBCPP_END_NAMESPACE_STD
1835# endif
1836
1837_LIBCPP_POP_MACROS
1838
1839# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
1840# include <cmath>
1841# include <concepts>
1842# include <cstdlib>
1843# include <functional>
1844# include <iterator>
1845# include <stdexcept>
1846# include <type_traits>
1847# endif
1848#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
1849
1850#endif // _LIBCPP_UNORDERED_SET