xref: /freebsd/contrib/llvm-project/libcxx/include/unordered_set (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric// -*- C++ -*-
2349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_UNORDERED_SET
110b57cec5SDimitry Andric#define _LIBCPP_UNORDERED_SET
120b57cec5SDimitry Andric
135f757f3fSDimitry Andric// clang-format off
145f757f3fSDimitry Andric
150b57cec5SDimitry Andric/*
160b57cec5SDimitry Andric
170b57cec5SDimitry Andric    unordered_set synopsis
180b57cec5SDimitry Andric
190b57cec5SDimitry Andric#include <initializer_list>
200b57cec5SDimitry Andric
210b57cec5SDimitry Andricnamespace std
220b57cec5SDimitry Andric{
230b57cec5SDimitry Andric
240b57cec5SDimitry Andrictemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
250b57cec5SDimitry Andric          class Alloc = allocator<Value>>
260b57cec5SDimitry Andricclass unordered_set
270b57cec5SDimitry Andric{
280b57cec5SDimitry Andricpublic:
290b57cec5SDimitry Andric    // types
300b57cec5SDimitry Andric    typedef Value                                                      key_type;
310b57cec5SDimitry Andric    typedef key_type                                                   value_type;
320b57cec5SDimitry Andric    typedef Hash                                                       hasher;
330b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
340b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
350b57cec5SDimitry Andric    typedef value_type&                                                reference;
360b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
370b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
380b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
390b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
400b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
410b57cec5SDimitry Andric
420b57cec5SDimitry Andric    typedef /unspecified/ iterator;
430b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
440b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
450b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
460b57cec5SDimitry Andric
470b57cec5SDimitry Andric    typedef unspecified node_type unspecified;                            // C++17
480b57cec5SDimitry Andric    typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type;   // C++17
490b57cec5SDimitry Andric
500b57cec5SDimitry Andric    unordered_set()
510b57cec5SDimitry Andric        noexcept(
520b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
530b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
540b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
550b57cec5SDimitry Andric    explicit unordered_set(size_type n, const hasher& hf = hasher(),
560b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
570b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
580b57cec5SDimitry Andric    template <class InputIterator>
590b57cec5SDimitry Andric        unordered_set(InputIterator f, InputIterator l,
600b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
610b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
620b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
6306c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
6406c3fb27SDimitry Andric      unordered_set(from_range_t, R&& rg, size_type n = see below,
6506c3fb27SDimitry Andric        const hasher& hf = hasher(), const key_equal& eql = key_equal(),
6606c3fb27SDimitry Andric        const allocator_type& a = allocator_type()); // C++23
670b57cec5SDimitry Andric    explicit unordered_set(const allocator_type&);
680b57cec5SDimitry Andric    unordered_set(const unordered_set&);
690b57cec5SDimitry Andric    unordered_set(const unordered_set&, const Allocator&);
700b57cec5SDimitry Andric    unordered_set(unordered_set&&)
710b57cec5SDimitry Andric        noexcept(
720b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
730b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
740b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
750b57cec5SDimitry Andric    unordered_set(unordered_set&&, const Allocator&);
760b57cec5SDimitry Andric    unordered_set(initializer_list<value_type>, size_type n = 0,
770b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
780b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
790b57cec5SDimitry Andric    unordered_set(size_type n, const allocator_type& a); // C++14
800b57cec5SDimitry Andric    unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
810b57cec5SDimitry Andric    template <class InputIterator>
820b57cec5SDimitry Andric      unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
830b57cec5SDimitry Andric    template <class InputIterator>
840b57cec5SDimitry Andric      unordered_set(InputIterator f, InputIterator l, size_type n,
850b57cec5SDimitry Andric                    const hasher& hf,  const allocator_type& a); // C++14
8606c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
8706c3fb27SDimitry Andric      unordered_set(from_range_t, R&& rg, size_type n, const allocator_type& a)
8806c3fb27SDimitry Andric        : unordered_set(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
8906c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
9006c3fb27SDimitry Andric      unordered_set(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
9106c3fb27SDimitry Andric        : unordered_set(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }       // C++23
920b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
930b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> il, size_type n,
940b57cec5SDimitry Andric                  const hasher& hf,  const allocator_type& a); // C++14
950b57cec5SDimitry Andric    ~unordered_set();
960b57cec5SDimitry Andric    unordered_set& operator=(const unordered_set&);
970b57cec5SDimitry Andric    unordered_set& operator=(unordered_set&&)
980b57cec5SDimitry Andric        noexcept(
990b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
1000b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
1010b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
1020b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
1030b57cec5SDimitry Andric    unordered_set& operator=(initializer_list<value_type>);
1040b57cec5SDimitry Andric
1050b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
1060b57cec5SDimitry Andric
1070b57cec5SDimitry Andric    bool      empty() const noexcept;
1080b57cec5SDimitry Andric    size_type size() const noexcept;
1090b57cec5SDimitry Andric    size_type max_size() const noexcept;
1100b57cec5SDimitry Andric
1110b57cec5SDimitry Andric    iterator       begin() noexcept;
1120b57cec5SDimitry Andric    iterator       end() noexcept;
1130b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
1140b57cec5SDimitry Andric    const_iterator end()    const noexcept;
1150b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
1160b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
1170b57cec5SDimitry Andric
1180b57cec5SDimitry Andric    template <class... Args>
1190b57cec5SDimitry Andric        pair<iterator, bool> emplace(Args&&... args);
1200b57cec5SDimitry Andric    template <class... Args>
1210b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
1220b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& obj);
1230b57cec5SDimitry Andric    pair<iterator, bool> insert(value_type&& obj);
1240b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
1250b57cec5SDimitry Andric    iterator insert(const_iterator hint, value_type&& obj);
1260b57cec5SDimitry Andric    template <class InputIterator>
1270b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
12806c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
12906c3fb27SDimitry Andric      void insert_range(R&& rg);                                      // C++23
1300b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
1310b57cec5SDimitry Andric
1320b57cec5SDimitry Andric    node_type extract(const_iterator position);                       // C++17
1330b57cec5SDimitry Andric    node_type extract(const key_type& x);                             // C++17
1340b57cec5SDimitry Andric    insert_return_type insert(node_type&& nh);                        // C++17
1350b57cec5SDimitry Andric    iterator           insert(const_iterator hint, node_type&& nh);   // C++17
1360b57cec5SDimitry Andric
1370b57cec5SDimitry Andric    iterator erase(const_iterator position);
1380b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
1390b57cec5SDimitry Andric    size_type erase(const key_type& k);
1400b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
1410b57cec5SDimitry Andric    void clear() noexcept;
1420b57cec5SDimitry Andric
1430b57cec5SDimitry Andric    template<class H2, class P2>
1440b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>& source);         // C++17
1450b57cec5SDimitry Andric    template<class H2, class P2>
1460b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>&& source);        // C++17
1470b57cec5SDimitry Andric    template<class H2, class P2>
1480b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>& source);    // C++17
1490b57cec5SDimitry Andric    template<class H2, class P2>
1500b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);   // C++17
1510b57cec5SDimitry Andric
1520b57cec5SDimitry Andric    void swap(unordered_set&)
1530b57cec5SDimitry Andric       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
1540b57cec5SDimitry Andric                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
1550b57cec5SDimitry Andric                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
1560b57cec5SDimitry Andric
1570b57cec5SDimitry Andric    hasher hash_function() const;
1580b57cec5SDimitry Andric    key_equal key_eq() const;
1590b57cec5SDimitry Andric
1600b57cec5SDimitry Andric    iterator       find(const key_type& k);
1610b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
162e8d8bef9SDimitry Andric    template<typename K>
163e8d8bef9SDimitry Andric        iterator find(const K& x);              // C++20
164e8d8bef9SDimitry Andric    template<typename K>
165e8d8bef9SDimitry Andric        const_iterator find(const K& x) const;  // C++20
1660b57cec5SDimitry Andric    size_type count(const key_type& k) const;
167e8d8bef9SDimitry Andric    template<typename K>
168e8d8bef9SDimitry Andric        size_type count(const K& k) const; // C++20
1690b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
170e8d8bef9SDimitry Andric    template<typename K>
171e8d8bef9SDimitry Andric        bool contains(const K& k) const; // C++20
1720b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
1730b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
174e8d8bef9SDimitry Andric    template<typename K>
175e8d8bef9SDimitry Andric        pair<iterator, iterator>             equal_range(const K& k); // C++20
176e8d8bef9SDimitry Andric    template<typename K>
177e8d8bef9SDimitry Andric        pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
1780b57cec5SDimitry Andric
1790b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
1800b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
1810b57cec5SDimitry Andric
1820b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
1830b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
1840b57cec5SDimitry Andric
1850b57cec5SDimitry Andric    local_iterator       begin(size_type n);
1860b57cec5SDimitry Andric    local_iterator       end(size_type n);
1870b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
1880b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
1890b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
1900b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
1910b57cec5SDimitry Andric
1920b57cec5SDimitry Andric    float load_factor() const noexcept;
1930b57cec5SDimitry Andric    float max_load_factor() const noexcept;
1940b57cec5SDimitry Andric    void max_load_factor(float z);
1950b57cec5SDimitry Andric    void rehash(size_type n);
1960b57cec5SDimitry Andric    void reserve(size_type n);
1970b57cec5SDimitry Andric};
1980b57cec5SDimitry Andric
199349cc55cSDimitry Andrictemplate<class InputIterator,
200349cc55cSDimitry Andric    class Hash = hash<typename iterator_traits<InputIterator>::value_type>,
201349cc55cSDimitry Andric    class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>,
202349cc55cSDimitry Andric    class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
203349cc55cSDimitry Andricunordered_set(InputIterator, InputIterator, typename see below::size_type = see below,
204349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
205349cc55cSDimitry Andric  -> unordered_set<typename iterator_traits<InputIterator>::value_type,
206349cc55cSDimitry Andric        Hash, Pred, Allocator>; // C++17
207349cc55cSDimitry Andric
20806c3fb27SDimitry Andrictemplate<ranges::input_range R,
20906c3fb27SDimitry Andric         class Hash = hash<ranges::range_value_t<R>>,
21006c3fb27SDimitry Andric         class Pred = equal_to<ranges::range_value_t<R>>,
21106c3fb27SDimitry Andric         class Allocator = allocator<ranges::range_value_t<R>>>
21206c3fb27SDimitry Andric  unordered_set(from_range_t, R&&, typename see below::size_type = see below, Hash = Hash(), Pred = Pred(), Allocator = Allocator())
21306c3fb27SDimitry Andric    -> unordered_set<ranges::range_value_t<R>, Hash, Pred, Allocator>; // C++23
21406c3fb27SDimitry Andric
215349cc55cSDimitry Andrictemplate<class T, class Hash = hash<T>,
216349cc55cSDimitry Andric          class Pred = equal_to<T>, class Allocator = allocator<T>>
217349cc55cSDimitry Andricunordered_set(initializer_list<T>, typename see below::size_type = see below,
218349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
219349cc55cSDimitry Andric  -> unordered_set<T, Hash, Pred, Allocator>; // C++17
220349cc55cSDimitry Andric
221349cc55cSDimitry Andrictemplate<class InputIterator,  class Allocator>
222349cc55cSDimitry Andricunordered_set(InputIterator, InputIterator, typename see below::size_type, Allocator)
223349cc55cSDimitry Andric  -> unordered_set<typename iterator_traits<InputIterator>::value_type,
224349cc55cSDimitry Andric        hash<typename iterator_traits<InputIterator>::value_type>,
225349cc55cSDimitry Andric        equal_to<typename iterator_traits<InputIterator>::value_type>,
226349cc55cSDimitry Andric        Allocator>; // C++17
227349cc55cSDimitry Andric
228349cc55cSDimitry Andrictemplate<class InputIterator, class Hash, class Allocator>
229349cc55cSDimitry Andricunordered_set(InputIterator, InputIterator, typename see below::size_type,
230349cc55cSDimitry Andric    Hash, Allocator)
231349cc55cSDimitry Andric  -> unordered_set<typename iterator_traits<InputIterator>::value_type, Hash,
232349cc55cSDimitry Andric        equal_to<typename iterator_traits<InputIterator>::value_type>,
233349cc55cSDimitry Andric        Allocator>; // C++17
234349cc55cSDimitry Andric
23506c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
23606c3fb27SDimitry Andric  unordered_set(from_range_t, R&&, typename see below::size_type, Allocator)
23706c3fb27SDimitry Andric    -> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
23806c3fb27SDimitry Andric                      equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
23906c3fb27SDimitry Andric
24006c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
24106c3fb27SDimitry Andric  unordered_set(from_range_t, R&&, Allocator)
24206c3fb27SDimitry Andric    -> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
24306c3fb27SDimitry Andric                      equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
24406c3fb27SDimitry Andric
24506c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator>
24606c3fb27SDimitry Andric  unordered_set(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
24706c3fb27SDimitry Andric    -> unordered_set<ranges::range_value_t<R>, Hash,
24806c3fb27SDimitry Andric                      equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
24906c3fb27SDimitry Andric
250349cc55cSDimitry Andrictemplate<class T, class Allocator>
251349cc55cSDimitry Andricunordered_set(initializer_list<T>, typename see below::size_type, Allocator)
252349cc55cSDimitry Andric  -> unordered_set<T, hash<T>, equal_to<T>, Allocator>; // C++17
253349cc55cSDimitry Andric
254349cc55cSDimitry Andrictemplate<class T, class Hash, class Allocator>
255349cc55cSDimitry Andricunordered_set(initializer_list<T>, typename see below::size_type, Hash, Allocator)
256349cc55cSDimitry Andric  -> unordered_set<T, Hash, equal_to<T>, Allocator>; // C++17
257349cc55cSDimitry Andric
2580b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
2590b57cec5SDimitry Andric    void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
2600b57cec5SDimitry Andric              unordered_set<Value, Hash, Pred, Alloc>& y)
2610b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
2620b57cec5SDimitry Andric
2630b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
2640b57cec5SDimitry Andric    bool
2650b57cec5SDimitry Andric    operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
2660b57cec5SDimitry Andric               const unordered_set<Value, Hash, Pred, Alloc>& y);
2670b57cec5SDimitry Andric
2680b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
2690b57cec5SDimitry Andric    bool
2700b57cec5SDimitry Andric    operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
27106c3fb27SDimitry Andric               const unordered_set<Value, Hash, Pred, Alloc>& y); // removed in C++20
2720b57cec5SDimitry Andric
2730b57cec5SDimitry Andrictemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
2740b57cec5SDimitry Andric          class Alloc = allocator<Value>>
2750b57cec5SDimitry Andricclass unordered_multiset
2760b57cec5SDimitry Andric{
2770b57cec5SDimitry Andricpublic:
2780b57cec5SDimitry Andric    // types
2790b57cec5SDimitry Andric    typedef Value                                                      key_type;
2800b57cec5SDimitry Andric    typedef key_type                                                   value_type;
2810b57cec5SDimitry Andric    typedef Hash                                                       hasher;
2820b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
2830b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
2840b57cec5SDimitry Andric    typedef value_type&                                                reference;
2850b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
2860b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
2870b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
2880b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
2890b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
2900b57cec5SDimitry Andric
2910b57cec5SDimitry Andric    typedef /unspecified/ iterator;
2920b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
2930b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
2940b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
2950b57cec5SDimitry Andric
2960b57cec5SDimitry Andric    typedef unspecified node_type unspecified;   // C++17
2970b57cec5SDimitry Andric
2980b57cec5SDimitry Andric    unordered_multiset()
2990b57cec5SDimitry Andric        noexcept(
3000b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
3010b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
3020b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
3030b57cec5SDimitry Andric    explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
3040b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
3050b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
3060b57cec5SDimitry Andric    template <class InputIterator>
3070b57cec5SDimitry Andric        unordered_multiset(InputIterator f, InputIterator l,
3080b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
3090b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
3100b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
31106c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
31206c3fb27SDimitry Andric      unordered_multiset(from_range_t, R&& rg, size_type n = see below,
31306c3fb27SDimitry Andric        const hasher& hf = hasher(), const key_equal& eql = key_equal(),
31406c3fb27SDimitry Andric        const allocator_type& a = allocator_type()); // C++23
3150b57cec5SDimitry Andric    explicit unordered_multiset(const allocator_type&);
3160b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset&);
3170b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset&, const Allocator&);
3180b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&&)
3190b57cec5SDimitry Andric        noexcept(
3200b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
3210b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
3220b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
3230b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&&, const Allocator&);
3240b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
3250b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
3260b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
3270b57cec5SDimitry Andric    unordered_multiset(size_type n, const allocator_type& a); // C++14
3280b57cec5SDimitry Andric    unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
3290b57cec5SDimitry Andric    template <class InputIterator>
3300b57cec5SDimitry Andric      unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
3310b57cec5SDimitry Andric    template <class InputIterator>
3320b57cec5SDimitry Andric      unordered_multiset(InputIterator f, InputIterator l, size_type n,
3330b57cec5SDimitry Andric                         const hasher& hf, const allocator_type& a); // C++14
33406c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
33506c3fb27SDimitry Andric      unordered_multiset(from_range_t, R&& rg, size_type n, const allocator_type& a)
33606c3fb27SDimitry Andric        : unordered_multiset(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
33706c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
33806c3fb27SDimitry Andric      unordered_multiset(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
33906c3fb27SDimitry Andric        : unordered_multiset(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }       // C++23
3400b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
3410b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> il, size_type n,
3420b57cec5SDimitry Andric                       const hasher& hf,  const allocator_type& a); // C++14
3430b57cec5SDimitry Andric    ~unordered_multiset();
3440b57cec5SDimitry Andric    unordered_multiset& operator=(const unordered_multiset&);
3450b57cec5SDimitry Andric    unordered_multiset& operator=(unordered_multiset&&)
3460b57cec5SDimitry Andric        noexcept(
3470b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
3480b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
3490b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
3500b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
3510b57cec5SDimitry Andric    unordered_multiset& operator=(initializer_list<value_type>);
3520b57cec5SDimitry Andric
3530b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
3540b57cec5SDimitry Andric
3550b57cec5SDimitry Andric    bool      empty() const noexcept;
3560b57cec5SDimitry Andric    size_type size() const noexcept;
3570b57cec5SDimitry Andric    size_type max_size() const noexcept;
3580b57cec5SDimitry Andric
3590b57cec5SDimitry Andric    iterator       begin() noexcept;
3600b57cec5SDimitry Andric    iterator       end() noexcept;
3610b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
3620b57cec5SDimitry Andric    const_iterator end()    const noexcept;
3630b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
3640b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
3650b57cec5SDimitry Andric
3660b57cec5SDimitry Andric    template <class... Args>
3670b57cec5SDimitry Andric        iterator emplace(Args&&... args);
3680b57cec5SDimitry Andric    template <class... Args>
3690b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
3700b57cec5SDimitry Andric    iterator insert(const value_type& obj);
3710b57cec5SDimitry Andric    iterator insert(value_type&& obj);
3720b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
3730b57cec5SDimitry Andric    iterator insert(const_iterator hint, value_type&& obj);
3740b57cec5SDimitry Andric    template <class InputIterator>
3750b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
37606c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
37706c3fb27SDimitry Andric      void insert_range(R&& rg);                            // C++23
3780b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
3790b57cec5SDimitry Andric
3800b57cec5SDimitry Andric    node_type extract(const_iterator position);             // C++17
3810b57cec5SDimitry Andric    node_type extract(const key_type& x);                   // C++17
3820b57cec5SDimitry Andric    iterator insert(node_type&& nh);                        // C++17
3830b57cec5SDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);   // C++17
3840b57cec5SDimitry Andric
3850b57cec5SDimitry Andric    iterator erase(const_iterator position);
3860b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
3870b57cec5SDimitry Andric    size_type erase(const key_type& k);
3880b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
3890b57cec5SDimitry Andric    void clear() noexcept;
3900b57cec5SDimitry Andric
3910b57cec5SDimitry Andric    template<class H2, class P2>
3920b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>& source);    // C++17
3930b57cec5SDimitry Andric    template<class H2, class P2>
3940b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);   // C++17
3950b57cec5SDimitry Andric    template<class H2, class P2>
3960b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>& source);         // C++17
3970b57cec5SDimitry Andric    template<class H2, class P2>
3980b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>&& source);        // C++17
3990b57cec5SDimitry Andric
4000b57cec5SDimitry Andric    void swap(unordered_multiset&)
4010b57cec5SDimitry Andric       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
4020b57cec5SDimitry Andric                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
4030b57cec5SDimitry Andric                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
4040b57cec5SDimitry Andric
4050b57cec5SDimitry Andric    hasher hash_function() const;
4060b57cec5SDimitry Andric    key_equal key_eq() const;
4070b57cec5SDimitry Andric
4080b57cec5SDimitry Andric    iterator       find(const key_type& k);
4090b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
410e8d8bef9SDimitry Andric    template<typename K>
411e8d8bef9SDimitry Andric        iterator find(const K& x);              // C++20
412e8d8bef9SDimitry Andric    template<typename K>
413e8d8bef9SDimitry Andric        const_iterator find(const K& x) const;  // C++20
4140b57cec5SDimitry Andric    size_type count(const key_type& k) const;
415e8d8bef9SDimitry Andric    template<typename K>
416e8d8bef9SDimitry Andric        size_type count(const K& k) const; // C++20
4170b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
418e8d8bef9SDimitry Andric    template<typename K>
419e8d8bef9SDimitry Andric        bool contains(const K& k) const; // C++20
4200b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
4210b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
422e8d8bef9SDimitry Andric    template<typename K>
423e8d8bef9SDimitry Andric        pair<iterator, iterator>             equal_range(const K& k); // C++20
424e8d8bef9SDimitry Andric    template<typename K>
425e8d8bef9SDimitry Andric        pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
4260b57cec5SDimitry Andric
4270b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
4280b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
4290b57cec5SDimitry Andric
4300b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
4310b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
4320b57cec5SDimitry Andric
4330b57cec5SDimitry Andric    local_iterator       begin(size_type n);
4340b57cec5SDimitry Andric    local_iterator       end(size_type n);
4350b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
4360b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
4370b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
4380b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
4390b57cec5SDimitry Andric
4400b57cec5SDimitry Andric    float load_factor() const noexcept;
4410b57cec5SDimitry Andric    float max_load_factor() const noexcept;
4420b57cec5SDimitry Andric    void max_load_factor(float z);
4430b57cec5SDimitry Andric    void rehash(size_type n);
4440b57cec5SDimitry Andric    void reserve(size_type n);
4450b57cec5SDimitry Andric};
4460b57cec5SDimitry Andric
447349cc55cSDimitry Andrictemplate<class InputIterator,
448349cc55cSDimitry Andric    class Hash = hash<typename iterator_traits<InputIterator>::value_type>,
449349cc55cSDimitry Andric    class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>,
450349cc55cSDimitry Andric    class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
451349cc55cSDimitry Andricunordered_multiset(InputIterator, InputIterator, see below::size_type = see below,
452349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
453349cc55cSDimitry Andric  -> unordered_multiset<typename iterator_traits<InputIterator>::value_type,
454349cc55cSDimitry Andric        Hash, Pred, Allocator>; // C++17
455349cc55cSDimitry Andric
45606c3fb27SDimitry Andrictemplate<ranges::input_range R,
45706c3fb27SDimitry Andric         class Hash = hash<ranges::range_value_t<R>>,
45806c3fb27SDimitry Andric         class Pred = equal_to<ranges::range_value_t<R>>,
45906c3fb27SDimitry Andric         class Allocator = allocator<ranges::range_value_t<R>>>
46006c3fb27SDimitry Andric  unordered_multiset(from_range_t, R&&, typename see below::size_type = see below, Hash = Hash(), Pred = Pred(), Allocator = Allocator())
46106c3fb27SDimitry Andric    -> unordered_multiset<ranges::range_value_t<R>, Hash, Pred, Allocator>; // C++23
46206c3fb27SDimitry Andric
463349cc55cSDimitry Andrictemplate<class T, class Hash = hash<T>,
464349cc55cSDimitry Andric          class Pred = equal_to<T>, class Allocator = allocator<T>>
465349cc55cSDimitry Andricunordered_multiset(initializer_list<T>, typename see below::size_type = see below,
466349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
467349cc55cSDimitry Andric  -> unordered_multiset<T, Hash, Pred, Allocator>; // C++17
468349cc55cSDimitry Andric
469349cc55cSDimitry Andrictemplate<class InputIterator,  class Allocator>
470349cc55cSDimitry Andricunordered_multiset(InputIterator, InputIterator, typename see below::size_type, Allocator)
471349cc55cSDimitry Andric  -> unordered_multiset<typename iterator_traits<InputIterator>::value_type,
472349cc55cSDimitry Andric        hash<typename iterator_traits<InputIterator>::value_type>,
473349cc55cSDimitry Andric        equal_to<typename iterator_traits<InputIterator>::value_type>,
474349cc55cSDimitry Andric        Allocator>; // C++17
475349cc55cSDimitry Andric
476349cc55cSDimitry Andrictemplate<class InputIterator,  class Hash, class Allocator>
477349cc55cSDimitry Andricunordered_multiset(InputIterator, InputIterator, typename see below::size_type,
478349cc55cSDimitry Andric    Hash, Allocator)
479349cc55cSDimitry Andric  -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, Hash,
480349cc55cSDimitry Andric        equal_to<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17
481349cc55cSDimitry Andric
48206c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
48306c3fb27SDimitry Andric  unordered_multiset(from_range_t, R&&, typename see below::size_type, Allocator)
48406c3fb27SDimitry Andric    -> unordered_multiset<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
48506c3fb27SDimitry Andric                      equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
48606c3fb27SDimitry Andric
48706c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
48806c3fb27SDimitry Andric  unordered_multiset(from_range_t, R&&, Allocator)
48906c3fb27SDimitry Andric    -> unordered_multiset<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
49006c3fb27SDimitry Andric                      equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
49106c3fb27SDimitry Andric
49206c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator>
49306c3fb27SDimitry Andric  unordered_multiset(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
49406c3fb27SDimitry Andric    -> unordered_multiset<ranges::range_value_t<R>, Hash,
49506c3fb27SDimitry Andric                      equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
49606c3fb27SDimitry Andric
497349cc55cSDimitry Andrictemplate<class T, class Allocator>
498349cc55cSDimitry Andricunordered_multiset(initializer_list<T>, typename see below::size_type, Allocator)
499349cc55cSDimitry Andric  -> unordered_multiset<T, hash<T>, equal_to<T>, Allocator>; // C++17
500349cc55cSDimitry Andric
501349cc55cSDimitry Andrictemplate<class T, class Hash, class Allocator>
502349cc55cSDimitry Andricunordered_multiset(initializer_list<T>, typename see below::size_type, Hash, Allocator)
503349cc55cSDimitry Andric  -> unordered_multiset<T, Hash, equal_to<T>, Allocator>; // C++17
504349cc55cSDimitry Andric
5050b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
5060b57cec5SDimitry Andric    void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
5070b57cec5SDimitry Andric              unordered_multiset<Value, Hash, Pred, Alloc>& y)
5080b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
5090b57cec5SDimitry Andric
5100b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
5115ffd83dbSDimitry Andric    typename unordered_set<K, T, H, P, A>::size_type
5125ffd83dbSDimitry Andric    erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred);       // C++20
5130b57cec5SDimitry Andric
5140b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
5155ffd83dbSDimitry Andric    typename unordered_multiset<K, T, H, P, A>::size_type
5165ffd83dbSDimitry Andric    erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred);  // C++20
5170b57cec5SDimitry Andric
5180b57cec5SDimitry Andric
5190b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
5200b57cec5SDimitry Andric    bool
5210b57cec5SDimitry Andric    operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
5220b57cec5SDimitry Andric               const unordered_multiset<Value, Hash, Pred, Alloc>& y);
5230b57cec5SDimitry Andric
5240b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
5250b57cec5SDimitry Andric    bool
5260b57cec5SDimitry Andric    operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
52706c3fb27SDimitry Andric               const unordered_multiset<Value, Hash, Pred, Alloc>& y); // removed in C++20
5280b57cec5SDimitry Andric}  // std
5290b57cec5SDimitry Andric
5300b57cec5SDimitry Andric*/
5310b57cec5SDimitry Andric
5325f757f3fSDimitry Andric// clang-format on
5335f757f3fSDimitry Andric
53481ad6265SDimitry Andric#include <__algorithm/is_permutation.h>
535*0fca6ea1SDimitry Andric#include <__assert>
5360b57cec5SDimitry Andric#include <__config>
537fe6060f1SDimitry Andric#include <__functional/is_transparent.h>
53881ad6265SDimitry Andric#include <__functional/operations.h>
5390b57cec5SDimitry Andric#include <__hash_table>
54081ad6265SDimitry Andric#include <__iterator/distance.h>
54181ad6265SDimitry Andric#include <__iterator/erase_if_container.h>
54281ad6265SDimitry Andric#include <__iterator/iterator_traits.h>
54306c3fb27SDimitry Andric#include <__iterator/ranges_iterator_traits.h>
54404eeddc0SDimitry Andric#include <__memory/addressof.h>
545bdd1243dSDimitry Andric#include <__memory/allocator.h>
546bdd1243dSDimitry Andric#include <__memory_resource/polymorphic_allocator.h>
5470b57cec5SDimitry Andric#include <__node_handle>
54806c3fb27SDimitry Andric#include <__ranges/concepts.h>
54906c3fb27SDimitry Andric#include <__ranges/container_compatible_range.h>
55006c3fb27SDimitry Andric#include <__ranges/from_range.h>
551bdd1243dSDimitry Andric#include <__type_traits/is_allocator.h>
552fe6060f1SDimitry Andric#include <__utility/forward.h>
5530b57cec5SDimitry Andric#include <version>
5540b57cec5SDimitry Andric
55581ad6265SDimitry Andric// standard-mandated includes
55681ad6265SDimitry Andric
55781ad6265SDimitry Andric// [iterator.range]
55881ad6265SDimitry Andric#include <__iterator/access.h>
55981ad6265SDimitry Andric#include <__iterator/data.h>
56081ad6265SDimitry Andric#include <__iterator/empty.h>
56181ad6265SDimitry Andric#include <__iterator/reverse_access.h>
56281ad6265SDimitry Andric#include <__iterator/size.h>
56381ad6265SDimitry Andric
56481ad6265SDimitry Andric// [unord.set.syn]
56581ad6265SDimitry Andric#include <compare>
56681ad6265SDimitry Andric#include <initializer_list>
56781ad6265SDimitry Andric
5680b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5690b57cec5SDimitry Andric#  pragma GCC system_header
5700b57cec5SDimitry Andric#endif
5710b57cec5SDimitry Andric
572b3edf446SDimitry Andric_LIBCPP_PUSH_MACROS
573b3edf446SDimitry Andric#include <__undef_macros>
574b3edf446SDimitry Andric
5750b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
5760b57cec5SDimitry Andric
5770b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
5780b57cec5SDimitry Andricclass unordered_multiset;
5790b57cec5SDimitry Andric
580cb14a3feSDimitry Andrictemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >
581cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_set {
5820b57cec5SDimitry Andricpublic:
5830b57cec5SDimitry Andric  // types
5840b57cec5SDimitry Andric  typedef _Value key_type;
5850b57cec5SDimitry Andric  typedef key_type value_type;
58681ad6265SDimitry Andric  typedef __type_identity_t<_Hash> hasher;
58781ad6265SDimitry Andric  typedef __type_identity_t<_Pred> key_equal;
58881ad6265SDimitry Andric  typedef __type_identity_t<_Alloc> allocator_type;
5890b57cec5SDimitry Andric  typedef value_type& reference;
5900b57cec5SDimitry Andric  typedef const value_type& const_reference;
591*0fca6ea1SDimitry Andric  static_assert(__check_valid_allocator<allocator_type>::value, "");
592*0fca6ea1SDimitry Andric  static_assert(is_same<value_type, typename allocator_type::value_type>::value,
59306c3fb27SDimitry Andric                "Allocator::value_type must be same type as value_type");
5940b57cec5SDimitry Andric
5950b57cec5SDimitry Andricprivate:
5960b57cec5SDimitry Andric  typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
5970b57cec5SDimitry Andric
5980b57cec5SDimitry Andric  __table __table_;
5990b57cec5SDimitry Andric
6000b57cec5SDimitry Andricpublic:
6010b57cec5SDimitry Andric  typedef typename __table::pointer pointer;
6020b57cec5SDimitry Andric  typedef typename __table::const_pointer const_pointer;
6030b57cec5SDimitry Andric  typedef typename __table::size_type size_type;
6040b57cec5SDimitry Andric  typedef typename __table::difference_type difference_type;
6050b57cec5SDimitry Andric
6060b57cec5SDimitry Andric  typedef typename __table::const_iterator iterator;
6070b57cec5SDimitry Andric  typedef typename __table::const_iterator const_iterator;
6080b57cec5SDimitry Andric  typedef typename __table::const_local_iterator local_iterator;
6090b57cec5SDimitry Andric  typedef typename __table::const_local_iterator const_local_iterator;
6100b57cec5SDimitry Andric
61106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
6120b57cec5SDimitry Andric  typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
6130b57cec5SDimitry Andric  typedef __insert_return_type<iterator, node_type> insert_return_type;
6140b57cec5SDimitry Andric#endif
6150b57cec5SDimitry Andric
6160b57cec5SDimitry Andric  template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
6170b57cec5SDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_set;
6180b57cec5SDimitry Andric  template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
6190b57cec5SDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
6200b57cec5SDimitry Andric
621cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
622cb14a3feSDimitry Andric  explicit _LIBCPP_HIDE_FROM_ABI
623cb14a3feSDimitry Andric  unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
62406c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14
625cb14a3feSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const allocator_type& __a)
6260b57cec5SDimitry Andric      : unordered_set(__n, hasher(), key_equal(), __a) {}
627cb14a3feSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
6280b57cec5SDimitry Andric      : unordered_set(__n, __hf, key_equal(), __a) {}
6290b57cec5SDimitry Andric#endif
630cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
631cb14a3feSDimitry Andric  unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
6320b57cec5SDimitry Andric  template <class _InputIterator>
63306c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(_InputIterator __first, _InputIterator __last);
6340b57cec5SDimitry Andric  template <class _InputIterator>
635cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
636cb14a3feSDimitry Andric  unordered_set(_InputIterator __first,
637cb14a3feSDimitry Andric                _InputIterator __last,
638cb14a3feSDimitry Andric                size_type __n,
639cb14a3feSDimitry Andric                const hasher& __hf     = hasher(),
6400b57cec5SDimitry Andric                const key_equal& __eql = key_equal());
6410b57cec5SDimitry Andric  template <class _InputIterator>
642cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(
643cb14a3feSDimitry Andric      _InputIterator __first,
644cb14a3feSDimitry Andric      _InputIterator __last,
645cb14a3feSDimitry Andric      size_type __n,
646cb14a3feSDimitry Andric      const hasher& __hf,
647cb14a3feSDimitry Andric      const key_equal& __eql,
6480b57cec5SDimitry Andric      const allocator_type& __a);
64906c3fb27SDimitry Andric
65006c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
65106c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
652cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(
653cb14a3feSDimitry Andric      from_range_t,
654cb14a3feSDimitry Andric      _Range&& __range,
655cb14a3feSDimitry Andric      size_type __n             = /*implementation-defined*/ 0,
656cb14a3feSDimitry Andric      const hasher& __hf        = hasher(),
657cb14a3feSDimitry Andric      const key_equal& __eql    = key_equal(),
65806c3fb27SDimitry Andric      const allocator_type& __a = allocator_type())
65906c3fb27SDimitry Andric      : __table_(__hf, __eql, __a) {
66006c3fb27SDimitry Andric    if (__n > 0) {
66106c3fb27SDimitry Andric      __table_.__rehash_unique(__n);
66206c3fb27SDimitry Andric    }
66306c3fb27SDimitry Andric    insert_range(std::forward<_Range>(__range));
66406c3fb27SDimitry Andric  }
66506c3fb27SDimitry Andric#endif
66606c3fb27SDimitry Andric
66706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14
6680b57cec5SDimitry Andric  template <class _InputIterator>
6695f757f3fSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI
670cb14a3feSDimitry Andric  unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
6710b57cec5SDimitry Andric      : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
6720b57cec5SDimitry Andric  template <class _InputIterator>
673cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(
674cb14a3feSDimitry Andric      _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
6750b57cec5SDimitry Andric      : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
6760b57cec5SDimitry Andric#endif
67706c3fb27SDimitry Andric
67806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
67906c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
680cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
68106c3fb27SDimitry Andric      : unordered_set(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
68206c3fb27SDimitry Andric
68306c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
68406c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI
68506c3fb27SDimitry Andric  unordered_set(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
68606c3fb27SDimitry Andric      : unordered_set(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
68706c3fb27SDimitry Andric#endif
68806c3fb27SDimitry Andric
689cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit unordered_set(const allocator_type& __a);
69006c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u);
69106c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u, const allocator_type& __a);
6920b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
693cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
69406c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u, const allocator_type& __a);
69506c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il);
696cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
697cb14a3feSDimitry Andric  unordered_set(initializer_list<value_type> __il,
698cb14a3feSDimitry Andric                size_type __n,
6990b57cec5SDimitry Andric                const hasher& __hf     = hasher(),
7000b57cec5SDimitry Andric                const key_equal& __eql = key_equal());
701cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set(
702cb14a3feSDimitry Andric      initializer_list<value_type> __il,
703cb14a3feSDimitry Andric      size_type __n,
704cb14a3feSDimitry Andric      const hasher& __hf,
705cb14a3feSDimitry Andric      const key_equal& __eql,
7060b57cec5SDimitry Andric      const allocator_type& __a);
70706c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 14
7085f757f3fSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI
709cb14a3feSDimitry Andric  unordered_set(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
7100b57cec5SDimitry Andric      : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
7115f757f3fSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI
712cb14a3feSDimitry Andric  unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
7130b57cec5SDimitry Andric      : unordered_set(__il, __n, __hf, key_equal(), __a) {}
7140b57cec5SDimitry Andric#  endif
7150b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
716cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ~unordered_set() {
717bdd1243dSDimitry Andric    static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
7180b57cec5SDimitry Andric  }
7190b57cec5SDimitry Andric
720cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(const unordered_set& __u) {
7210b57cec5SDimitry Andric    __table_ = __u.__table_;
7220b57cec5SDimitry Andric    return *this;
7230b57cec5SDimitry Andric  }
7240b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
725cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(unordered_set&& __u)
7260b57cec5SDimitry Andric      _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
727cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(initializer_list<value_type> __il);
7280b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
7290b57cec5SDimitry Andric
730cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
731cb14a3feSDimitry Andric    return allocator_type(__table_.__node_alloc());
732cb14a3feSDimitry Andric  }
7330b57cec5SDimitry Andric
734*0fca6ea1SDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
735cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
736cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
7370b57cec5SDimitry Andric
738cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); }
739cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); }
740cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); }
741cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); }
742cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
743cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
7440b57cec5SDimitry Andric
7450b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7460b57cec5SDimitry Andric  template <class... _Args>
747cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
748cb14a3feSDimitry Andric    return __table_.__emplace_unique(std::forward<_Args>(__args)...);
749cb14a3feSDimitry Andric  }
7500b57cec5SDimitry Andric  template <class... _Args>
751cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator, _Args&&... __args) {
75281ad6265SDimitry Andric    return __table_.__emplace_unique(std::forward<_Args>(__args)...).first;
7530b57cec5SDimitry Andric  }
7540b57cec5SDimitry Andric
755cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) {
756cb14a3feSDimitry Andric    return __table_.__insert_unique(std::move(__x));
7570b57cec5SDimitry Andric  }
758cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { return insert(std::move(__x)).first; }
75981ad6265SDimitry Andric
760cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
7610b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
762cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); }
7630b57cec5SDimitry Andric
764cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }
7650b57cec5SDimitry Andric  template <class _InputIterator>
766cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
7670b57cec5SDimitry Andric
76806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
76906c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
770cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
77106c3fb27SDimitry Andric    for (auto&& __element : __range) {
77206c3fb27SDimitry Andric      __table_.__insert_unique(std::forward<decltype(__element)>(__element));
77306c3fb27SDimitry Andric    }
77406c3fb27SDimitry Andric  }
77506c3fb27SDimitry Andric#endif
77606c3fb27SDimitry Andric
777cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); }
778cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_unique(__k); }
779cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
780cb14a3feSDimitry Andric    return __table_.erase(__first, __last);
781cb14a3feSDimitry Andric  }
782cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
7830b57cec5SDimitry Andric
78406c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
785cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
78606c3fb27SDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
7870b57cec5SDimitry Andric                                        "node_type with incompatible allocator passed to unordered_set::insert()");
788cb14a3feSDimitry Andric    return __table_.template __node_handle_insert_unique< node_type, insert_return_type>(std::move(__nh));
7890b57cec5SDimitry Andric  }
790cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __h, node_type&& __nh) {
79106c3fb27SDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
7920b57cec5SDimitry Andric                                        "node_type with incompatible allocator passed to unordered_set::insert()");
793cb14a3feSDimitry Andric    return __table_.template __node_handle_insert_unique<node_type>(__h, std::move(__nh));
7940b57cec5SDimitry Andric  }
795cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
7960b57cec5SDimitry Andric    return __table_.template __node_handle_extract<node_type>(__key);
7970b57cec5SDimitry Andric  }
798cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {
7990b57cec5SDimitry Andric    return __table_.template __node_handle_extract<node_type>(__it);
8000b57cec5SDimitry Andric  }
8010b57cec5SDimitry Andric
8020b57cec5SDimitry Andric  template <class _H2, class _P2>
803cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source) {
804cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
805cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
8060b57cec5SDimitry Andric    __table_.__node_handle_merge_unique(__source.__table_);
8070b57cec5SDimitry Andric  }
8080b57cec5SDimitry Andric  template <class _H2, class _P2>
809cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source) {
810cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
811cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
8120b57cec5SDimitry Andric    __table_.__node_handle_merge_unique(__source.__table_);
8130b57cec5SDimitry Andric  }
8140b57cec5SDimitry Andric  template <class _H2, class _P2>
815cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source) {
816cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
817cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
8180b57cec5SDimitry Andric    __table_.__node_handle_merge_unique(__source.__table_);
8190b57cec5SDimitry Andric  }
8200b57cec5SDimitry Andric  template <class _H2, class _P2>
821cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source) {
822cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
823cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
8240b57cec5SDimitry Andric    __table_.__node_handle_merge_unique(__source.__table_);
8250b57cec5SDimitry Andric  }
8260b57cec5SDimitry Andric#endif
8270b57cec5SDimitry Andric
828*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(unordered_set& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
829cb14a3feSDimitry Andric    __table_.swap(__u.__table_);
830cb14a3feSDimitry Andric  }
8310b57cec5SDimitry Andric
832cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function(); }
833cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq(); }
8340b57cec5SDimitry Andric
835cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
836cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
83706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
838*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
839cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
840cb14a3feSDimitry Andric    return __table_.find(__k);
841cb14a3feSDimitry Andric  }
842*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
843cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
844cb14a3feSDimitry Andric    return __table_.find(__k);
845cb14a3feSDimitry Andric  }
84606c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
847349cc55cSDimitry Andric
848cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); }
84906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
850*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
851cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
852cb14a3feSDimitry Andric    return __table_.__count_unique(__k);
853cb14a3feSDimitry Andric  }
85406c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
855349cc55cSDimitry Andric
85606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
857cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
858e8d8bef9SDimitry Andric
859*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
860cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
861cb14a3feSDimitry Andric    return find(__k) != end();
862cb14a3feSDimitry Andric  }
86306c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
864349cc55cSDimitry Andric
865cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
866cb14a3feSDimitry Andric    return __table_.__equal_range_unique(__k);
867cb14a3feSDimitry Andric  }
868cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
869cb14a3feSDimitry Andric    return __table_.__equal_range_unique(__k);
870cb14a3feSDimitry Andric  }
87106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
872*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
873cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
874cb14a3feSDimitry Andric    return __table_.__equal_range_unique(__k);
875cb14a3feSDimitry Andric  }
876*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
877cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
878cb14a3feSDimitry Andric    return __table_.__equal_range_unique(__k);
879cb14a3feSDimitry Andric  }
88006c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
8810b57cec5SDimitry Andric
882cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }
883cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }
8840b57cec5SDimitry Andric
885cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); }
886cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); }
8870b57cec5SDimitry Andric
888cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); }
889cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); }
890cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); }
891cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); }
892cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); }
893cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); }
8940b57cec5SDimitry Andric
895cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); }
896cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); }
897cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); }
898cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_unique(__n); }
899cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); }
9000b57cec5SDimitry Andric};
9010b57cec5SDimitry Andric
902349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
9030b57cec5SDimitry Andrictemplate <class _InputIterator,
9040b57cec5SDimitry Andric          class _Hash      = hash<__iter_value_type<_InputIterator>>,
9050b57cec5SDimitry Andric          class _Pred      = equal_to<__iter_value_type<_InputIterator>>,
9060b57cec5SDimitry Andric          class _Allocator = allocator<__iter_value_type<_InputIterator>>,
90706c3fb27SDimitry Andric          class            = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
908349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
909349cc55cSDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
910349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
911349cc55cSDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
912cb14a3feSDimitry Andricunordered_set(_InputIterator,
913cb14a3feSDimitry Andric              _InputIterator,
914cb14a3feSDimitry Andric              typename allocator_traits<_Allocator>::size_type = 0,
915cb14a3feSDimitry Andric              _Hash                                            = _Hash(),
916cb14a3feSDimitry Andric              _Pred                                            = _Pred(),
917cb14a3feSDimitry Andric              _Allocator = _Allocator()) -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
9180b57cec5SDimitry Andric
91906c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
92006c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
92106c3fb27SDimitry Andric          class _Hash      = hash<ranges::range_value_t<_Range>>,
92206c3fb27SDimitry Andric          class _Pred      = equal_to<ranges::range_value_t<_Range>>,
92306c3fb27SDimitry Andric          class _Allocator = allocator<ranges::range_value_t<_Range>>,
92406c3fb27SDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
92506c3fb27SDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
92606c3fb27SDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
92706c3fb27SDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
928*0fca6ea1SDimitry Andricunordered_set(
929*0fca6ea1SDimitry Andric    from_range_t,
930cb14a3feSDimitry Andric    _Range&&,
931cb14a3feSDimitry Andric    typename allocator_traits<_Allocator>::size_type = 0,
932cb14a3feSDimitry Andric    _Hash                                            = _Hash(),
933cb14a3feSDimitry Andric    _Pred                                            = _Pred(),
934*0fca6ea1SDimitry Andric    _Allocator = _Allocator()) -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
93506c3fb27SDimitry Andric#  endif
93606c3fb27SDimitry Andric
937cb14a3feSDimitry Andrictemplate <class _Tp,
938cb14a3feSDimitry Andric          class _Hash      = hash<_Tp>,
9390b57cec5SDimitry Andric          class _Pred      = equal_to<_Tp>,
9400b57cec5SDimitry Andric          class _Allocator = allocator<_Tp>,
941349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
942349cc55cSDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
943349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
944349cc55cSDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
945cb14a3feSDimitry Andricunordered_set(initializer_list<_Tp>,
946cb14a3feSDimitry Andric              typename allocator_traits<_Allocator>::size_type = 0,
947cb14a3feSDimitry Andric              _Hash                                            = _Hash(),
948cb14a3feSDimitry Andric              _Pred                                            = _Pred(),
949cb14a3feSDimitry Andric              _Allocator = _Allocator()) -> unordered_set<_Tp, _Hash, _Pred, _Allocator>;
9500b57cec5SDimitry Andric
951cb14a3feSDimitry Andrictemplate <class _InputIterator,
952cb14a3feSDimitry Andric          class _Allocator,
95306c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
954349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
955cb14a3feSDimitry Andricunordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
9560b57cec5SDimitry Andric    -> unordered_set<__iter_value_type<_InputIterator>,
9570b57cec5SDimitry Andric                     hash<__iter_value_type<_InputIterator>>,
9580b57cec5SDimitry Andric                     equal_to<__iter_value_type<_InputIterator>>,
9590b57cec5SDimitry Andric                     _Allocator>;
9600b57cec5SDimitry Andric
961cb14a3feSDimitry Andrictemplate <class _InputIterator,
962cb14a3feSDimitry Andric          class _Hash,
963cb14a3feSDimitry Andric          class _Allocator,
96406c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
965349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
966349cc55cSDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
967349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
968cb14a3feSDimitry Andricunordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
969cb14a3feSDimitry Andric    -> unordered_set<__iter_value_type<_InputIterator>, _Hash, equal_to<__iter_value_type<_InputIterator>>, _Allocator>;
9700b57cec5SDimitry Andric
97106c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
97206c3fb27SDimitry Andric
973cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
97406c3fb27SDimitry Andricunordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
975cb14a3feSDimitry Andric    -> unordered_set<ranges::range_value_t<_Range>,
976cb14a3feSDimitry Andric                     hash<ranges::range_value_t<_Range>>,
977cb14a3feSDimitry Andric                     equal_to<ranges::range_value_t<_Range>>,
978cb14a3feSDimitry Andric                     _Allocator>;
97906c3fb27SDimitry Andric
980cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
98106c3fb27SDimitry Andricunordered_set(from_range_t, _Range&&, _Allocator)
982cb14a3feSDimitry Andric    -> unordered_set<ranges::range_value_t<_Range>,
983cb14a3feSDimitry Andric                     hash<ranges::range_value_t<_Range>>,
984cb14a3feSDimitry Andric                     equal_to<ranges::range_value_t<_Range>>,
985cb14a3feSDimitry Andric                     _Allocator>;
98606c3fb27SDimitry Andric
987cb14a3feSDimitry Andrictemplate <ranges::input_range _Range,
988cb14a3feSDimitry Andric          class _Hash,
989cb14a3feSDimitry Andric          class _Allocator,
99006c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
99106c3fb27SDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
99206c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
99306c3fb27SDimitry Andricunordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
99406c3fb27SDimitry Andric    -> unordered_set<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>;
99506c3fb27SDimitry Andric
99606c3fb27SDimitry Andric#  endif
99706c3fb27SDimitry Andric
998cb14a3feSDimitry Andrictemplate <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
9990b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
10000b57cec5SDimitry Andric    -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
10010b57cec5SDimitry Andric
1002cb14a3feSDimitry Andrictemplate <class _Tp,
1003cb14a3feSDimitry Andric          class _Hash,
1004cb14a3feSDimitry Andric          class _Allocator,
1005349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
1006349cc55cSDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
1007349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
10080b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
10090b57cec5SDimitry Andric    -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
10100b57cec5SDimitry Andric#endif
10110b57cec5SDimitry Andric
10120b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1013cb14a3feSDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql)
1014cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
1015753f127fSDimitry Andric  __table_.__rehash_unique(__n);
10160b57cec5SDimitry Andric}
10170b57cec5SDimitry Andric
10180b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1019cb14a3feSDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1020cb14a3feSDimitry Andric    size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1021cb14a3feSDimitry Andric    : __table_(__hf, __eql, __a) {
1022753f127fSDimitry Andric  __table_.__rehash_unique(__n);
10230b57cec5SDimitry Andric}
10240b57cec5SDimitry Andric
10250b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
10260b57cec5SDimitry Andrictemplate <class _InputIterator>
1027cb14a3feSDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(_InputIterator __first, _InputIterator __last) {
10280b57cec5SDimitry Andric  insert(__first, __last);
10290b57cec5SDimitry Andric}
10300b57cec5SDimitry Andric
10310b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
10320b57cec5SDimitry Andrictemplate <class _InputIterator>
10330b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1034cb14a3feSDimitry Andric    _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql)
1035cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
1036753f127fSDimitry Andric  __table_.__rehash_unique(__n);
10370b57cec5SDimitry Andric  insert(__first, __last);
10380b57cec5SDimitry Andric}
10390b57cec5SDimitry Andric
10400b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
10410b57cec5SDimitry Andrictemplate <class _InputIterator>
10420b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1043cb14a3feSDimitry Andric    _InputIterator __first,
1044cb14a3feSDimitry Andric    _InputIterator __last,
1045cb14a3feSDimitry Andric    size_type __n,
1046cb14a3feSDimitry Andric    const hasher& __hf,
1047cb14a3feSDimitry Andric    const key_equal& __eql,
10480b57cec5SDimitry Andric    const allocator_type& __a)
1049cb14a3feSDimitry Andric    : __table_(__hf, __eql, __a) {
1050cb14a3feSDimitry Andric  __table_.__rehash_unique(__n);
1051cb14a3feSDimitry Andric  insert(__first, __last);
10520b57cec5SDimitry Andric}
10530b57cec5SDimitry Andric
10540b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1055cb14a3feSDimitry Andricinline unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const allocator_type& __a) : __table_(__a) {}
1056cb14a3feSDimitry Andric
1057cb14a3feSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1058cb14a3feSDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set& __u) : __table_(__u.__table_) {
1059753f127fSDimitry Andric  __table_.__rehash_unique(__u.bucket_count());
10600b57cec5SDimitry Andric  insert(__u.begin(), __u.end());
10610b57cec5SDimitry Andric}
10620b57cec5SDimitry Andric
10630b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1064cb14a3feSDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set& __u, const allocator_type& __a)
1065cb14a3feSDimitry Andric    : __table_(__u.__table_, __a) {
1066753f127fSDimitry Andric  __table_.__rehash_unique(__u.bucket_count());
10670b57cec5SDimitry Andric  insert(__u.begin(), __u.end());
10680b57cec5SDimitry Andric}
10690b57cec5SDimitry Andric
10700b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
10710b57cec5SDimitry Andric
10720b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1073cb14a3feSDimitry Andricinline unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u)
10740b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1075cb14a3feSDimitry Andric    : __table_(std::move(__u.__table_)) {}
10760b57cec5SDimitry Andric
10770b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1078cb14a3feSDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u, const allocator_type& __a)
1079cb14a3feSDimitry Andric    : __table_(std::move(__u.__table_), __a) {
1080cb14a3feSDimitry Andric  if (__a != __u.get_allocator()) {
10810b57cec5SDimitry Andric    iterator __i = __u.begin();
10820b57cec5SDimitry Andric    while (__u.size() != 0)
10835f757f3fSDimitry Andric      __table_.__insert_unique(std::move(__u.__table_.remove(__i++)->__get_value()));
10840b57cec5SDimitry Andric  }
10850b57cec5SDimitry Andric}
10860b57cec5SDimitry Andric
10870b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1088cb14a3feSDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(initializer_list<value_type> __il) {
10890b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
10900b57cec5SDimitry Andric}
10910b57cec5SDimitry Andric
10920b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
10930b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1094cb14a3feSDimitry Andric    initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql)
1095cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
1096753f127fSDimitry Andric  __table_.__rehash_unique(__n);
10970b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
10980b57cec5SDimitry Andric}
10990b57cec5SDimitry Andric
11000b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
11010b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
1102cb14a3feSDimitry Andric    initializer_list<value_type> __il,
1103cb14a3feSDimitry Andric    size_type __n,
1104cb14a3feSDimitry Andric    const hasher& __hf,
1105cb14a3feSDimitry Andric    const key_equal& __eql,
1106cb14a3feSDimitry Andric    const allocator_type& __a)
1107cb14a3feSDimitry Andric    : __table_(__hf, __eql, __a) {
1108753f127fSDimitry Andric  __table_.__rehash_unique(__n);
11090b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
11100b57cec5SDimitry Andric}
11110b57cec5SDimitry Andric
11120b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1113cb14a3feSDimitry Andricinline unordered_set<_Value, _Hash, _Pred, _Alloc>&
11140b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
1115cb14a3feSDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) {
11165f757f3fSDimitry Andric  __table_ = std::move(__u.__table_);
11170b57cec5SDimitry Andric  return *this;
11180b57cec5SDimitry Andric}
11190b57cec5SDimitry Andric
11200b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1121cb14a3feSDimitry Andricinline unordered_set<_Value, _Hash, _Pred, _Alloc>&
1122cb14a3feSDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) {
11230b57cec5SDimitry Andric  __table_.__assign_unique(__il.begin(), __il.end());
11240b57cec5SDimitry Andric  return *this;
11250b57cec5SDimitry Andric}
11260b57cec5SDimitry Andric
11270b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
11280b57cec5SDimitry Andric
11290b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
11300b57cec5SDimitry Andrictemplate <class _InputIterator>
1131cb14a3feSDimitry Andricinline void unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
11320b57cec5SDimitry Andric  for (; __first != __last; ++__first)
11330b57cec5SDimitry Andric    __table_.__insert_unique(*__first);
11340b57cec5SDimitry Andric}
11350b57cec5SDimitry Andric
11360b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1137cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
1138cb14a3feSDimitry Andricswap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1139cb14a3feSDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
11400b57cec5SDimitry Andric  __x.swap(__y);
11410b57cec5SDimitry Andric}
11420b57cec5SDimitry Andric
114306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1144cb14a3feSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
1145cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type
1146cb14a3feSDimitry Andricerase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
11475f757f3fSDimitry Andric  return std::__libcpp_erase_if_container(__c, __pred);
11485ffd83dbSDimitry Andric}
11490b57cec5SDimitry Andric#endif
11500b57cec5SDimitry Andric
11510b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1152cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1153cb14a3feSDimitry Andric                                      const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) {
11540b57cec5SDimitry Andric  if (__x.size() != __y.size())
11550b57cec5SDimitry Andric    return false;
1156cb14a3feSDimitry Andric  typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator const_iterator;
1157cb14a3feSDimitry Andric  for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); __i != __ex; ++__i) {
11580b57cec5SDimitry Andric    const_iterator __j = __y.find(*__i);
11590b57cec5SDimitry Andric    if (__j == __ey || !(*__i == *__j))
11600b57cec5SDimitry Andric      return false;
11610b57cec5SDimitry Andric  }
11620b57cec5SDimitry Andric  return true;
11630b57cec5SDimitry Andric}
11640b57cec5SDimitry Andric
116506c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
116606c3fb27SDimitry Andric
11670b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1168cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1169cb14a3feSDimitry Andric                                             const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) {
11700b57cec5SDimitry Andric  return !(__x == __y);
11710b57cec5SDimitry Andric}
11720b57cec5SDimitry Andric
117306c3fb27SDimitry Andric#endif
117406c3fb27SDimitry Andric
1175cb14a3feSDimitry Andrictemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >
1176cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multiset {
11770b57cec5SDimitry Andricpublic:
11780b57cec5SDimitry Andric  // types
11790b57cec5SDimitry Andric  typedef _Value key_type;
11800b57cec5SDimitry Andric  typedef key_type value_type;
118181ad6265SDimitry Andric  typedef __type_identity_t<_Hash> hasher;
118281ad6265SDimitry Andric  typedef __type_identity_t<_Pred> key_equal;
118381ad6265SDimitry Andric  typedef __type_identity_t<_Alloc> allocator_type;
11840b57cec5SDimitry Andric  typedef value_type& reference;
11850b57cec5SDimitry Andric  typedef const value_type& const_reference;
1186*0fca6ea1SDimitry Andric  static_assert(is_same<value_type, typename allocator_type::value_type>::value,
118706c3fb27SDimitry Andric                "Allocator::value_type must be same type as value_type");
11880b57cec5SDimitry Andric
11890b57cec5SDimitry Andricprivate:
11900b57cec5SDimitry Andric  typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
11910b57cec5SDimitry Andric
11920b57cec5SDimitry Andric  __table __table_;
11930b57cec5SDimitry Andric
11940b57cec5SDimitry Andricpublic:
11950b57cec5SDimitry Andric  typedef typename __table::pointer pointer;
11960b57cec5SDimitry Andric  typedef typename __table::const_pointer const_pointer;
11970b57cec5SDimitry Andric  typedef typename __table::size_type size_type;
11980b57cec5SDimitry Andric  typedef typename __table::difference_type difference_type;
11990b57cec5SDimitry Andric
12000b57cec5SDimitry Andric  typedef typename __table::const_iterator iterator;
12010b57cec5SDimitry Andric  typedef typename __table::const_iterator const_iterator;
12020b57cec5SDimitry Andric  typedef typename __table::const_local_iterator local_iterator;
12030b57cec5SDimitry Andric  typedef typename __table::const_local_iterator const_local_iterator;
12040b57cec5SDimitry Andric
120506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
12060b57cec5SDimitry Andric  typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
12070b57cec5SDimitry Andric#endif
12080b57cec5SDimitry Andric
12090b57cec5SDimitry Andric  template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
12100b57cec5SDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_set;
12110b57cec5SDimitry Andric  template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
12120b57cec5SDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
12130b57cec5SDimitry Andric
1214cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
1215cb14a3feSDimitry Andric  explicit _LIBCPP_HIDE_FROM_ABI
1216cb14a3feSDimitry Andric  unordered_multiset(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
12175f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
1218cb14a3feSDimitry Andric  unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
121906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14
1220cb14a3feSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const allocator_type& __a)
12210b57cec5SDimitry Andric      : unordered_multiset(__n, hasher(), key_equal(), __a) {}
1222cb14a3feSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
12230b57cec5SDimitry Andric      : unordered_multiset(__n, __hf, key_equal(), __a) {}
12240b57cec5SDimitry Andric#endif
12250b57cec5SDimitry Andric  template <class _InputIterator>
122606c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last);
12270b57cec5SDimitry Andric  template <class _InputIterator>
1228cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1229cb14a3feSDimitry Andric      _InputIterator __first,
1230cb14a3feSDimitry Andric      _InputIterator __last,
1231cb14a3feSDimitry Andric      size_type __n,
1232cb14a3feSDimitry Andric      const hasher& __hf     = hasher(),
12330b57cec5SDimitry Andric      const key_equal& __eql = key_equal());
12340b57cec5SDimitry Andric  template <class _InputIterator>
1235cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1236cb14a3feSDimitry Andric      _InputIterator __first,
1237cb14a3feSDimitry Andric      _InputIterator __last,
1238cb14a3feSDimitry Andric      size_type __n,
1239cb14a3feSDimitry Andric      const hasher& __hf,
1240cb14a3feSDimitry Andric      const key_equal& __eql,
1241cb14a3feSDimitry Andric      const allocator_type& __a);
124206c3fb27SDimitry Andric
124306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
124406c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
1245cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1246cb14a3feSDimitry Andric      from_range_t,
1247cb14a3feSDimitry Andric      _Range&& __range,
1248cb14a3feSDimitry Andric      size_type __n             = /*implementation-defined*/ 0,
1249cb14a3feSDimitry Andric      const hasher& __hf        = hasher(),
1250cb14a3feSDimitry Andric      const key_equal& __eql    = key_equal(),
125106c3fb27SDimitry Andric      const allocator_type& __a = allocator_type())
125206c3fb27SDimitry Andric      : __table_(__hf, __eql, __a) {
125306c3fb27SDimitry Andric    if (__n > 0) {
125406c3fb27SDimitry Andric      __table_.__rehash_multi(__n);
125506c3fb27SDimitry Andric    }
125606c3fb27SDimitry Andric    insert_range(std::forward<_Range>(__range));
125706c3fb27SDimitry Andric  }
125806c3fb27SDimitry Andric#endif
125906c3fb27SDimitry Andric
126006c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14
12610b57cec5SDimitry Andric  template <class _InputIterator>
12625f757f3fSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI
1263cb14a3feSDimitry Andric  unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
12640b57cec5SDimitry Andric      : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
12650b57cec5SDimitry Andric  template <class _InputIterator>
1266cb14a3feSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1267cb14a3feSDimitry Andric      _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
12680b57cec5SDimitry Andric      : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
12690b57cec5SDimitry Andric#endif
127006c3fb27SDimitry Andric
127106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
127206c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
1273cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
127406c3fb27SDimitry Andric      : unordered_multiset(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
127506c3fb27SDimitry Andric
127606c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
127706c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI
127806c3fb27SDimitry Andric  unordered_multiset(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
127906c3fb27SDimitry Andric      : unordered_multiset(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
128006c3fb27SDimitry Andric#endif
128106c3fb27SDimitry Andric
1282cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit unordered_multiset(const allocator_type& __a);
128306c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u);
128406c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
12850b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1286cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u)
12870b57cec5SDimitry Andric      _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
128806c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
128906c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(initializer_list<value_type> __il);
1290cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1291cb14a3feSDimitry Andric      initializer_list<value_type> __il,
1292cb14a3feSDimitry Andric      size_type __n,
12930b57cec5SDimitry Andric      const hasher& __hf     = hasher(),
12940b57cec5SDimitry Andric      const key_equal& __eql = key_equal());
1295cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1296cb14a3feSDimitry Andric      initializer_list<value_type> __il,
1297cb14a3feSDimitry Andric      size_type __n,
1298cb14a3feSDimitry Andric      const hasher& __hf,
1299cb14a3feSDimitry Andric      const key_equal& __eql,
13000b57cec5SDimitry Andric      const allocator_type& __a);
130106c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 14
13025f757f3fSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI
13030b57cec5SDimitry Andric  unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
13040b57cec5SDimitry Andric      : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
13055f757f3fSDimitry Andric  inline _LIBCPP_HIDE_FROM_ABI
13060b57cec5SDimitry Andric  unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
13070b57cec5SDimitry Andric      : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
13080b57cec5SDimitry Andric#  endif
13090b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
1310cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ~unordered_multiset() {
1311bdd1243dSDimitry Andric    static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
13120b57cec5SDimitry Andric  }
13130b57cec5SDimitry Andric
1314cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(const unordered_multiset& __u) {
13150b57cec5SDimitry Andric    __table_ = __u.__table_;
13160b57cec5SDimitry Andric    return *this;
13170b57cec5SDimitry Andric  }
13180b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1319cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(unordered_multiset&& __u)
13200b57cec5SDimitry Andric      _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
132106c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(initializer_list<value_type> __il);
13220b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
13230b57cec5SDimitry Andric
1324cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
1325cb14a3feSDimitry Andric    return allocator_type(__table_.__node_alloc());
1326cb14a3feSDimitry Andric  }
13270b57cec5SDimitry Andric
1328*0fca6ea1SDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
1329cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
1330cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
13310b57cec5SDimitry Andric
1332cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); }
1333cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); }
1334cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); }
1335cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); }
1336cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
1337cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
13380b57cec5SDimitry Andric
13390b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
13400b57cec5SDimitry Andric  template <class... _Args>
1341cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
1342cb14a3feSDimitry Andric    return __table_.__emplace_multi(std::forward<_Args>(__args)...);
1343cb14a3feSDimitry Andric  }
13440b57cec5SDimitry Andric  template <class... _Args>
1345cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1346cb14a3feSDimitry Andric    return __table_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...);
1347cb14a3feSDimitry Andric  }
13480b57cec5SDimitry Andric
1349cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__insert_multi(std::move(__x)); }
1350cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) {
1351cb14a3feSDimitry Andric    return __table_.__insert_multi(__p, std::move(__x));
1352cb14a3feSDimitry Andric  }
1353cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
13540b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
13550b57cec5SDimitry Andric
1356cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); }
13570b57cec5SDimitry Andric
1358cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) {
1359cb14a3feSDimitry Andric    return __table_.__insert_multi(__p, __x);
1360cb14a3feSDimitry Andric  }
13610b57cec5SDimitry Andric
13620b57cec5SDimitry Andric  template <class _InputIterator>
1363cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
13640b57cec5SDimitry Andric
136506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
136606c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
1367cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
136806c3fb27SDimitry Andric    for (auto&& __element : __range) {
136906c3fb27SDimitry Andric      __table_.__insert_multi(std::forward<decltype(__element)>(__element));
137006c3fb27SDimitry Andric    }
137106c3fb27SDimitry Andric  }
137206c3fb27SDimitry Andric#endif
137306c3fb27SDimitry Andric
137406c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
1375cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {
137606c3fb27SDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
13770b57cec5SDimitry Andric                                        "node_type with incompatible allocator passed to unordered_multiset::insert()");
1378cb14a3feSDimitry Andric    return __table_.template __node_handle_insert_multi<node_type>(std::move(__nh));
13790b57cec5SDimitry Andric  }
1380cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {
138106c3fb27SDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
13820b57cec5SDimitry Andric                                        "node_type with incompatible allocator passed to unordered_multiset::insert()");
1383cb14a3feSDimitry Andric    return __table_.template __node_handle_insert_multi<node_type>(__hint, std::move(__nh));
13840b57cec5SDimitry Andric  }
1385cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __position) {
1386cb14a3feSDimitry Andric    return __table_.template __node_handle_extract<node_type>(__position);
13870b57cec5SDimitry Andric  }
1388cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
13890b57cec5SDimitry Andric    return __table_.template __node_handle_extract<node_type>(__key);
13900b57cec5SDimitry Andric  }
13910b57cec5SDimitry Andric
13920b57cec5SDimitry Andric  template <class _H2, class _P2>
1393cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source) {
1394cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1395cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
13960b57cec5SDimitry Andric    return __table_.__node_handle_merge_multi(__source.__table_);
13970b57cec5SDimitry Andric  }
13980b57cec5SDimitry Andric  template <class _H2, class _P2>
1399cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source) {
1400cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1401cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
14020b57cec5SDimitry Andric    return __table_.__node_handle_merge_multi(__source.__table_);
14030b57cec5SDimitry Andric  }
14040b57cec5SDimitry Andric  template <class _H2, class _P2>
1405cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source) {
1406cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1407cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
14080b57cec5SDimitry Andric    return __table_.__node_handle_merge_multi(__source.__table_);
14090b57cec5SDimitry Andric  }
14100b57cec5SDimitry Andric  template <class _H2, class _P2>
1411cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source) {
1412cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1413cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
14140b57cec5SDimitry Andric    return __table_.__node_handle_merge_multi(__source.__table_);
14150b57cec5SDimitry Andric  }
14160b57cec5SDimitry Andric#endif
14170b57cec5SDimitry Andric
1418cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); }
1419cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_multi(__k); }
1420cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
1421cb14a3feSDimitry Andric    return __table_.erase(__first, __last);
1422cb14a3feSDimitry Andric  }
1423cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
14240b57cec5SDimitry Andric
1425*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(unordered_multiset& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
1426cb14a3feSDimitry Andric    __table_.swap(__u.__table_);
1427cb14a3feSDimitry Andric  }
14280b57cec5SDimitry Andric
1429cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function(); }
1430cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq(); }
14310b57cec5SDimitry Andric
1432cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
1433cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
143406c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1435*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1436cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1437cb14a3feSDimitry Andric    return __table_.find(__k);
1438cb14a3feSDimitry Andric  }
1439*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1440cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1441cb14a3feSDimitry Andric    return __table_.find(__k);
1442cb14a3feSDimitry Andric  }
144306c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1444349cc55cSDimitry Andric
1445cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); }
144606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1447*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1448cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1449cb14a3feSDimitry Andric    return __table_.__count_multi(__k);
1450cb14a3feSDimitry Andric  }
145106c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1452349cc55cSDimitry Andric
145306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1454cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1455e8d8bef9SDimitry Andric
1456*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1457cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1458cb14a3feSDimitry Andric    return find(__k) != end();
1459cb14a3feSDimitry Andric  }
146006c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1461349cc55cSDimitry Andric
1462cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
1463cb14a3feSDimitry Andric    return __table_.__equal_range_multi(__k);
1464cb14a3feSDimitry Andric  }
1465cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
1466cb14a3feSDimitry Andric    return __table_.__equal_range_multi(__k);
1467cb14a3feSDimitry Andric  }
146806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1469*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1470cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
1471cb14a3feSDimitry Andric    return __table_.__equal_range_multi(__k);
1472cb14a3feSDimitry Andric  }
1473*0fca6ea1SDimitry Andric  template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1474cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
1475cb14a3feSDimitry Andric    return __table_.__equal_range_multi(__k);
1476cb14a3feSDimitry Andric  }
147706c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
14780b57cec5SDimitry Andric
1479cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }
1480cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }
14810b57cec5SDimitry Andric
1482cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); }
1483cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); }
14840b57cec5SDimitry Andric
1485cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); }
1486cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); }
1487cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); }
1488cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); }
1489cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); }
1490cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); }
14910b57cec5SDimitry Andric
1492cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); }
1493cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); }
1494cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); }
1495cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_multi(__n); }
1496cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); }
14970b57cec5SDimitry Andric};
14980b57cec5SDimitry Andric
1499349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
15000b57cec5SDimitry Andrictemplate <class _InputIterator,
15010b57cec5SDimitry Andric          class _Hash      = hash<__iter_value_type<_InputIterator>>,
15020b57cec5SDimitry Andric          class _Pred      = equal_to<__iter_value_type<_InputIterator>>,
15030b57cec5SDimitry Andric          class _Allocator = allocator<__iter_value_type<_InputIterator>>,
150406c3fb27SDimitry Andric          class            = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1505349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
1506349cc55cSDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
1507349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
1508349cc55cSDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
1509cb14a3feSDimitry Andricunordered_multiset(
1510cb14a3feSDimitry Andric    _InputIterator,
1511cb14a3feSDimitry Andric    _InputIterator,
1512cb14a3feSDimitry Andric    typename allocator_traits<_Allocator>::size_type = 0,
1513cb14a3feSDimitry Andric    _Hash                                            = _Hash(),
1514cb14a3feSDimitry Andric    _Pred                                            = _Pred(),
1515cb14a3feSDimitry Andric    _Allocator = _Allocator()) -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
15160b57cec5SDimitry Andric
151706c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
151806c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
151906c3fb27SDimitry Andric          class _Hash      = hash<ranges::range_value_t<_Range>>,
152006c3fb27SDimitry Andric          class _Pred      = equal_to<ranges::range_value_t<_Range>>,
152106c3fb27SDimitry Andric          class _Allocator = allocator<ranges::range_value_t<_Range>>,
152206c3fb27SDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
152306c3fb27SDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
152406c3fb27SDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
152506c3fb27SDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
1526cb14a3feSDimitry Andricunordered_multiset(
1527cb14a3feSDimitry Andric    from_range_t,
1528cb14a3feSDimitry Andric    _Range&&,
1529cb14a3feSDimitry Andric    typename allocator_traits<_Allocator>::size_type = 0,
1530cb14a3feSDimitry Andric    _Hash                                            = _Hash(),
1531cb14a3feSDimitry Andric    _Pred                                            = _Pred(),
1532cb14a3feSDimitry Andric    _Allocator = _Allocator()) -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
153306c3fb27SDimitry Andric#  endif
153406c3fb27SDimitry Andric
1535cb14a3feSDimitry Andrictemplate <class _Tp,
1536cb14a3feSDimitry Andric          class _Hash      = hash<_Tp>,
1537cb14a3feSDimitry Andric          class _Pred      = equal_to<_Tp>,
1538cb14a3feSDimitry Andric          class _Allocator = allocator<_Tp>,
1539349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
1540349cc55cSDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
1541349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
1542349cc55cSDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
1543cb14a3feSDimitry Andricunordered_multiset(initializer_list<_Tp>,
1544cb14a3feSDimitry Andric                   typename allocator_traits<_Allocator>::size_type = 0,
1545cb14a3feSDimitry Andric                   _Hash                                            = _Hash(),
1546cb14a3feSDimitry Andric                   _Pred                                            = _Pred(),
1547cb14a3feSDimitry Andric                   _Allocator = _Allocator()) -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>;
15480b57cec5SDimitry Andric
1549cb14a3feSDimitry Andrictemplate <class _InputIterator,
1550cb14a3feSDimitry Andric          class _Allocator,
155106c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1552349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
15530b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
15540b57cec5SDimitry Andric    -> unordered_multiset<__iter_value_type<_InputIterator>,
15550b57cec5SDimitry Andric                          hash<__iter_value_type<_InputIterator>>,
15560b57cec5SDimitry Andric                          equal_to<__iter_value_type<_InputIterator>>,
15570b57cec5SDimitry Andric                          _Allocator>;
15580b57cec5SDimitry Andric
1559cb14a3feSDimitry Andrictemplate <class _InputIterator,
1560cb14a3feSDimitry Andric          class _Hash,
1561cb14a3feSDimitry Andric          class _Allocator,
156206c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1563349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
1564349cc55cSDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
1565349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
1566cb14a3feSDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1567cb14a3feSDimitry Andric    -> unordered_multiset<__iter_value_type<_InputIterator>,
1568cb14a3feSDimitry Andric                          _Hash,
15690b57cec5SDimitry Andric                          equal_to<__iter_value_type<_InputIterator>>,
15700b57cec5SDimitry Andric                          _Allocator>;
15710b57cec5SDimitry Andric
157206c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
157306c3fb27SDimitry Andric
1574cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
157506c3fb27SDimitry Andricunordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
1576cb14a3feSDimitry Andric    -> unordered_multiset<ranges::range_value_t<_Range>,
1577cb14a3feSDimitry Andric                          hash<ranges::range_value_t<_Range>>,
1578cb14a3feSDimitry Andric                          equal_to<ranges::range_value_t<_Range>>,
1579cb14a3feSDimitry Andric                          _Allocator>;
158006c3fb27SDimitry Andric
1581cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
158206c3fb27SDimitry Andricunordered_multiset(from_range_t, _Range&&, _Allocator)
1583cb14a3feSDimitry Andric    -> unordered_multiset<ranges::range_value_t<_Range>,
1584cb14a3feSDimitry Andric                          hash<ranges::range_value_t<_Range>>,
1585cb14a3feSDimitry Andric                          equal_to<ranges::range_value_t<_Range>>,
1586cb14a3feSDimitry Andric                          _Allocator>;
158706c3fb27SDimitry Andric
1588cb14a3feSDimitry Andrictemplate <ranges::input_range _Range,
1589cb14a3feSDimitry Andric          class _Hash,
1590cb14a3feSDimitry Andric          class _Allocator,
159106c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
159206c3fb27SDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
159306c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
159406c3fb27SDimitry Andricunordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
159506c3fb27SDimitry Andric    -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>;
159606c3fb27SDimitry Andric
159706c3fb27SDimitry Andric#  endif
159806c3fb27SDimitry Andric
1599cb14a3feSDimitry Andrictemplate <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
16000b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
16010b57cec5SDimitry Andric    -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
16020b57cec5SDimitry Andric
1603cb14a3feSDimitry Andrictemplate <class _Tp,
1604cb14a3feSDimitry Andric          class _Hash,
1605cb14a3feSDimitry Andric          class _Allocator,
1606349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
1607349cc55cSDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
1608349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
16090b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
16100b57cec5SDimitry Andric    -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
16110b57cec5SDimitry Andric#endif
16120b57cec5SDimitry Andric
16130b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16140b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
16150b57cec5SDimitry Andric    size_type __n, const hasher& __hf, const key_equal& __eql)
1616cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
1617753f127fSDimitry Andric  __table_.__rehash_multi(__n);
16180b57cec5SDimitry Andric}
16190b57cec5SDimitry Andric
16200b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16210b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1622cb14a3feSDimitry Andric    size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1623cb14a3feSDimitry Andric    : __table_(__hf, __eql, __a) {
1624cb14a3feSDimitry Andric  __table_.__rehash_multi(__n);
1625cb14a3feSDimitry Andric}
1626cb14a3feSDimitry Andric
1627cb14a3feSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1628cb14a3feSDimitry Andrictemplate <class _InputIterator>
1629cb14a3feSDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(_InputIterator __first, _InputIterator __last) {
1630cb14a3feSDimitry Andric  insert(__first, __last);
1631cb14a3feSDimitry Andric}
1632cb14a3feSDimitry Andric
1633cb14a3feSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1634cb14a3feSDimitry Andrictemplate <class _InputIterator>
1635cb14a3feSDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1636cb14a3feSDimitry Andric    _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql)
1637cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
1638cb14a3feSDimitry Andric  __table_.__rehash_multi(__n);
1639cb14a3feSDimitry Andric  insert(__first, __last);
1640cb14a3feSDimitry Andric}
1641cb14a3feSDimitry Andric
1642cb14a3feSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1643cb14a3feSDimitry Andrictemplate <class _InputIterator>
1644cb14a3feSDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1645cb14a3feSDimitry Andric    _InputIterator __first,
1646cb14a3feSDimitry Andric    _InputIterator __last,
1647cb14a3feSDimitry Andric    size_type __n,
1648cb14a3feSDimitry Andric    const hasher& __hf,
1649cb14a3feSDimitry Andric    const key_equal& __eql,
16500b57cec5SDimitry Andric    const allocator_type& __a)
1651cb14a3feSDimitry Andric    : __table_(__hf, __eql, __a) {
1652753f127fSDimitry Andric  __table_.__rehash_multi(__n);
16530b57cec5SDimitry Andric  insert(__first, __last);
16540b57cec5SDimitry Andric}
16550b57cec5SDimitry Andric
16560b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1657cb14a3feSDimitry Andricinline unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(const allocator_type& __a)
1658cb14a3feSDimitry Andric    : __table_(__a) {}
16590b57cec5SDimitry Andric
16600b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1661cb14a3feSDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(const unordered_multiset& __u)
1662cb14a3feSDimitry Andric    : __table_(__u.__table_) {
1663753f127fSDimitry Andric  __table_.__rehash_multi(__u.bucket_count());
16640b57cec5SDimitry Andric  insert(__u.begin(), __u.end());
16650b57cec5SDimitry Andric}
16660b57cec5SDimitry Andric
16670b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16680b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
16690b57cec5SDimitry Andric    const unordered_multiset& __u, const allocator_type& __a)
1670cb14a3feSDimitry Andric    : __table_(__u.__table_, __a) {
1671753f127fSDimitry Andric  __table_.__rehash_multi(__u.bucket_count());
16720b57cec5SDimitry Andric  insert(__u.begin(), __u.end());
16730b57cec5SDimitry Andric}
16740b57cec5SDimitry Andric
16750b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
16760b57cec5SDimitry Andric
16770b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1678cb14a3feSDimitry Andricinline unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(unordered_multiset&& __u)
16790b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1680cb14a3feSDimitry Andric    : __table_(std::move(__u.__table_)) {}
16810b57cec5SDimitry Andric
16820b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16830b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
16840b57cec5SDimitry Andric    unordered_multiset&& __u, const allocator_type& __a)
1685cb14a3feSDimitry Andric    : __table_(std::move(__u.__table_), __a) {
1686cb14a3feSDimitry Andric  if (__a != __u.get_allocator()) {
16870b57cec5SDimitry Andric    iterator __i = __u.begin();
16880b57cec5SDimitry Andric    while (__u.size() != 0)
16895f757f3fSDimitry Andric      __table_.__insert_multi(std::move(__u.__table_.remove(__i++)->__get_value()));
16900b57cec5SDimitry Andric  }
16910b57cec5SDimitry Andric}
16920b57cec5SDimitry Andric
16930b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1694cb14a3feSDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(initializer_list<value_type> __il) {
16950b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
16960b57cec5SDimitry Andric}
16970b57cec5SDimitry Andric
16980b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16990b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1700cb14a3feSDimitry Andric    initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql)
1701cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
1702753f127fSDimitry Andric  __table_.__rehash_multi(__n);
17030b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
17040b57cec5SDimitry Andric}
17050b57cec5SDimitry Andric
17060b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
17070b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1708cb14a3feSDimitry Andric    initializer_list<value_type> __il,
1709cb14a3feSDimitry Andric    size_type __n,
1710cb14a3feSDimitry Andric    const hasher& __hf,
1711cb14a3feSDimitry Andric    const key_equal& __eql,
1712cb14a3feSDimitry Andric    const allocator_type& __a)
1713cb14a3feSDimitry Andric    : __table_(__hf, __eql, __a) {
1714753f127fSDimitry Andric  __table_.__rehash_multi(__n);
17150b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
17160b57cec5SDimitry Andric}
17170b57cec5SDimitry Andric
17180b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1719cb14a3feSDimitry Andricinline unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1720cb14a3feSDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_multiset&& __u)
1721cb14a3feSDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) {
17225f757f3fSDimitry Andric  __table_ = std::move(__u.__table_);
17230b57cec5SDimitry Andric  return *this;
17240b57cec5SDimitry Andric}
17250b57cec5SDimitry Andric
17260b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1727cb14a3feSDimitry Andricinline unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1728cb14a3feSDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) {
17290b57cec5SDimitry Andric  __table_.__assign_multi(__il.begin(), __il.end());
17300b57cec5SDimitry Andric  return *this;
17310b57cec5SDimitry Andric}
17320b57cec5SDimitry Andric
17330b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
17340b57cec5SDimitry Andric
17350b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
17360b57cec5SDimitry Andrictemplate <class _InputIterator>
1737cb14a3feSDimitry Andricinline void unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
17380b57cec5SDimitry Andric  for (; __first != __last; ++__first)
17390b57cec5SDimitry Andric    __table_.__insert_multi(*__first);
17400b57cec5SDimitry Andric}
17410b57cec5SDimitry Andric
17420b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1743cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
1744cb14a3feSDimitry Andricswap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1745cb14a3feSDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
17460b57cec5SDimitry Andric  __x.swap(__y);
17470b57cec5SDimitry Andric}
17480b57cec5SDimitry Andric
174906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1750cb14a3feSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
1751cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type
1752cb14a3feSDimitry Andricerase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
17535f757f3fSDimitry Andric  return std::__libcpp_erase_if_container(__c, __pred);
17545ffd83dbSDimitry Andric}
17550b57cec5SDimitry Andric#endif
17560b57cec5SDimitry Andric
17570b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1758cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1759cb14a3feSDimitry Andric                                      const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) {
17600b57cec5SDimitry Andric  if (__x.size() != __y.size())
17610b57cec5SDimitry Andric    return false;
1762cb14a3feSDimitry Andric  typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator const_iterator;
17630b57cec5SDimitry Andric  typedef pair<const_iterator, const_iterator> _EqRng;
1764cb14a3feSDimitry Andric  for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) {
17650b57cec5SDimitry Andric    _EqRng __xeq = __x.equal_range(*__i);
17660b57cec5SDimitry Andric    _EqRng __yeq = __y.equal_range(*__i);
1767cb14a3feSDimitry Andric    if (std::distance(__xeq.first, __xeq.second) != std::distance(__yeq.first, __yeq.second) ||
17685f757f3fSDimitry Andric        !std::is_permutation(__xeq.first, __xeq.second, __yeq.first))
17690b57cec5SDimitry Andric      return false;
17700b57cec5SDimitry Andric    __i = __xeq.second;
17710b57cec5SDimitry Andric  }
17720b57cec5SDimitry Andric  return true;
17730b57cec5SDimitry Andric}
17740b57cec5SDimitry Andric
177506c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
177606c3fb27SDimitry Andric
17770b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1778cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1779cb14a3feSDimitry Andric                                             const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) {
17800b57cec5SDimitry Andric  return !(__x == __y);
17810b57cec5SDimitry Andric}
17820b57cec5SDimitry Andric
178306c3fb27SDimitry Andric#endif
178406c3fb27SDimitry Andric
17850b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
17860b57cec5SDimitry Andric
178706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
1788bdd1243dSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
1789bdd1243dSDimitry Andricnamespace pmr {
1790bdd1243dSDimitry Andrictemplate <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
179106c3fb27SDimitry Andricusing unordered_set _LIBCPP_AVAILABILITY_PMR = std::unordered_set<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;
1792bdd1243dSDimitry Andric
1793bdd1243dSDimitry Andrictemplate <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
1794cb14a3feSDimitry Andricusing unordered_multiset _LIBCPP_AVAILABILITY_PMR =
1795cb14a3feSDimitry Andric    std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;
1796bdd1243dSDimitry Andric} // namespace pmr
1797bdd1243dSDimitry Andric_LIBCPP_END_NAMESPACE_STD
1798bdd1243dSDimitry Andric#endif
1799bdd1243dSDimitry Andric
1800b3edf446SDimitry Andric_LIBCPP_POP_MACROS
1801b3edf446SDimitry Andric
1802bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1803bdd1243dSDimitry Andric#  include <concepts>
180406c3fb27SDimitry Andric#  include <cstdlib>
1805bdd1243dSDimitry Andric#  include <functional>
1806bdd1243dSDimitry Andric#  include <iterator>
18075f757f3fSDimitry Andric#  include <stdexcept>
180806c3fb27SDimitry Andric#  include <type_traits>
1809bdd1243dSDimitry Andric#endif
1810bdd1243dSDimitry Andric
18110b57cec5SDimitry Andric#endif // _LIBCPP_UNORDERED_SET
1812