xref: /freebsd/contrib/llvm-project/libcxx/include/unordered_set (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
10b57cec5SDimitry Andric// -*- C++ -*-
20b57cec5SDimitry Andric//===-------------------------- unordered_set -----------------------------===//
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
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric
150b57cec5SDimitry Andric    unordered_set synopsis
160b57cec5SDimitry Andric
170b57cec5SDimitry Andric#include <initializer_list>
180b57cec5SDimitry Andric
190b57cec5SDimitry Andricnamespace std
200b57cec5SDimitry Andric{
210b57cec5SDimitry Andric
220b57cec5SDimitry Andrictemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
230b57cec5SDimitry Andric          class Alloc = allocator<Value>>
240b57cec5SDimitry Andricclass unordered_set
250b57cec5SDimitry Andric{
260b57cec5SDimitry Andricpublic:
270b57cec5SDimitry Andric    // types
280b57cec5SDimitry Andric    typedef Value                                                      key_type;
290b57cec5SDimitry Andric    typedef key_type                                                   value_type;
300b57cec5SDimitry Andric    typedef Hash                                                       hasher;
310b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
320b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
330b57cec5SDimitry Andric    typedef value_type&                                                reference;
340b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
350b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
360b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
370b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
380b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
390b57cec5SDimitry Andric
400b57cec5SDimitry Andric    typedef /unspecified/ iterator;
410b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
420b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
430b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
440b57cec5SDimitry Andric
450b57cec5SDimitry Andric    typedef unspecified node_type unspecified;                            // C++17
460b57cec5SDimitry Andric    typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type;   // C++17
470b57cec5SDimitry Andric
480b57cec5SDimitry Andric    unordered_set()
490b57cec5SDimitry Andric        noexcept(
500b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
510b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
520b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
530b57cec5SDimitry Andric    explicit unordered_set(size_type n, const hasher& hf = hasher(),
540b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
550b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
560b57cec5SDimitry Andric    template <class InputIterator>
570b57cec5SDimitry Andric        unordered_set(InputIterator f, InputIterator l,
580b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
590b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
600b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
610b57cec5SDimitry Andric    explicit unordered_set(const allocator_type&);
620b57cec5SDimitry Andric    unordered_set(const unordered_set&);
630b57cec5SDimitry Andric    unordered_set(const unordered_set&, const Allocator&);
640b57cec5SDimitry Andric    unordered_set(unordered_set&&)
650b57cec5SDimitry Andric        noexcept(
660b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
670b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
680b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
690b57cec5SDimitry Andric    unordered_set(unordered_set&&, const Allocator&);
700b57cec5SDimitry Andric    unordered_set(initializer_list<value_type>, size_type n = 0,
710b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
720b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
730b57cec5SDimitry Andric    unordered_set(size_type n, const allocator_type& a); // C++14
740b57cec5SDimitry Andric    unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
750b57cec5SDimitry Andric    template <class InputIterator>
760b57cec5SDimitry Andric      unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
770b57cec5SDimitry Andric    template <class InputIterator>
780b57cec5SDimitry Andric      unordered_set(InputIterator f, InputIterator l, size_type n,
790b57cec5SDimitry Andric                    const hasher& hf,  const allocator_type& a); // C++14
800b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
810b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> il, size_type n,
820b57cec5SDimitry Andric                  const hasher& hf,  const allocator_type& a); // C++14
830b57cec5SDimitry Andric    ~unordered_set();
840b57cec5SDimitry Andric    unordered_set& operator=(const unordered_set&);
850b57cec5SDimitry Andric    unordered_set& operator=(unordered_set&&)
860b57cec5SDimitry Andric        noexcept(
870b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
880b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
890b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
900b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
910b57cec5SDimitry Andric    unordered_set& operator=(initializer_list<value_type>);
920b57cec5SDimitry Andric
930b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
940b57cec5SDimitry Andric
950b57cec5SDimitry Andric    bool      empty() const noexcept;
960b57cec5SDimitry Andric    size_type size() const noexcept;
970b57cec5SDimitry Andric    size_type max_size() const noexcept;
980b57cec5SDimitry Andric
990b57cec5SDimitry Andric    iterator       begin() noexcept;
1000b57cec5SDimitry Andric    iterator       end() noexcept;
1010b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
1020b57cec5SDimitry Andric    const_iterator end()    const noexcept;
1030b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
1040b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
1050b57cec5SDimitry Andric
1060b57cec5SDimitry Andric    template <class... Args>
1070b57cec5SDimitry Andric        pair<iterator, bool> emplace(Args&&... args);
1080b57cec5SDimitry Andric    template <class... Args>
1090b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
1100b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& obj);
1110b57cec5SDimitry Andric    pair<iterator, bool> insert(value_type&& obj);
1120b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
1130b57cec5SDimitry Andric    iterator insert(const_iterator hint, value_type&& obj);
1140b57cec5SDimitry Andric    template <class InputIterator>
1150b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
1160b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
1170b57cec5SDimitry Andric
1180b57cec5SDimitry Andric    node_type extract(const_iterator position);                       // C++17
1190b57cec5SDimitry Andric    node_type extract(const key_type& x);                             // C++17
1200b57cec5SDimitry Andric    insert_return_type insert(node_type&& nh);                        // C++17
1210b57cec5SDimitry Andric    iterator           insert(const_iterator hint, node_type&& nh);   // C++17
1220b57cec5SDimitry Andric
1230b57cec5SDimitry Andric    iterator erase(const_iterator position);
1240b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
1250b57cec5SDimitry Andric    size_type erase(const key_type& k);
1260b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
1270b57cec5SDimitry Andric    void clear() noexcept;
1280b57cec5SDimitry Andric
1290b57cec5SDimitry Andric    template<class H2, class P2>
1300b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>& source);         // C++17
1310b57cec5SDimitry Andric    template<class H2, class P2>
1320b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>&& source);        // C++17
1330b57cec5SDimitry Andric    template<class H2, class P2>
1340b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>& source);    // C++17
1350b57cec5SDimitry Andric    template<class H2, class P2>
1360b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);   // C++17
1370b57cec5SDimitry Andric
1380b57cec5SDimitry Andric    void swap(unordered_set&)
1390b57cec5SDimitry Andric       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
1400b57cec5SDimitry Andric                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
1410b57cec5SDimitry Andric                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
1420b57cec5SDimitry Andric
1430b57cec5SDimitry Andric    hasher hash_function() const;
1440b57cec5SDimitry Andric    key_equal key_eq() const;
1450b57cec5SDimitry Andric
1460b57cec5SDimitry Andric    iterator       find(const key_type& k);
1470b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
1480b57cec5SDimitry Andric    size_type count(const key_type& k) const;
1490b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
1500b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
1510b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
1520b57cec5SDimitry Andric
1530b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
1540b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
1550b57cec5SDimitry Andric
1560b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
1570b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
1580b57cec5SDimitry Andric
1590b57cec5SDimitry Andric    local_iterator       begin(size_type n);
1600b57cec5SDimitry Andric    local_iterator       end(size_type n);
1610b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
1620b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
1630b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
1640b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
1650b57cec5SDimitry Andric
1660b57cec5SDimitry Andric    float load_factor() const noexcept;
1670b57cec5SDimitry Andric    float max_load_factor() const noexcept;
1680b57cec5SDimitry Andric    void max_load_factor(float z);
1690b57cec5SDimitry Andric    void rehash(size_type n);
1700b57cec5SDimitry Andric    void reserve(size_type n);
1710b57cec5SDimitry Andric};
1720b57cec5SDimitry Andric
1730b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
1740b57cec5SDimitry Andric    void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
1750b57cec5SDimitry Andric              unordered_set<Value, Hash, Pred, Alloc>& y)
1760b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
1770b57cec5SDimitry Andric
1780b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
1790b57cec5SDimitry Andric    bool
1800b57cec5SDimitry Andric    operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
1810b57cec5SDimitry Andric               const unordered_set<Value, Hash, Pred, Alloc>& y);
1820b57cec5SDimitry Andric
1830b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
1840b57cec5SDimitry Andric    bool
1850b57cec5SDimitry Andric    operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
1860b57cec5SDimitry Andric               const unordered_set<Value, Hash, Pred, Alloc>& y);
1870b57cec5SDimitry Andric
1880b57cec5SDimitry Andrictemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
1890b57cec5SDimitry Andric          class Alloc = allocator<Value>>
1900b57cec5SDimitry Andricclass unordered_multiset
1910b57cec5SDimitry Andric{
1920b57cec5SDimitry Andricpublic:
1930b57cec5SDimitry Andric    // types
1940b57cec5SDimitry Andric    typedef Value                                                      key_type;
1950b57cec5SDimitry Andric    typedef key_type                                                   value_type;
1960b57cec5SDimitry Andric    typedef Hash                                                       hasher;
1970b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
1980b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
1990b57cec5SDimitry Andric    typedef value_type&                                                reference;
2000b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
2010b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
2020b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
2030b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
2040b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
2050b57cec5SDimitry Andric
2060b57cec5SDimitry Andric    typedef /unspecified/ iterator;
2070b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
2080b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
2090b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
2100b57cec5SDimitry Andric
2110b57cec5SDimitry Andric    typedef unspecified node_type unspecified;   // C++17
2120b57cec5SDimitry Andric
2130b57cec5SDimitry Andric    unordered_multiset()
2140b57cec5SDimitry Andric        noexcept(
2150b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
2160b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
2170b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
2180b57cec5SDimitry Andric    explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
2190b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
2200b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
2210b57cec5SDimitry Andric    template <class InputIterator>
2220b57cec5SDimitry Andric        unordered_multiset(InputIterator f, InputIterator l,
2230b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
2240b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
2250b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
2260b57cec5SDimitry Andric    explicit unordered_multiset(const allocator_type&);
2270b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset&);
2280b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset&, const Allocator&);
2290b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&&)
2300b57cec5SDimitry Andric        noexcept(
2310b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
2320b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
2330b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
2340b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&&, const Allocator&);
2350b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
2360b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
2370b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
2380b57cec5SDimitry Andric    unordered_multiset(size_type n, const allocator_type& a); // C++14
2390b57cec5SDimitry Andric    unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
2400b57cec5SDimitry Andric    template <class InputIterator>
2410b57cec5SDimitry Andric      unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
2420b57cec5SDimitry Andric    template <class InputIterator>
2430b57cec5SDimitry Andric      unordered_multiset(InputIterator f, InputIterator l, size_type n,
2440b57cec5SDimitry Andric                         const hasher& hf, const allocator_type& a); // C++14
2450b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
2460b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> il, size_type n,
2470b57cec5SDimitry Andric                       const hasher& hf,  const allocator_type& a); // C++14
2480b57cec5SDimitry Andric    ~unordered_multiset();
2490b57cec5SDimitry Andric    unordered_multiset& operator=(const unordered_multiset&);
2500b57cec5SDimitry Andric    unordered_multiset& operator=(unordered_multiset&&)
2510b57cec5SDimitry Andric        noexcept(
2520b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
2530b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
2540b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
2550b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
2560b57cec5SDimitry Andric    unordered_multiset& operator=(initializer_list<value_type>);
2570b57cec5SDimitry Andric
2580b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
2590b57cec5SDimitry Andric
2600b57cec5SDimitry Andric    bool      empty() const noexcept;
2610b57cec5SDimitry Andric    size_type size() const noexcept;
2620b57cec5SDimitry Andric    size_type max_size() const noexcept;
2630b57cec5SDimitry Andric
2640b57cec5SDimitry Andric    iterator       begin() noexcept;
2650b57cec5SDimitry Andric    iterator       end() noexcept;
2660b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
2670b57cec5SDimitry Andric    const_iterator end()    const noexcept;
2680b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
2690b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
2700b57cec5SDimitry Andric
2710b57cec5SDimitry Andric    template <class... Args>
2720b57cec5SDimitry Andric        iterator emplace(Args&&... args);
2730b57cec5SDimitry Andric    template <class... Args>
2740b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
2750b57cec5SDimitry Andric    iterator insert(const value_type& obj);
2760b57cec5SDimitry Andric    iterator insert(value_type&& obj);
2770b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
2780b57cec5SDimitry Andric    iterator insert(const_iterator hint, value_type&& obj);
2790b57cec5SDimitry Andric    template <class InputIterator>
2800b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
2810b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
2820b57cec5SDimitry Andric
2830b57cec5SDimitry Andric    node_type extract(const_iterator position);             // C++17
2840b57cec5SDimitry Andric    node_type extract(const key_type& x);                   // C++17
2850b57cec5SDimitry Andric    iterator insert(node_type&& nh);                        // C++17
2860b57cec5SDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);   // C++17
2870b57cec5SDimitry Andric
2880b57cec5SDimitry Andric    iterator erase(const_iterator position);
2890b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
2900b57cec5SDimitry Andric    size_type erase(const key_type& k);
2910b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
2920b57cec5SDimitry Andric    void clear() noexcept;
2930b57cec5SDimitry Andric
2940b57cec5SDimitry Andric    template<class H2, class P2>
2950b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>& source);    // C++17
2960b57cec5SDimitry Andric    template<class H2, class P2>
2970b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);   // C++17
2980b57cec5SDimitry Andric    template<class H2, class P2>
2990b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>& source);         // C++17
3000b57cec5SDimitry Andric    template<class H2, class P2>
3010b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>&& source);        // C++17
3020b57cec5SDimitry Andric
3030b57cec5SDimitry Andric    void swap(unordered_multiset&)
3040b57cec5SDimitry Andric       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
3050b57cec5SDimitry Andric                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
3060b57cec5SDimitry Andric                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
3070b57cec5SDimitry Andric
3080b57cec5SDimitry Andric    hasher hash_function() const;
3090b57cec5SDimitry Andric    key_equal key_eq() const;
3100b57cec5SDimitry Andric
3110b57cec5SDimitry Andric    iterator       find(const key_type& k);
3120b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
3130b57cec5SDimitry Andric    size_type count(const key_type& k) const;
3140b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
3150b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
3160b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
3170b57cec5SDimitry Andric
3180b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
3190b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
3200b57cec5SDimitry Andric
3210b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
3220b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
3230b57cec5SDimitry Andric
3240b57cec5SDimitry Andric    local_iterator       begin(size_type n);
3250b57cec5SDimitry Andric    local_iterator       end(size_type n);
3260b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
3270b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
3280b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
3290b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
3300b57cec5SDimitry Andric
3310b57cec5SDimitry Andric    float load_factor() const noexcept;
3320b57cec5SDimitry Andric    float max_load_factor() const noexcept;
3330b57cec5SDimitry Andric    void max_load_factor(float z);
3340b57cec5SDimitry Andric    void rehash(size_type n);
3350b57cec5SDimitry Andric    void reserve(size_type n);
3360b57cec5SDimitry Andric};
3370b57cec5SDimitry Andric
3380b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
3390b57cec5SDimitry Andric    void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
3400b57cec5SDimitry Andric              unordered_multiset<Value, Hash, Pred, Alloc>& y)
3410b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
344*5ffd83dbSDimitry Andric    typename unordered_set<K, T, H, P, A>::size_type
345*5ffd83dbSDimitry Andric    erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred);       // C++20
3460b57cec5SDimitry Andric
3470b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
348*5ffd83dbSDimitry Andric    typename unordered_multiset<K, T, H, P, A>::size_type
349*5ffd83dbSDimitry Andric    erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred);  // C++20
3500b57cec5SDimitry Andric
3510b57cec5SDimitry Andric
3520b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
3530b57cec5SDimitry Andric    bool
3540b57cec5SDimitry Andric    operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
3550b57cec5SDimitry Andric               const unordered_multiset<Value, Hash, Pred, Alloc>& y);
3560b57cec5SDimitry Andric
3570b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
3580b57cec5SDimitry Andric    bool
3590b57cec5SDimitry Andric    operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
3600b57cec5SDimitry Andric               const unordered_multiset<Value, Hash, Pred, Alloc>& y);
3610b57cec5SDimitry Andric}  // std
3620b57cec5SDimitry Andric
3630b57cec5SDimitry Andric*/
3640b57cec5SDimitry Andric
3650b57cec5SDimitry Andric#include <__config>
3660b57cec5SDimitry Andric#include <__hash_table>
3670b57cec5SDimitry Andric#include <__node_handle>
3680b57cec5SDimitry Andric#include <functional>
3690b57cec5SDimitry Andric#include <version>
3700b57cec5SDimitry Andric
3710b57cec5SDimitry Andric#include <__debug>
3720b57cec5SDimitry Andric
3730b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3740b57cec5SDimitry Andric#pragma GCC system_header
3750b57cec5SDimitry Andric#endif
3760b57cec5SDimitry Andric
3770b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
3780b57cec5SDimitry Andric
3790b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
3800b57cec5SDimitry Andricclass unordered_multiset;
3810b57cec5SDimitry Andric
3820b57cec5SDimitry Andrictemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
3830b57cec5SDimitry Andric          class _Alloc = allocator<_Value> >
3840b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_set
3850b57cec5SDimitry Andric{
3860b57cec5SDimitry Andricpublic:
3870b57cec5SDimitry Andric    // types
3880b57cec5SDimitry Andric    typedef _Value                                                     key_type;
3890b57cec5SDimitry Andric    typedef key_type                                                   value_type;
3900b57cec5SDimitry Andric    typedef typename __identity<_Hash>::type                           hasher;
3910b57cec5SDimitry Andric    typedef typename __identity<_Pred>::type                           key_equal;
3920b57cec5SDimitry Andric    typedef typename __identity<_Alloc>::type                          allocator_type;
3930b57cec5SDimitry Andric    typedef value_type&                                                reference;
3940b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
3950b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
3960b57cec5SDimitry Andric                  "Invalid allocator::value_type");
3970b57cec5SDimitry Andric
3980b57cec5SDimitry Andricprivate:
3990b57cec5SDimitry Andric    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
4000b57cec5SDimitry Andric
4010b57cec5SDimitry Andric    __table __table_;
4020b57cec5SDimitry Andric
4030b57cec5SDimitry Andricpublic:
4040b57cec5SDimitry Andric    typedef typename __table::pointer         pointer;
4050b57cec5SDimitry Andric    typedef typename __table::const_pointer   const_pointer;
4060b57cec5SDimitry Andric    typedef typename __table::size_type       size_type;
4070b57cec5SDimitry Andric    typedef typename __table::difference_type difference_type;
4080b57cec5SDimitry Andric
4090b57cec5SDimitry Andric    typedef typename __table::const_iterator       iterator;
4100b57cec5SDimitry Andric    typedef typename __table::const_iterator       const_iterator;
4110b57cec5SDimitry Andric    typedef typename __table::const_local_iterator local_iterator;
4120b57cec5SDimitry Andric    typedef typename __table::const_local_iterator const_local_iterator;
4130b57cec5SDimitry Andric
4140b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
4150b57cec5SDimitry Andric    typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
4160b57cec5SDimitry Andric    typedef __insert_return_type<iterator, node_type> insert_return_type;
4170b57cec5SDimitry Andric#endif
4180b57cec5SDimitry Andric
4190b57cec5SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
4200b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_set;
4210b57cec5SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
4220b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
4230b57cec5SDimitry Andric
4240b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4250b57cec5SDimitry Andric    unordered_set()
4260b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
4270b57cec5SDimitry Andric        {
4280b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
4290b57cec5SDimitry Andric            __get_db()->__insert_c(this);
4300b57cec5SDimitry Andric#endif
4310b57cec5SDimitry Andric        }
4320b57cec5SDimitry Andric    explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
4330b57cec5SDimitry Andric                           const key_equal& __eql = key_equal());
4340b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
4350b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4360b57cec5SDimitry Andric    unordered_set(size_type __n, const allocator_type& __a)
4370b57cec5SDimitry Andric        : unordered_set(__n, hasher(), key_equal(), __a) {}
4380b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4390b57cec5SDimitry Andric    unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
4400b57cec5SDimitry Andric        : unordered_set(__n, __hf, key_equal(), __a) {}
4410b57cec5SDimitry Andric#endif
4420b57cec5SDimitry Andric    unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
4430b57cec5SDimitry Andric                  const allocator_type& __a);
4440b57cec5SDimitry Andric    template <class _InputIterator>
4450b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last);
4460b57cec5SDimitry Andric    template <class _InputIterator>
4470b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
4480b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
4490b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
4500b57cec5SDimitry Andric    template <class _InputIterator>
4510b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
4520b57cec5SDimitry Andric                      size_type __n, const hasher& __hf, const key_equal& __eql,
4530b57cec5SDimitry Andric                      const allocator_type& __a);
4540b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
4550b57cec5SDimitry Andric    template <class _InputIterator>
4560b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4570b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
4580b57cec5SDimitry Andric                    size_type __n, const allocator_type& __a)
4590b57cec5SDimitry Andric            : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
4600b57cec5SDimitry Andric    template <class _InputIterator>
4610b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
4620b57cec5SDimitry Andric                      size_type __n, const hasher& __hf, const allocator_type& __a)
4630b57cec5SDimitry Andric            : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
4640b57cec5SDimitry Andric#endif
4650b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4660b57cec5SDimitry Andric    explicit unordered_set(const allocator_type& __a);
4670b57cec5SDimitry Andric    unordered_set(const unordered_set& __u);
4680b57cec5SDimitry Andric    unordered_set(const unordered_set& __u, const allocator_type& __a);
4690b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4710b57cec5SDimitry Andric    unordered_set(unordered_set&& __u)
4720b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
4730b57cec5SDimitry Andric    unordered_set(unordered_set&& __u, const allocator_type& __a);
4740b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il);
4750b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
4760b57cec5SDimitry Andric                  const hasher& __hf = hasher(),
4770b57cec5SDimitry Andric                  const key_equal& __eql = key_equal());
4780b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
4790b57cec5SDimitry Andric                  const hasher& __hf, const key_equal& __eql,
4800b57cec5SDimitry Andric                  const allocator_type& __a);
4810b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
4820b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4830b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
4840b57cec5SDimitry Andric                                                      const allocator_type& __a)
4850b57cec5SDimitry Andric        : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
4860b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
4870b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
4880b57cec5SDimitry Andric                                  const hasher& __hf, const allocator_type& __a)
4890b57cec5SDimitry Andric        : unordered_set(__il, __n, __hf, key_equal(), __a) {}
4900b57cec5SDimitry Andric#endif
4910b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
4920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4930b57cec5SDimitry Andric    ~unordered_set() {
4940b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
4950b57cec5SDimitry Andric    }
4960b57cec5SDimitry Andric
4970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4980b57cec5SDimitry Andric    unordered_set& operator=(const unordered_set& __u)
4990b57cec5SDimitry Andric    {
5000b57cec5SDimitry Andric        __table_ = __u.__table_;
5010b57cec5SDimitry Andric        return *this;
5020b57cec5SDimitry Andric    }
5030b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5040b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5050b57cec5SDimitry Andric    unordered_set& operator=(unordered_set&& __u)
5060b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
5070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5080b57cec5SDimitry Andric    unordered_set& operator=(initializer_list<value_type> __il);
5090b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
5100b57cec5SDimitry Andric
5110b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5120b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
5130b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
5140b57cec5SDimitry Andric
5150b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
5160b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
5170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5180b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
5190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5200b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
5210b57cec5SDimitry Andric
5220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5230b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
5240b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5250b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
5260b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5270b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
5280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5290b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
5300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5310b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
5320b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5330b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
5340b57cec5SDimitry Andric
5350b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5360b57cec5SDimitry Andric    template <class... _Args>
5370b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5380b57cec5SDimitry Andric        pair<iterator, bool> emplace(_Args&&... __args)
5390b57cec5SDimitry Andric            {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
5400b57cec5SDimitry Andric    template <class... _Args>
5410b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5420b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
5430b57cec5SDimitry Andric        iterator emplace_hint(const_iterator __p, _Args&&... __args)
5440b57cec5SDimitry Andric        {
5450b57cec5SDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
5460b57cec5SDimitry Andric                "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
5470b57cec5SDimitry Andric                " referring to this unordered_set");
5480b57cec5SDimitry Andric            return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
5490b57cec5SDimitry Andric        }
5500b57cec5SDimitry Andric#else
5510b57cec5SDimitry Andric        iterator emplace_hint(const_iterator, _Args&&... __args)
5520b57cec5SDimitry Andric            {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
5530b57cec5SDimitry Andric#endif
5540b57cec5SDimitry Andric
5550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5560b57cec5SDimitry Andric    pair<iterator, bool> insert(value_type&& __x)
5570b57cec5SDimitry Andric        {return __table_.__insert_unique(_VSTD::move(__x));}
5580b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5590b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
5600b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __x)
5610b57cec5SDimitry Andric        {
5620b57cec5SDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
5630b57cec5SDimitry Andric                "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
5640b57cec5SDimitry Andric                " referring to this unordered_set");
5650b57cec5SDimitry Andric            return insert(_VSTD::move(__x)).first;
5660b57cec5SDimitry Andric        }
5670b57cec5SDimitry Andric#else
5680b57cec5SDimitry Andric    iterator insert(const_iterator, value_type&& __x)
5690b57cec5SDimitry Andric        {return insert(_VSTD::move(__x)).first;}
5700b57cec5SDimitry Andric#endif
5710b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5720b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
5730b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
5740b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
5750b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5760b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& __x)
5770b57cec5SDimitry Andric        {return __table_.__insert_unique(__x);}
5780b57cec5SDimitry Andric
5790b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5800b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
5810b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __x)
5820b57cec5SDimitry Andric        {
5830b57cec5SDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
5840b57cec5SDimitry Andric                "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
5850b57cec5SDimitry Andric                " referring to this unordered_set");
5860b57cec5SDimitry Andric            return insert(__x).first;
5870b57cec5SDimitry Andric        }
5880b57cec5SDimitry Andric#else
5890b57cec5SDimitry Andric    iterator insert(const_iterator, const value_type& __x)
5900b57cec5SDimitry Andric        {return insert(__x).first;}
5910b57cec5SDimitry Andric#endif
5920b57cec5SDimitry Andric    template <class _InputIterator>
5930b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5940b57cec5SDimitry Andric        void insert(_InputIterator __first, _InputIterator __last);
5950b57cec5SDimitry Andric
5960b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5970b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p);}
5980b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5990b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
6000b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6010b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
6020b57cec5SDimitry Andric        {return __table_.erase(__first, __last);}
6030b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6040b57cec5SDimitry Andric    void clear() _NOEXCEPT {__table_.clear();}
6050b57cec5SDimitry Andric
6060b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
6070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6080b57cec5SDimitry Andric    insert_return_type insert(node_type&& __nh)
6090b57cec5SDimitry Andric    {
6100b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
6110b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_set::insert()");
6120b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<
6130b57cec5SDimitry Andric            node_type, insert_return_type>(_VSTD::move(__nh));
6140b57cec5SDimitry Andric    }
6150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6160b57cec5SDimitry Andric    iterator insert(const_iterator __h, node_type&& __nh)
6170b57cec5SDimitry Andric    {
6180b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
6190b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_set::insert()");
6200b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<node_type>(
6210b57cec5SDimitry Andric            __h, _VSTD::move(__nh));
6220b57cec5SDimitry Andric    }
6230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6240b57cec5SDimitry Andric    node_type extract(key_type const& __key)
6250b57cec5SDimitry Andric    {
6260b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
6270b57cec5SDimitry Andric    }
6280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6290b57cec5SDimitry Andric    node_type extract(const_iterator __it)
6300b57cec5SDimitry Andric    {
6310b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__it);
6320b57cec5SDimitry Andric    }
6330b57cec5SDimitry Andric
6340b57cec5SDimitry Andric    template<class _H2, class _P2>
6350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6360b57cec5SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
6370b57cec5SDimitry Andric    {
6380b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
6390b57cec5SDimitry Andric                       "merging container with incompatible allocator");
6400b57cec5SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
6410b57cec5SDimitry Andric    }
6420b57cec5SDimitry Andric    template<class _H2, class _P2>
6430b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6440b57cec5SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
6450b57cec5SDimitry Andric    {
6460b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
6470b57cec5SDimitry Andric                       "merging container with incompatible allocator");
6480b57cec5SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
6490b57cec5SDimitry Andric    }
6500b57cec5SDimitry Andric    template<class _H2, class _P2>
6510b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6520b57cec5SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
6530b57cec5SDimitry Andric    {
6540b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
6550b57cec5SDimitry Andric                       "merging container with incompatible allocator");
6560b57cec5SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
6570b57cec5SDimitry Andric    }
6580b57cec5SDimitry Andric    template<class _H2, class _P2>
6590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6600b57cec5SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
6610b57cec5SDimitry Andric    {
6620b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
6630b57cec5SDimitry Andric                       "merging container with incompatible allocator");
6640b57cec5SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
6650b57cec5SDimitry Andric    }
6660b57cec5SDimitry Andric#endif
6670b57cec5SDimitry Andric
6680b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6690b57cec5SDimitry Andric    void swap(unordered_set& __u)
6700b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
6710b57cec5SDimitry Andric        {__table_.swap(__u.__table_);}
6720b57cec5SDimitry Andric
6730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6740b57cec5SDimitry Andric    hasher hash_function() const {return __table_.hash_function();}
6750b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6760b57cec5SDimitry Andric    key_equal key_eq() const {return __table_.key_eq();}
6770b57cec5SDimitry Andric
6780b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6790b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
6800b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6810b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
6820b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6830b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
6840b57cec5SDimitry Andric    #if _LIBCPP_STD_VER > 17
6850b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6860b57cec5SDimitry Andric        bool contains(const key_type& __k) const {return find(__k) != end();}
6870b57cec5SDimitry Andric    #endif // _LIBCPP_STD_VER > 17
6880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6890b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
6900b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
6910b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6920b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
6930b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
6940b57cec5SDimitry Andric
6950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6960b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
6970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6980b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
6990b57cec5SDimitry Andric
7000b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7010b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
7020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7030b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
7040b57cec5SDimitry Andric
7050b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7060b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
7070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7080b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
7090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7100b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
7110b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7120b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
7130b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7140b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
7150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7160b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
7170b57cec5SDimitry Andric
7180b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7190b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
7200b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7210b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
7220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7230b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
7240b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7250b57cec5SDimitry Andric    void rehash(size_type __n) {__table_.rehash(__n);}
7260b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7270b57cec5SDimitry Andric    void reserve(size_type __n) {__table_.reserve(__n);}
7280b57cec5SDimitry Andric
7290b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
7300b57cec5SDimitry Andric
7310b57cec5SDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
7320b57cec5SDimitry Andric        {return __table_.__dereferenceable(__i);}
7330b57cec5SDimitry Andric    bool __decrementable(const const_iterator* __i) const
7340b57cec5SDimitry Andric        {return __table_.__decrementable(__i);}
7350b57cec5SDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
7360b57cec5SDimitry Andric        {return __table_.__addable(__i, __n);}
7370b57cec5SDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
7380b57cec5SDimitry Andric        {return __table_.__addable(__i, __n);}
7390b57cec5SDimitry Andric
7400b57cec5SDimitry Andric#endif  // _LIBCPP_DEBUG_LEVEL >= 2
7410b57cec5SDimitry Andric
7420b57cec5SDimitry Andric};
7430b57cec5SDimitry Andric
7440b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
7450b57cec5SDimitry Andrictemplate<class _InputIterator,
7460b57cec5SDimitry Andric         class _Hash = hash<__iter_value_type<_InputIterator>>,
7470b57cec5SDimitry Andric         class _Pred = equal_to<__iter_value_type<_InputIterator>>,
7480b57cec5SDimitry Andric         class _Allocator = allocator<__iter_value_type<_InputIterator>>,
7490b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
7500b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
7510b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
7520b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
7530b57cec5SDimitry Andricunordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
7540b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
7550b57cec5SDimitry Andric  -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
7560b57cec5SDimitry Andric
7570b57cec5SDimitry Andrictemplate<class _Tp, class _Hash = hash<_Tp>,
7580b57cec5SDimitry Andric         class _Pred = equal_to<_Tp>,
7590b57cec5SDimitry Andric         class _Allocator = allocator<_Tp>,
7600b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
7610b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
7620b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
7630b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
7640b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0,
7650b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
7660b57cec5SDimitry Andric  -> unordered_set<_Tp, _Hash, _Pred, _Allocator>;
7670b57cec5SDimitry Andric
7680b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
7690b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
7700b57cec5SDimitry Andricunordered_set(_InputIterator, _InputIterator,
7710b57cec5SDimitry Andric              typename allocator_traits<_Allocator>::size_type, _Allocator)
7720b57cec5SDimitry Andric  -> unordered_set<__iter_value_type<_InputIterator>,
7730b57cec5SDimitry Andric                   hash<__iter_value_type<_InputIterator>>,
7740b57cec5SDimitry Andric                   equal_to<__iter_value_type<_InputIterator>>,
7750b57cec5SDimitry Andric                   _Allocator>;
7760b57cec5SDimitry Andric
7770b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
7780b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
7790b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
7800b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
7810b57cec5SDimitry Andricunordered_set(_InputIterator, _InputIterator,
7820b57cec5SDimitry Andric              typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
7830b57cec5SDimitry Andric  -> unordered_set<__iter_value_type<_InputIterator>, _Hash,
7840b57cec5SDimitry Andric                   equal_to<__iter_value_type<_InputIterator>>,
7850b57cec5SDimitry Andric                   _Allocator>;
7860b57cec5SDimitry Andric
7870b57cec5SDimitry Andrictemplate<class _Tp, class _Allocator,
7880b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
7890b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
7900b57cec5SDimitry Andric  -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
7910b57cec5SDimitry Andric
7920b57cec5SDimitry Andrictemplate<class _Tp, class _Hash, class _Allocator,
7930b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
7940b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
7950b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
7960b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
7970b57cec5SDimitry Andric  -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
7980b57cec5SDimitry Andric#endif
7990b57cec5SDimitry Andric
8000b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8010b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
8020b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
8030b57cec5SDimitry Andric    : __table_(__hf, __eql)
8040b57cec5SDimitry Andric{
8050b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8060b57cec5SDimitry Andric    __get_db()->__insert_c(this);
8070b57cec5SDimitry Andric#endif
8080b57cec5SDimitry Andric    __table_.rehash(__n);
8090b57cec5SDimitry Andric}
8100b57cec5SDimitry Andric
8110b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8120b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
8130b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
8140b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
8150b57cec5SDimitry Andric{
8160b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8170b57cec5SDimitry Andric    __get_db()->__insert_c(this);
8180b57cec5SDimitry Andric#endif
8190b57cec5SDimitry Andric    __table_.rehash(__n);
8200b57cec5SDimitry Andric}
8210b57cec5SDimitry Andric
8220b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8230b57cec5SDimitry Andrictemplate <class _InputIterator>
8240b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8250b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
8260b57cec5SDimitry Andric{
8270b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8280b57cec5SDimitry Andric    __get_db()->__insert_c(this);
8290b57cec5SDimitry Andric#endif
8300b57cec5SDimitry Andric    insert(__first, __last);
8310b57cec5SDimitry Andric}
8320b57cec5SDimitry Andric
8330b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8340b57cec5SDimitry Andrictemplate <class _InputIterator>
8350b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8360b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
8370b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
8380b57cec5SDimitry Andric    : __table_(__hf, __eql)
8390b57cec5SDimitry Andric{
8400b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8410b57cec5SDimitry Andric    __get_db()->__insert_c(this);
8420b57cec5SDimitry Andric#endif
8430b57cec5SDimitry Andric    __table_.rehash(__n);
8440b57cec5SDimitry Andric    insert(__first, __last);
8450b57cec5SDimitry Andric}
8460b57cec5SDimitry Andric
8470b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8480b57cec5SDimitry Andrictemplate <class _InputIterator>
8490b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8500b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
8510b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
8520b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
8530b57cec5SDimitry Andric{
8540b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8550b57cec5SDimitry Andric    __get_db()->__insert_c(this);
8560b57cec5SDimitry Andric#endif
8570b57cec5SDimitry Andric    __table_.rehash(__n);
8580b57cec5SDimitry Andric    insert(__first, __last);
8590b57cec5SDimitry Andric}
8600b57cec5SDimitry Andric
8610b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8620b57cec5SDimitry Andricinline
8630b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8640b57cec5SDimitry Andric        const allocator_type& __a)
8650b57cec5SDimitry Andric    : __table_(__a)
8660b57cec5SDimitry Andric{
8670b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8680b57cec5SDimitry Andric    __get_db()->__insert_c(this);
8690b57cec5SDimitry Andric#endif
8700b57cec5SDimitry Andric}
8710b57cec5SDimitry Andric
8720b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8730b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8740b57cec5SDimitry Andric        const unordered_set& __u)
8750b57cec5SDimitry Andric    : __table_(__u.__table_)
8760b57cec5SDimitry Andric{
8770b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8780b57cec5SDimitry Andric    __get_db()->__insert_c(this);
8790b57cec5SDimitry Andric#endif
8800b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
8810b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
8820b57cec5SDimitry Andric}
8830b57cec5SDimitry Andric
8840b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8850b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
8860b57cec5SDimitry Andric        const unordered_set& __u, const allocator_type& __a)
8870b57cec5SDimitry Andric    : __table_(__u.__table_, __a)
8880b57cec5SDimitry Andric{
8890b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
8900b57cec5SDimitry Andric    __get_db()->__insert_c(this);
8910b57cec5SDimitry Andric#endif
8920b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
8930b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
8940b57cec5SDimitry Andric}
8950b57cec5SDimitry Andric
8960b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8970b57cec5SDimitry Andric
8980b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
8990b57cec5SDimitry Andricinline
9000b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
9010b57cec5SDimitry Andric        unordered_set&& __u)
9020b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
9030b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
9040b57cec5SDimitry Andric{
9050b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
9060b57cec5SDimitry Andric    __get_db()->__insert_c(this);
9070b57cec5SDimitry Andric    __get_db()->swap(this, &__u);
9080b57cec5SDimitry Andric#endif
9090b57cec5SDimitry Andric}
9100b57cec5SDimitry Andric
9110b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9120b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
9130b57cec5SDimitry Andric        unordered_set&& __u, const allocator_type& __a)
9140b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), __a)
9150b57cec5SDimitry Andric{
9160b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
9170b57cec5SDimitry Andric    __get_db()->__insert_c(this);
9180b57cec5SDimitry Andric#endif
9190b57cec5SDimitry Andric    if (__a != __u.get_allocator())
9200b57cec5SDimitry Andric    {
9210b57cec5SDimitry Andric        iterator __i = __u.begin();
9220b57cec5SDimitry Andric        while (__u.size() != 0)
9230b57cec5SDimitry Andric            __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
9240b57cec5SDimitry Andric    }
9250b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
9260b57cec5SDimitry Andric    else
9270b57cec5SDimitry Andric        __get_db()->swap(this, &__u);
9280b57cec5SDimitry Andric#endif
9290b57cec5SDimitry Andric}
9300b57cec5SDimitry Andric
9310b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9320b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
9330b57cec5SDimitry Andric        initializer_list<value_type> __il)
9340b57cec5SDimitry Andric{
9350b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
9360b57cec5SDimitry Andric    __get_db()->__insert_c(this);
9370b57cec5SDimitry Andric#endif
9380b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
9390b57cec5SDimitry Andric}
9400b57cec5SDimitry Andric
9410b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9420b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
9430b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
9440b57cec5SDimitry Andric        const key_equal& __eql)
9450b57cec5SDimitry Andric    : __table_(__hf, __eql)
9460b57cec5SDimitry Andric{
9470b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
9480b57cec5SDimitry Andric    __get_db()->__insert_c(this);
9490b57cec5SDimitry Andric#endif
9500b57cec5SDimitry Andric    __table_.rehash(__n);
9510b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
9520b57cec5SDimitry Andric}
9530b57cec5SDimitry Andric
9540b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9550b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
9560b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
9570b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
9580b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
9590b57cec5SDimitry Andric{
9600b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
9610b57cec5SDimitry Andric    __get_db()->__insert_c(this);
9620b57cec5SDimitry Andric#endif
9630b57cec5SDimitry Andric    __table_.rehash(__n);
9640b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
9650b57cec5SDimitry Andric}
9660b57cec5SDimitry Andric
9670b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9680b57cec5SDimitry Andricinline
9690b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>&
9700b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
9710b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
9720b57cec5SDimitry Andric{
9730b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
9740b57cec5SDimitry Andric    return *this;
9750b57cec5SDimitry Andric}
9760b57cec5SDimitry Andric
9770b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9780b57cec5SDimitry Andricinline
9790b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>&
9800b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
9810b57cec5SDimitry Andric        initializer_list<value_type> __il)
9820b57cec5SDimitry Andric{
9830b57cec5SDimitry Andric    __table_.__assign_unique(__il.begin(), __il.end());
9840b57cec5SDimitry Andric    return *this;
9850b57cec5SDimitry Andric}
9860b57cec5SDimitry Andric
9870b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
9880b57cec5SDimitry Andric
9890b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
9900b57cec5SDimitry Andrictemplate <class _InputIterator>
9910b57cec5SDimitry Andricinline
9920b57cec5SDimitry Andricvoid
9930b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
9940b57cec5SDimitry Andric                                                    _InputIterator __last)
9950b57cec5SDimitry Andric{
9960b57cec5SDimitry Andric    for (; __first != __last; ++__first)
9970b57cec5SDimitry Andric        __table_.__insert_unique(*__first);
9980b57cec5SDimitry Andric}
9990b57cec5SDimitry Andric
10000b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
10010b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
10020b57cec5SDimitry Andricvoid
10030b57cec5SDimitry Andricswap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
10040b57cec5SDimitry Andric     unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
10050b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
10060b57cec5SDimitry Andric{
10070b57cec5SDimitry Andric    __x.swap(__y);
10080b57cec5SDimitry Andric}
10090b57cec5SDimitry Andric
10100b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
1011*5ffd83dbSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc,
1012*5ffd83dbSDimitry Andric          class _Predicate>
10130b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1014*5ffd83dbSDimitry Andric    typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type
1015*5ffd83dbSDimitry Andric    erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c,
1016*5ffd83dbSDimitry Andric             _Predicate __pred) {
1017*5ffd83dbSDimitry Andric  return __libcpp_erase_if_container(__c, __pred);
1018*5ffd83dbSDimitry Andric}
10190b57cec5SDimitry Andric#endif
10200b57cec5SDimitry Andric
10210b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
10220b57cec5SDimitry Andricbool
10230b57cec5SDimitry Andricoperator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
10240b57cec5SDimitry Andric           const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
10250b57cec5SDimitry Andric{
10260b57cec5SDimitry Andric    if (__x.size() != __y.size())
10270b57cec5SDimitry Andric        return false;
10280b57cec5SDimitry Andric    typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
10290b57cec5SDimitry Andric                                                                 const_iterator;
10300b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
10310b57cec5SDimitry Andric            __i != __ex; ++__i)
10320b57cec5SDimitry Andric    {
10330b57cec5SDimitry Andric        const_iterator __j = __y.find(*__i);
10340b57cec5SDimitry Andric        if (__j == __ey || !(*__i == *__j))
10350b57cec5SDimitry Andric            return false;
10360b57cec5SDimitry Andric    }
10370b57cec5SDimitry Andric    return true;
10380b57cec5SDimitry Andric}
10390b57cec5SDimitry Andric
10400b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
10410b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
10420b57cec5SDimitry Andricbool
10430b57cec5SDimitry Andricoperator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
10440b57cec5SDimitry Andric           const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
10450b57cec5SDimitry Andric{
10460b57cec5SDimitry Andric    return !(__x == __y);
10470b57cec5SDimitry Andric}
10480b57cec5SDimitry Andric
10490b57cec5SDimitry Andrictemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
10500b57cec5SDimitry Andric          class _Alloc = allocator<_Value> >
10510b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multiset
10520b57cec5SDimitry Andric{
10530b57cec5SDimitry Andricpublic:
10540b57cec5SDimitry Andric    // types
10550b57cec5SDimitry Andric    typedef _Value                                                     key_type;
10560b57cec5SDimitry Andric    typedef key_type                                                   value_type;
10570b57cec5SDimitry Andric    typedef typename __identity<_Hash>::type                           hasher;
10580b57cec5SDimitry Andric    typedef typename __identity<_Pred>::type                           key_equal;
10590b57cec5SDimitry Andric    typedef typename __identity<_Alloc>::type                          allocator_type;
10600b57cec5SDimitry Andric    typedef value_type&                                                reference;
10610b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
10620b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
10630b57cec5SDimitry Andric                  "Invalid allocator::value_type");
10640b57cec5SDimitry Andric
10650b57cec5SDimitry Andricprivate:
10660b57cec5SDimitry Andric    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
10670b57cec5SDimitry Andric
10680b57cec5SDimitry Andric    __table __table_;
10690b57cec5SDimitry Andric
10700b57cec5SDimitry Andricpublic:
10710b57cec5SDimitry Andric    typedef typename __table::pointer         pointer;
10720b57cec5SDimitry Andric    typedef typename __table::const_pointer   const_pointer;
10730b57cec5SDimitry Andric    typedef typename __table::size_type       size_type;
10740b57cec5SDimitry Andric    typedef typename __table::difference_type difference_type;
10750b57cec5SDimitry Andric
10760b57cec5SDimitry Andric    typedef typename __table::const_iterator       iterator;
10770b57cec5SDimitry Andric    typedef typename __table::const_iterator       const_iterator;
10780b57cec5SDimitry Andric    typedef typename __table::const_local_iterator local_iterator;
10790b57cec5SDimitry Andric    typedef typename __table::const_local_iterator const_local_iterator;
10800b57cec5SDimitry Andric
10810b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
10820b57cec5SDimitry Andric    typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
10830b57cec5SDimitry Andric#endif
10840b57cec5SDimitry Andric
10850b57cec5SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
10860b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_set;
10870b57cec5SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
10880b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
10890b57cec5SDimitry Andric
10900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10910b57cec5SDimitry Andric    unordered_multiset()
10920b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
10930b57cec5SDimitry Andric        {
10940b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
10950b57cec5SDimitry Andric            __get_db()->__insert_c(this);
10960b57cec5SDimitry Andric#endif
10970b57cec5SDimitry Andric        }
10980b57cec5SDimitry Andric    explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
10990b57cec5SDimitry Andric                                const key_equal& __eql = key_equal());
11000b57cec5SDimitry Andric    unordered_multiset(size_type __n, const hasher& __hf,
11010b57cec5SDimitry Andric                       const key_equal& __eql, const allocator_type& __a);
11020b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
11030b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
11040b57cec5SDimitry Andric    unordered_multiset(size_type __n, const allocator_type& __a)
11050b57cec5SDimitry Andric        : unordered_multiset(__n, hasher(), key_equal(), __a) {}
11060b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
11070b57cec5SDimitry Andric    unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
11080b57cec5SDimitry Andric        : unordered_multiset(__n, __hf, key_equal(), __a) {}
11090b57cec5SDimitry Andric#endif
11100b57cec5SDimitry Andric    template <class _InputIterator>
11110b57cec5SDimitry Andric        unordered_multiset(_InputIterator __first, _InputIterator __last);
11120b57cec5SDimitry Andric    template <class _InputIterator>
11130b57cec5SDimitry Andric        unordered_multiset(_InputIterator __first, _InputIterator __last,
11140b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
11150b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
11160b57cec5SDimitry Andric    template <class _InputIterator>
11170b57cec5SDimitry Andric        unordered_multiset(_InputIterator __first, _InputIterator __last,
11180b57cec5SDimitry Andric                      size_type __n , const hasher& __hf,
11190b57cec5SDimitry Andric                      const key_equal& __eql, const allocator_type& __a);
11200b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
11210b57cec5SDimitry Andric    template <class _InputIterator>
11220b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
11230b57cec5SDimitry Andric    unordered_multiset(_InputIterator __first, _InputIterator __last,
11240b57cec5SDimitry Andric                       size_type __n, const allocator_type& __a)
11250b57cec5SDimitry Andric        : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
11260b57cec5SDimitry Andric    template <class _InputIterator>
11270b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
11280b57cec5SDimitry Andric    unordered_multiset(_InputIterator __first, _InputIterator __last,
11290b57cec5SDimitry Andric                       size_type __n, const hasher& __hf, const allocator_type& __a)
11300b57cec5SDimitry Andric        : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
11310b57cec5SDimitry Andric#endif
11320b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11330b57cec5SDimitry Andric    explicit unordered_multiset(const allocator_type& __a);
11340b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset& __u);
11350b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
11360b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
11370b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11380b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&& __u)
11390b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
11400b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
11410b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il);
11420b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n,
11430b57cec5SDimitry Andric                       const hasher& __hf = hasher(),
11440b57cec5SDimitry Andric                       const key_equal& __eql = key_equal());
11450b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n,
11460b57cec5SDimitry Andric                       const hasher& __hf, const key_equal& __eql,
11470b57cec5SDimitry Andric                       const allocator_type& __a);
11480b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
11490b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
11500b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
11510b57cec5SDimitry Andric      : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
11520b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
11530b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
11540b57cec5SDimitry Andric      : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
11550b57cec5SDimitry Andric#endif
11560b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
11570b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11580b57cec5SDimitry Andric    ~unordered_multiset() {
11590b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
11600b57cec5SDimitry Andric    }
11610b57cec5SDimitry Andric
11620b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11630b57cec5SDimitry Andric    unordered_multiset& operator=(const unordered_multiset& __u)
11640b57cec5SDimitry Andric    {
11650b57cec5SDimitry Andric        __table_ = __u.__table_;
11660b57cec5SDimitry Andric        return *this;
11670b57cec5SDimitry Andric    }
11680b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
11690b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11700b57cec5SDimitry Andric    unordered_multiset& operator=(unordered_multiset&& __u)
11710b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
11720b57cec5SDimitry Andric    unordered_multiset& operator=(initializer_list<value_type> __il);
11730b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
11740b57cec5SDimitry Andric
11750b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11760b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
11770b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
11780b57cec5SDimitry Andric
11790b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
11800b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
11810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11820b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
11830b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11840b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
11850b57cec5SDimitry Andric
11860b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11870b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
11880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11890b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
11900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11910b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
11920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11930b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
11940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11950b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
11960b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11970b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
11980b57cec5SDimitry Andric
11990b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
12000b57cec5SDimitry Andric    template <class... _Args>
12010b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12020b57cec5SDimitry Andric        iterator emplace(_Args&&... __args)
12030b57cec5SDimitry Andric            {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
12040b57cec5SDimitry Andric    template <class... _Args>
12050b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12060b57cec5SDimitry Andric        iterator emplace_hint(const_iterator __p, _Args&&... __args)
12070b57cec5SDimitry Andric            {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
12080b57cec5SDimitry Andric
12090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12100b57cec5SDimitry Andric    iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
12110b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12120b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __x)
12130b57cec5SDimitry Andric        {return __table_.__insert_multi(__p, _VSTD::move(__x));}
12140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12150b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
12160b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
12170b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
12180b57cec5SDimitry Andric
12190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12200b57cec5SDimitry Andric    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
12210b57cec5SDimitry Andric
12220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12230b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __x)
12240b57cec5SDimitry Andric        {return __table_.__insert_multi(__p, __x);}
12250b57cec5SDimitry Andric
12260b57cec5SDimitry Andric    template <class _InputIterator>
12270b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12280b57cec5SDimitry Andric        void insert(_InputIterator __first, _InputIterator __last);
12290b57cec5SDimitry Andric
12300b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
12310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12320b57cec5SDimitry Andric    iterator insert(node_type&& __nh)
12330b57cec5SDimitry Andric    {
12340b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
12350b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multiset::insert()");
12360b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
12370b57cec5SDimitry Andric            _VSTD::move(__nh));
12380b57cec5SDimitry Andric    }
12390b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12400b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
12410b57cec5SDimitry Andric    {
12420b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
12430b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multiset::insert()");
12440b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
12450b57cec5SDimitry Andric            __hint, _VSTD::move(__nh));
12460b57cec5SDimitry Andric    }
12470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12480b57cec5SDimitry Andric    node_type extract(const_iterator __position)
12490b57cec5SDimitry Andric    {
12500b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(
12510b57cec5SDimitry Andric            __position);
12520b57cec5SDimitry Andric    }
12530b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12540b57cec5SDimitry Andric    node_type extract(key_type const& __key)
12550b57cec5SDimitry Andric    {
12560b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
12570b57cec5SDimitry Andric    }
12580b57cec5SDimitry Andric
12590b57cec5SDimitry Andric    template <class _H2, class _P2>
12600b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12610b57cec5SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
12620b57cec5SDimitry Andric    {
12630b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
12640b57cec5SDimitry Andric                       "merging container with incompatible allocator");
12650b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
12660b57cec5SDimitry Andric    }
12670b57cec5SDimitry Andric    template <class _H2, class _P2>
12680b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12690b57cec5SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
12700b57cec5SDimitry Andric    {
12710b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
12720b57cec5SDimitry Andric                       "merging container with incompatible allocator");
12730b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
12740b57cec5SDimitry Andric    }
12750b57cec5SDimitry Andric    template <class _H2, class _P2>
12760b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12770b57cec5SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
12780b57cec5SDimitry Andric    {
12790b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
12800b57cec5SDimitry Andric                       "merging container with incompatible allocator");
12810b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
12820b57cec5SDimitry Andric    }
12830b57cec5SDimitry Andric    template <class _H2, class _P2>
12840b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12850b57cec5SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
12860b57cec5SDimitry Andric    {
12870b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
12880b57cec5SDimitry Andric                       "merging container with incompatible allocator");
12890b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
12900b57cec5SDimitry Andric    }
12910b57cec5SDimitry Andric#endif
12920b57cec5SDimitry Andric
12930b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12940b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p);}
12950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12960b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
12970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12980b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
12990b57cec5SDimitry Andric        {return __table_.erase(__first, __last);}
13000b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13010b57cec5SDimitry Andric    void clear() _NOEXCEPT {__table_.clear();}
13020b57cec5SDimitry Andric
13030b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13040b57cec5SDimitry Andric    void swap(unordered_multiset& __u)
13050b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
13060b57cec5SDimitry Andric        {__table_.swap(__u.__table_);}
13070b57cec5SDimitry Andric
13080b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13090b57cec5SDimitry Andric    hasher hash_function() const {return __table_.hash_function();}
13100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13110b57cec5SDimitry Andric    key_equal key_eq() const {return __table_.key_eq();}
13120b57cec5SDimitry Andric
13130b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13140b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
13150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13160b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
13170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13180b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
13190b57cec5SDimitry Andric    #if _LIBCPP_STD_VER > 17
13200b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13210b57cec5SDimitry Andric        bool contains(const key_type& __k) const {return find(__k) != end();}
13220b57cec5SDimitry Andric    #endif // _LIBCPP_STD_VER > 17
13230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13240b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
13250b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
13260b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13270b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
13280b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
13290b57cec5SDimitry Andric
13300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13310b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
13320b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13330b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
13340b57cec5SDimitry Andric
13350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13360b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
13370b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13380b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
13390b57cec5SDimitry Andric
13400b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13410b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
13420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13430b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
13440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13450b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
13460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13470b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
13480b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13490b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
13500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13510b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
13520b57cec5SDimitry Andric
13530b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13540b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
13550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13560b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
13570b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13580b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
13590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13600b57cec5SDimitry Andric    void rehash(size_type __n) {__table_.rehash(__n);}
13610b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13620b57cec5SDimitry Andric    void reserve(size_type __n) {__table_.reserve(__n);}
13630b57cec5SDimitry Andric
13640b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
13650b57cec5SDimitry Andric
13660b57cec5SDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
13670b57cec5SDimitry Andric        {return __table_.__dereferenceable(__i);}
13680b57cec5SDimitry Andric    bool __decrementable(const const_iterator* __i) const
13690b57cec5SDimitry Andric        {return __table_.__decrementable(__i);}
13700b57cec5SDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
13710b57cec5SDimitry Andric        {return __table_.__addable(__i, __n);}
13720b57cec5SDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
13730b57cec5SDimitry Andric        {return __table_.__addable(__i, __n);}
13740b57cec5SDimitry Andric
13750b57cec5SDimitry Andric#endif  // _LIBCPP_DEBUG_LEVEL >= 2
13760b57cec5SDimitry Andric
13770b57cec5SDimitry Andric};
13780b57cec5SDimitry Andric
13790b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
13800b57cec5SDimitry Andrictemplate<class _InputIterator,
13810b57cec5SDimitry Andric         class _Hash = hash<__iter_value_type<_InputIterator>>,
13820b57cec5SDimitry Andric         class _Pred = equal_to<__iter_value_type<_InputIterator>>,
13830b57cec5SDimitry Andric         class _Allocator = allocator<__iter_value_type<_InputIterator>>,
13840b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
13850b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
13860b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
13870b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
13880b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
13890b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
13900b57cec5SDimitry Andric  -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
13910b57cec5SDimitry Andric
13920b57cec5SDimitry Andrictemplate<class _Tp, class _Hash = hash<_Tp>,
13930b57cec5SDimitry Andric         class _Pred = equal_to<_Tp>, class _Allocator = allocator<_Tp>,
13940b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
13950b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
13960b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
13970b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
13980b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0,
13990b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
14000b57cec5SDimitry Andric  -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>;
14010b57cec5SDimitry Andric
14020b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
14030b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
14040b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
14050b57cec5SDimitry Andric  -> unordered_multiset<__iter_value_type<_InputIterator>,
14060b57cec5SDimitry Andric                   hash<__iter_value_type<_InputIterator>>,
14070b57cec5SDimitry Andric                   equal_to<__iter_value_type<_InputIterator>>,
14080b57cec5SDimitry Andric                   _Allocator>;
14090b57cec5SDimitry Andric
14100b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
14110b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
14120b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
14130b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
14140b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type,
14150b57cec5SDimitry Andric              _Hash, _Allocator)
14160b57cec5SDimitry Andric  -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash,
14170b57cec5SDimitry Andric                   equal_to<__iter_value_type<_InputIterator>>,
14180b57cec5SDimitry Andric                   _Allocator>;
14190b57cec5SDimitry Andric
14200b57cec5SDimitry Andrictemplate<class _Tp, class _Allocator,
14210b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
14220b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
14230b57cec5SDimitry Andric  -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
14240b57cec5SDimitry Andric
14250b57cec5SDimitry Andrictemplate<class _Tp, class _Hash, class _Allocator,
14260b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
14270b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
14280b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
14290b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
14300b57cec5SDimitry Andric  -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
14310b57cec5SDimitry Andric#endif
14320b57cec5SDimitry Andric
14330b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14340b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14350b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql)
14360b57cec5SDimitry Andric    : __table_(__hf, __eql)
14370b57cec5SDimitry Andric{
14380b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14390b57cec5SDimitry Andric    __get_db()->__insert_c(this);
14400b57cec5SDimitry Andric#endif
14410b57cec5SDimitry Andric    __table_.rehash(__n);
14420b57cec5SDimitry Andric}
14430b57cec5SDimitry Andric
14440b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14450b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14460b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql,
14470b57cec5SDimitry Andric        const allocator_type& __a)
14480b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
14490b57cec5SDimitry Andric{
14500b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14510b57cec5SDimitry Andric    __get_db()->__insert_c(this);
14520b57cec5SDimitry Andric#endif
14530b57cec5SDimitry Andric    __table_.rehash(__n);
14540b57cec5SDimitry Andric}
14550b57cec5SDimitry Andric
14560b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14570b57cec5SDimitry Andrictemplate <class _InputIterator>
14580b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14590b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
14600b57cec5SDimitry Andric{
14610b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14620b57cec5SDimitry Andric    __get_db()->__insert_c(this);
14630b57cec5SDimitry Andric#endif
14640b57cec5SDimitry Andric    insert(__first, __last);
14650b57cec5SDimitry Andric}
14660b57cec5SDimitry Andric
14670b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14680b57cec5SDimitry Andrictemplate <class _InputIterator>
14690b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14700b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
14710b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
14720b57cec5SDimitry Andric    : __table_(__hf, __eql)
14730b57cec5SDimitry Andric{
14740b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14750b57cec5SDimitry Andric    __get_db()->__insert_c(this);
14760b57cec5SDimitry Andric#endif
14770b57cec5SDimitry Andric    __table_.rehash(__n);
14780b57cec5SDimitry Andric    insert(__first, __last);
14790b57cec5SDimitry Andric}
14800b57cec5SDimitry Andric
14810b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14820b57cec5SDimitry Andrictemplate <class _InputIterator>
14830b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14840b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
14850b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
14860b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
14870b57cec5SDimitry Andric{
14880b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
14890b57cec5SDimitry Andric    __get_db()->__insert_c(this);
14900b57cec5SDimitry Andric#endif
14910b57cec5SDimitry Andric    __table_.rehash(__n);
14920b57cec5SDimitry Andric    insert(__first, __last);
14930b57cec5SDimitry Andric}
14940b57cec5SDimitry Andric
14950b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
14960b57cec5SDimitry Andricinline
14970b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
14980b57cec5SDimitry Andric        const allocator_type& __a)
14990b57cec5SDimitry Andric    : __table_(__a)
15000b57cec5SDimitry Andric{
15010b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
15020b57cec5SDimitry Andric    __get_db()->__insert_c(this);
15030b57cec5SDimitry Andric#endif
15040b57cec5SDimitry Andric}
15050b57cec5SDimitry Andric
15060b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15070b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
15080b57cec5SDimitry Andric        const unordered_multiset& __u)
15090b57cec5SDimitry Andric    : __table_(__u.__table_)
15100b57cec5SDimitry Andric{
15110b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
15120b57cec5SDimitry Andric    __get_db()->__insert_c(this);
15130b57cec5SDimitry Andric#endif
15140b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
15150b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
15160b57cec5SDimitry Andric}
15170b57cec5SDimitry Andric
15180b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15190b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
15200b57cec5SDimitry Andric        const unordered_multiset& __u, const allocator_type& __a)
15210b57cec5SDimitry Andric    : __table_(__u.__table_, __a)
15220b57cec5SDimitry Andric{
15230b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
15240b57cec5SDimitry Andric    __get_db()->__insert_c(this);
15250b57cec5SDimitry Andric#endif
15260b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
15270b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
15280b57cec5SDimitry Andric}
15290b57cec5SDimitry Andric
15300b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
15310b57cec5SDimitry Andric
15320b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15330b57cec5SDimitry Andricinline
15340b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
15350b57cec5SDimitry Andric        unordered_multiset&& __u)
15360b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
15370b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
15380b57cec5SDimitry Andric{
15390b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
15400b57cec5SDimitry Andric    __get_db()->__insert_c(this);
15410b57cec5SDimitry Andric    __get_db()->swap(this, &__u);
15420b57cec5SDimitry Andric#endif
15430b57cec5SDimitry Andric}
15440b57cec5SDimitry Andric
15450b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15460b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
15470b57cec5SDimitry Andric        unordered_multiset&& __u, const allocator_type& __a)
15480b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), __a)
15490b57cec5SDimitry Andric{
15500b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
15510b57cec5SDimitry Andric    __get_db()->__insert_c(this);
15520b57cec5SDimitry Andric#endif
15530b57cec5SDimitry Andric    if (__a != __u.get_allocator())
15540b57cec5SDimitry Andric    {
15550b57cec5SDimitry Andric        iterator __i = __u.begin();
15560b57cec5SDimitry Andric        while (__u.size() != 0)
15570b57cec5SDimitry Andric            __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
15580b57cec5SDimitry Andric    }
15590b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
15600b57cec5SDimitry Andric    else
15610b57cec5SDimitry Andric        __get_db()->swap(this, &__u);
15620b57cec5SDimitry Andric#endif
15630b57cec5SDimitry Andric}
15640b57cec5SDimitry Andric
15650b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15660b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
15670b57cec5SDimitry Andric        initializer_list<value_type> __il)
15680b57cec5SDimitry Andric{
15690b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
15700b57cec5SDimitry Andric    __get_db()->__insert_c(this);
15710b57cec5SDimitry Andric#endif
15720b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
15730b57cec5SDimitry Andric}
15740b57cec5SDimitry Andric
15750b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15760b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
15770b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
15780b57cec5SDimitry Andric        const key_equal& __eql)
15790b57cec5SDimitry Andric    : __table_(__hf, __eql)
15800b57cec5SDimitry Andric{
15810b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
15820b57cec5SDimitry Andric    __get_db()->__insert_c(this);
15830b57cec5SDimitry Andric#endif
15840b57cec5SDimitry Andric    __table_.rehash(__n);
15850b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
15860b57cec5SDimitry Andric}
15870b57cec5SDimitry Andric
15880b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
15890b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
15900b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
15910b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
15920b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
15930b57cec5SDimitry Andric{
15940b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
15950b57cec5SDimitry Andric    __get_db()->__insert_c(this);
15960b57cec5SDimitry Andric#endif
15970b57cec5SDimitry Andric    __table_.rehash(__n);
15980b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
15990b57cec5SDimitry Andric}
16000b57cec5SDimitry Andric
16010b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16020b57cec5SDimitry Andricinline
16030b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>&
16040b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
16050b57cec5SDimitry Andric        unordered_multiset&& __u)
16060b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
16070b57cec5SDimitry Andric{
16080b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
16090b57cec5SDimitry Andric    return *this;
16100b57cec5SDimitry Andric}
16110b57cec5SDimitry Andric
16120b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16130b57cec5SDimitry Andricinline
16140b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>&
16150b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
16160b57cec5SDimitry Andric        initializer_list<value_type> __il)
16170b57cec5SDimitry Andric{
16180b57cec5SDimitry Andric    __table_.__assign_multi(__il.begin(), __il.end());
16190b57cec5SDimitry Andric    return *this;
16200b57cec5SDimitry Andric}
16210b57cec5SDimitry Andric
16220b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
16230b57cec5SDimitry Andric
16240b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16250b57cec5SDimitry Andrictemplate <class _InputIterator>
16260b57cec5SDimitry Andricinline
16270b57cec5SDimitry Andricvoid
16280b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
16290b57cec5SDimitry Andric                                                         _InputIterator __last)
16300b57cec5SDimitry Andric{
16310b57cec5SDimitry Andric    for (; __first != __last; ++__first)
16320b57cec5SDimitry Andric        __table_.__insert_multi(*__first);
16330b57cec5SDimitry Andric}
16340b57cec5SDimitry Andric
16350b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16360b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16370b57cec5SDimitry Andricvoid
16380b57cec5SDimitry Andricswap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
16390b57cec5SDimitry Andric     unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
16400b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
16410b57cec5SDimitry Andric{
16420b57cec5SDimitry Andric    __x.swap(__y);
16430b57cec5SDimitry Andric}
16440b57cec5SDimitry Andric
16450b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
1646*5ffd83dbSDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc,
1647*5ffd83dbSDimitry Andric          class _Predicate>
16480b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1649*5ffd83dbSDimitry Andric    typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type
1650*5ffd83dbSDimitry Andric    erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c,
1651*5ffd83dbSDimitry Andric             _Predicate __pred) {
1652*5ffd83dbSDimitry Andric  return __libcpp_erase_if_container(__c, __pred);
1653*5ffd83dbSDimitry Andric}
16540b57cec5SDimitry Andric#endif
16550b57cec5SDimitry Andric
16560b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16570b57cec5SDimitry Andricbool
16580b57cec5SDimitry Andricoperator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
16590b57cec5SDimitry Andric           const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
16600b57cec5SDimitry Andric{
16610b57cec5SDimitry Andric    if (__x.size() != __y.size())
16620b57cec5SDimitry Andric        return false;
16630b57cec5SDimitry Andric    typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
16640b57cec5SDimitry Andric                                                                 const_iterator;
16650b57cec5SDimitry Andric    typedef pair<const_iterator, const_iterator> _EqRng;
16660b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
16670b57cec5SDimitry Andric    {
16680b57cec5SDimitry Andric        _EqRng __xeq = __x.equal_range(*__i);
16690b57cec5SDimitry Andric        _EqRng __yeq = __y.equal_range(*__i);
16700b57cec5SDimitry Andric        if (_VSTD::distance(__xeq.first, __xeq.second) !=
16710b57cec5SDimitry Andric            _VSTD::distance(__yeq.first, __yeq.second) ||
16720b57cec5SDimitry Andric                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
16730b57cec5SDimitry Andric            return false;
16740b57cec5SDimitry Andric        __i = __xeq.second;
16750b57cec5SDimitry Andric    }
16760b57cec5SDimitry Andric    return true;
16770b57cec5SDimitry Andric}
16780b57cec5SDimitry Andric
16790b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
16800b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
16810b57cec5SDimitry Andricbool
16820b57cec5SDimitry Andricoperator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
16830b57cec5SDimitry Andric           const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
16840b57cec5SDimitry Andric{
16850b57cec5SDimitry Andric    return !(__x == __y);
16860b57cec5SDimitry Andric}
16870b57cec5SDimitry Andric
16880b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
16890b57cec5SDimitry Andric
16900b57cec5SDimitry Andric#endif  // _LIBCPP_UNORDERED_SET
1691