xref: /freebsd/contrib/llvm-project/libcxx/include/unordered_map (revision cb14a3fe5122c879eae1fb480ed7ce82a699ddb6)
10b57cec5SDimitry Andric// -*- C++ -*-
2349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_UNORDERED_MAP
110b57cec5SDimitry Andric#define _LIBCPP_UNORDERED_MAP
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric
150b57cec5SDimitry Andric    unordered_map synopsis
160b57cec5SDimitry Andric
170b57cec5SDimitry Andric#include <initializer_list>
180b57cec5SDimitry Andric
190b57cec5SDimitry Andricnamespace std
200b57cec5SDimitry Andric{
210b57cec5SDimitry Andric
220b57cec5SDimitry Andrictemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
230b57cec5SDimitry Andric          class Alloc = allocator<pair<const Key, T>>>
240b57cec5SDimitry Andricclass unordered_map
250b57cec5SDimitry Andric{
260b57cec5SDimitry Andricpublic:
270b57cec5SDimitry Andric    // types
280b57cec5SDimitry Andric    typedef Key                                                        key_type;
290b57cec5SDimitry Andric    typedef T                                                          mapped_type;
300b57cec5SDimitry Andric    typedef Hash                                                       hasher;
310b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
320b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
330b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>                          value_type;
340b57cec5SDimitry Andric    typedef value_type&                                                reference;
350b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
360b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
370b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
380b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
390b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
400b57cec5SDimitry Andric
410b57cec5SDimitry Andric    typedef /unspecified/ iterator;
420b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
430b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
440b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
450b57cec5SDimitry Andric
460b57cec5SDimitry Andric    typedef unspecified                             node_type;            // C++17
470b57cec5SDimitry Andric    typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type;   // C++17
480b57cec5SDimitry Andric
490b57cec5SDimitry Andric    unordered_map()
500b57cec5SDimitry Andric        noexcept(
510b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
520b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
530b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
540b57cec5SDimitry Andric    explicit unordered_map(size_type n, const hasher& hf = hasher(),
550b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
560b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
570b57cec5SDimitry Andric    template <class InputIterator>
580b57cec5SDimitry Andric        unordered_map(InputIterator f, InputIterator l,
590b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
600b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
610b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
6206c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
6306c3fb27SDimitry Andric      unordered_map(from_range_t, R&& rg, size_type n = see below,
6406c3fb27SDimitry Andric        const hasher& hf = hasher(), const key_equal& eql = key_equal(),
6506c3fb27SDimitry Andric        const allocator_type& a = allocator_type()); // C++23
6606c3fb27SDimitry Andric
670b57cec5SDimitry Andric    explicit unordered_map(const allocator_type&);
680b57cec5SDimitry Andric    unordered_map(const unordered_map&);
690b57cec5SDimitry Andric    unordered_map(const unordered_map&, const Allocator&);
700b57cec5SDimitry Andric    unordered_map(unordered_map&&)
710b57cec5SDimitry Andric        noexcept(
720b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
730b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
740b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
750b57cec5SDimitry Andric    unordered_map(unordered_map&&, const Allocator&);
760b57cec5SDimitry Andric    unordered_map(initializer_list<value_type>, size_type n = 0,
770b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
780b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
790b57cec5SDimitry Andric    unordered_map(size_type n, const allocator_type& a)
800b57cec5SDimitry Andric      : unordered_map(n, hasher(), key_equal(), a) {}  // C++14
810b57cec5SDimitry Andric    unordered_map(size_type n, const hasher& hf, const allocator_type& a)
820b57cec5SDimitry Andric      : unordered_map(n, hf, key_equal(), a) {}  // C++14
830b57cec5SDimitry Andric    template <class InputIterator>
840b57cec5SDimitry Andric      unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
850b57cec5SDimitry Andric      : unordered_map(f, l, n, hasher(), key_equal(), a) {}  // C++14
860b57cec5SDimitry Andric    template <class InputIterator>
870b57cec5SDimitry Andric      unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
880b57cec5SDimitry Andric        const allocator_type& a)
890b57cec5SDimitry Andric      : unordered_map(f, l, n, hf, key_equal(), a) {}  // C++14
9006c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
9106c3fb27SDimitry Andric      unordered_map(from_range_t, R&& rg, size_type n, const allocator_type& a)
9206c3fb27SDimitry Andric        : unordered_map(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
9306c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
9406c3fb27SDimitry Andric      unordered_map(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
9506c3fb27SDimitry Andric        : unordered_map(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }       // C++23
960b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
970b57cec5SDimitry Andric      : unordered_map(il, n, hasher(), key_equal(), a) {}  // C++14
980b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
990b57cec5SDimitry Andric      const allocator_type& a)
1000b57cec5SDimitry Andric      : unordered_map(il, n, hf, key_equal(), a) {}  // C++14
1010b57cec5SDimitry Andric    ~unordered_map();
1020b57cec5SDimitry Andric    unordered_map& operator=(const unordered_map&);
1030b57cec5SDimitry Andric    unordered_map& operator=(unordered_map&&)
1040b57cec5SDimitry Andric        noexcept(
1050b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
1060b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
1070b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
1080b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
1090b57cec5SDimitry Andric    unordered_map& operator=(initializer_list<value_type>);
1100b57cec5SDimitry Andric
1110b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
1120b57cec5SDimitry Andric
1130b57cec5SDimitry Andric    bool      empty() const noexcept;
1140b57cec5SDimitry Andric    size_type size() const noexcept;
1150b57cec5SDimitry Andric    size_type max_size() const noexcept;
1160b57cec5SDimitry Andric
1170b57cec5SDimitry Andric    iterator       begin() noexcept;
1180b57cec5SDimitry Andric    iterator       end() noexcept;
1190b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
1200b57cec5SDimitry Andric    const_iterator end()    const noexcept;
1210b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
1220b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
1230b57cec5SDimitry Andric
1240b57cec5SDimitry Andric    template <class... Args>
1250b57cec5SDimitry Andric        pair<iterator, bool> emplace(Args&&... args);
1260b57cec5SDimitry Andric    template <class... Args>
1270b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
1280b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& obj);
1290b57cec5SDimitry Andric    template <class P>
1300b57cec5SDimitry Andric        pair<iterator, bool> insert(P&& obj);
1310b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
1320b57cec5SDimitry Andric    template <class P>
1330b57cec5SDimitry Andric        iterator insert(const_iterator hint, P&& obj);
1340b57cec5SDimitry Andric    template <class InputIterator>
1350b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
13606c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
13706c3fb27SDimitry Andric      void insert_range(R&& rg);                                                      // C++23
1380b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
1390b57cec5SDimitry Andric
1400b57cec5SDimitry Andric    node_type extract(const_iterator position);                                       // C++17
1410b57cec5SDimitry Andric    node_type extract(const key_type& x);                                             // C++17
1420b57cec5SDimitry Andric    insert_return_type insert(node_type&& nh);                                        // C++17
1430b57cec5SDimitry Andric    iterator           insert(const_iterator hint, node_type&& nh);                   // C++17
1440b57cec5SDimitry Andric
1450b57cec5SDimitry Andric    template <class... Args>
1460b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);          // C++17
1470b57cec5SDimitry Andric    template <class... Args>
1480b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);               // C++17
1490b57cec5SDimitry Andric    template <class... Args>
1500b57cec5SDimitry Andric        iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
1510b57cec5SDimitry Andric    template <class... Args>
1520b57cec5SDimitry Andric        iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);      // C++17
1530b57cec5SDimitry Andric    template <class M>
1540b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);            // C++17
1550b57cec5SDimitry Andric    template <class M>
1560b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);                 // C++17
1570b57cec5SDimitry Andric    template <class M>
1580b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);   // C++17
1590b57cec5SDimitry Andric    template <class M>
1600b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);        // C++17
1610b57cec5SDimitry Andric
1620b57cec5SDimitry Andric    iterator erase(const_iterator position);
1630b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
1640b57cec5SDimitry Andric    size_type erase(const key_type& k);
1650b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
1660b57cec5SDimitry Andric    void clear() noexcept;
1670b57cec5SDimitry Andric
1680b57cec5SDimitry Andric    template<class H2, class P2>
1690b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>& source);         // C++17
1700b57cec5SDimitry Andric    template<class H2, class P2>
1710b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>&& source);        // C++17
1720b57cec5SDimitry Andric    template<class H2, class P2>
1730b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source);    // C++17
1740b57cec5SDimitry Andric    template<class H2, class P2>
1750b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source);   // C++17
1760b57cec5SDimitry Andric
1770b57cec5SDimitry Andric    void swap(unordered_map&)
1780b57cec5SDimitry Andric        noexcept(
1790b57cec5SDimitry Andric            (!allocator_type::propagate_on_container_swap::value ||
1800b57cec5SDimitry Andric             __is_nothrow_swappable<allocator_type>::value) &&
1810b57cec5SDimitry Andric            __is_nothrow_swappable<hasher>::value &&
1820b57cec5SDimitry Andric            __is_nothrow_swappable<key_equal>::value);
1830b57cec5SDimitry Andric
1840b57cec5SDimitry Andric    hasher hash_function() const;
1850b57cec5SDimitry Andric    key_equal key_eq() const;
1860b57cec5SDimitry Andric
1870b57cec5SDimitry Andric    iterator       find(const key_type& k);
1880b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
189e8d8bef9SDimitry Andric    template<typename K>
190e8d8bef9SDimitry Andric        iterator find(const K& x);              // C++20
191e8d8bef9SDimitry Andric    template<typename K>
192e8d8bef9SDimitry Andric        const_iterator find(const K& x) const;  // C++20
1930b57cec5SDimitry Andric    size_type count(const key_type& k) const;
194e8d8bef9SDimitry Andric    template<typename K>
195e8d8bef9SDimitry Andric        size_type count(const K& k) const; // C++20
1960b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
197e8d8bef9SDimitry Andric    template<typename K>
198e8d8bef9SDimitry Andric        bool contains(const K& k) const; // C++20
1990b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
2000b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
201e8d8bef9SDimitry Andric    template<typename K>
202e8d8bef9SDimitry Andric        pair<iterator, iterator>             equal_range(const K& k); // C++20
203e8d8bef9SDimitry Andric    template<typename K>
204e8d8bef9SDimitry Andric        pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
2050b57cec5SDimitry Andric
2060b57cec5SDimitry Andric    mapped_type& operator[](const key_type& k);
2070b57cec5SDimitry Andric    mapped_type& operator[](key_type&& k);
2080b57cec5SDimitry Andric
2090b57cec5SDimitry Andric    mapped_type&       at(const key_type& k);
2100b57cec5SDimitry Andric    const mapped_type& at(const key_type& k) const;
2110b57cec5SDimitry Andric
2120b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
2130b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
2140b57cec5SDimitry Andric
2150b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
2160b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
2170b57cec5SDimitry Andric
2180b57cec5SDimitry Andric    local_iterator       begin(size_type n);
2190b57cec5SDimitry Andric    local_iterator       end(size_type n);
2200b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
2210b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
2220b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
2230b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
2240b57cec5SDimitry Andric
2250b57cec5SDimitry Andric    float load_factor() const noexcept;
2260b57cec5SDimitry Andric    float max_load_factor() const noexcept;
2270b57cec5SDimitry Andric    void max_load_factor(float z);
2280b57cec5SDimitry Andric    void rehash(size_type n);
2290b57cec5SDimitry Andric    void reserve(size_type n);
2300b57cec5SDimitry Andric};
2310b57cec5SDimitry Andric
232349cc55cSDimitry Andrictemplate<class InputIterator,
233349cc55cSDimitry Andric    class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>,
234349cc55cSDimitry Andric    class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
235349cc55cSDimitry Andricunordered_map(InputIterator, InputIterator, typename see below::size_type = see below,
236349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
237349cc55cSDimitry Andric  -> unordered_map<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred,
238349cc55cSDimitry Andric    Allocator>; // C++17
239349cc55cSDimitry Andric
24006c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash = hash<range-key-type<R>>,
24106c3fb27SDimitry Andric         class Pred = equal_to<range-key-type<R>>,
24206c3fb27SDimitry Andric         class Allocator = allocator<range-to-alloc-type<R>>>
24306c3fb27SDimitry Andric  unordered_map(from_range_t, R&&, typename see below::size_type = see below,
24406c3fb27SDimitry Andric                Hash = Hash(), Pred = Pred(), Allocator = Allocator())
24506c3fb27SDimitry Andric    -> unordered_map<range-key-type<R>, range-mapped-type<R>, Hash, Pred, Allocator>; // C++23
24606c3fb27SDimitry Andric
247349cc55cSDimitry Andrictemplate<class Key, class T, class Hash = hash<Key>,
248349cc55cSDimitry Andric    class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>
249349cc55cSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type = see below,
250349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
251349cc55cSDimitry Andric  -> unordered_map<Key, T, Hash, Pred, Allocator>; // C++17
252349cc55cSDimitry Andric
253349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
254349cc55cSDimitry Andricunordered_map(InputIterator, InputIterator, typename see below::size_type, Allocator)
255349cc55cSDimitry Andric  -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
256349cc55cSDimitry Andric        hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
257349cc55cSDimitry Andric
258349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
259349cc55cSDimitry Andricunordered_map(InputIterator, InputIterator, Allocator)
260349cc55cSDimitry Andric  -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
261349cc55cSDimitry Andric        hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
262349cc55cSDimitry Andric
263349cc55cSDimitry Andrictemplate<class InputIterator, class Hash, class Allocator>
264349cc55cSDimitry Andricunordered_map(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator)
265349cc55cSDimitry Andric  -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash,
266349cc55cSDimitry Andric          equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
267349cc55cSDimitry Andric
26806c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
26906c3fb27SDimitry Andric  unordered_map(from_range_t, R&&, typename see below::size_type, Allocator)
27006c3fb27SDimitry Andric    -> unordered_map<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
27106c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
27206c3fb27SDimitry Andric
27306c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
27406c3fb27SDimitry Andric  unordered_map(from_range_t, R&&, Allocator)
27506c3fb27SDimitry Andric    -> unordered_map<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
27606c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
27706c3fb27SDimitry Andric
27806c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator>
27906c3fb27SDimitry Andric  unordered_map(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
28006c3fb27SDimitry Andric    -> unordered_map<range-key-type<R>, range-mapped-type<R>, Hash,
28106c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
28206c3fb27SDimitry Andric
283349cc55cSDimitry Andrictemplate<class Key, class T, typename Allocator>
284349cc55cSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator)
285349cc55cSDimitry Andric  -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
286349cc55cSDimitry Andric
287349cc55cSDimitry Andrictemplate<class Key, class T, typename Allocator>
288349cc55cSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, Allocator)
289349cc55cSDimitry Andric  -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
290349cc55cSDimitry Andric
291349cc55cSDimitry Andrictemplate<class Key, class T, class Hash, class Allocator>
292349cc55cSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash, Allocator)
293349cc55cSDimitry Andric  -> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>; // C++17
294349cc55cSDimitry Andric
2950b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
2960b57cec5SDimitry Andric    void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
2970b57cec5SDimitry Andric              unordered_map<Key, T, Hash, Pred, Alloc>& y)
2980b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
2990b57cec5SDimitry Andric
3000b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
3010b57cec5SDimitry Andric    bool
3020b57cec5SDimitry Andric    operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
3030b57cec5SDimitry Andric               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
3040b57cec5SDimitry Andric
3050b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
3060b57cec5SDimitry Andric    bool
3070b57cec5SDimitry Andric    operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
30806c3fb27SDimitry Andric               const unordered_map<Key, T, Hash, Pred, Alloc>& y); // Removed in C++20
3090b57cec5SDimitry Andric
3100b57cec5SDimitry Andrictemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
3110b57cec5SDimitry Andric          class Alloc = allocator<pair<const Key, T>>>
3120b57cec5SDimitry Andricclass unordered_multimap
3130b57cec5SDimitry Andric{
3140b57cec5SDimitry Andricpublic:
3150b57cec5SDimitry Andric    // types
3160b57cec5SDimitry Andric    typedef Key                                                        key_type;
3170b57cec5SDimitry Andric    typedef T                                                          mapped_type;
3180b57cec5SDimitry Andric    typedef Hash                                                       hasher;
3190b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
3200b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
3210b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>                          value_type;
3220b57cec5SDimitry Andric    typedef value_type&                                                reference;
3230b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
3240b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
3250b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
3260b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
3270b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
3280b57cec5SDimitry Andric
3290b57cec5SDimitry Andric    typedef /unspecified/ iterator;
3300b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
3310b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
3320b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
3330b57cec5SDimitry Andric
3340b57cec5SDimitry Andric    typedef unspecified node_type;    // C++17
3350b57cec5SDimitry Andric
3360b57cec5SDimitry Andric    unordered_multimap()
3370b57cec5SDimitry Andric        noexcept(
3380b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
3390b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
3400b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
3410b57cec5SDimitry Andric    explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
3420b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
3430b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
3440b57cec5SDimitry Andric    template <class InputIterator>
3450b57cec5SDimitry Andric        unordered_multimap(InputIterator f, InputIterator l,
3460b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
3470b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
3480b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
34906c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
35006c3fb27SDimitry Andric      unordered_multimap(from_range_t, R&& rg, size_type n = see below,
35106c3fb27SDimitry Andric        const hasher& hf = hasher(), const key_equal& eql = key_equal(),
35206c3fb27SDimitry Andric        const allocator_type& a = allocator_type()); // C++23
3530b57cec5SDimitry Andric    explicit unordered_multimap(const allocator_type&);
3540b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap&);
3550b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap&, const Allocator&);
3560b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&&)
3570b57cec5SDimitry Andric        noexcept(
3580b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
3590b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
3600b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
3610b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&&, const Allocator&);
3620b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type>, size_type n = 0,
3630b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
3640b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
3650b57cec5SDimitry Andric    unordered_multimap(size_type n, const allocator_type& a)
3660b57cec5SDimitry Andric      : unordered_multimap(n, hasher(), key_equal(), a) {}  // C++14
3670b57cec5SDimitry Andric    unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
3680b57cec5SDimitry Andric      : unordered_multimap(n, hf, key_equal(), a) {}  // C++14
3690b57cec5SDimitry Andric    template <class InputIterator>
3700b57cec5SDimitry Andric      unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
3710b57cec5SDimitry Andric      : unordered_multimap(f, l, n, hasher(), key_equal(), a) {}  // C++14
3720b57cec5SDimitry Andric    template <class InputIterator>
3730b57cec5SDimitry Andric      unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
3740b57cec5SDimitry Andric        const allocator_type& a)
3750b57cec5SDimitry Andric      : unordered_multimap(f, l, n, hf, key_equal(), a) {}  // C++14
37606c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
37706c3fb27SDimitry Andric      unordered_multimap(from_range_t, R&& rg, size_type n, const allocator_type& a)
37806c3fb27SDimitry Andric        : unordered_multimap(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
37906c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
38006c3fb27SDimitry Andric      unordered_multimap(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
38106c3fb27SDimitry Andric        : unordered_multimap(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }       // C++23
3820b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
3830b57cec5SDimitry Andric      : unordered_multimap(il, n, hasher(), key_equal(), a) {}  // C++14
3840b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
3850b57cec5SDimitry Andric      const allocator_type& a)
3860b57cec5SDimitry Andric      : unordered_multimap(il, n, hf, key_equal(), a) {}  // C++14
3870b57cec5SDimitry Andric    ~unordered_multimap();
3880b57cec5SDimitry Andric    unordered_multimap& operator=(const unordered_multimap&);
3890b57cec5SDimitry Andric    unordered_multimap& operator=(unordered_multimap&&)
3900b57cec5SDimitry Andric        noexcept(
3910b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
3920b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
3930b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
3940b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
3950b57cec5SDimitry Andric    unordered_multimap& operator=(initializer_list<value_type>);
3960b57cec5SDimitry Andric
3970b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
3980b57cec5SDimitry Andric
3990b57cec5SDimitry Andric    bool      empty() const noexcept;
4000b57cec5SDimitry Andric    size_type size() const noexcept;
4010b57cec5SDimitry Andric    size_type max_size() const noexcept;
4020b57cec5SDimitry Andric
4030b57cec5SDimitry Andric    iterator       begin() noexcept;
4040b57cec5SDimitry Andric    iterator       end() noexcept;
4050b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
4060b57cec5SDimitry Andric    const_iterator end()    const noexcept;
4070b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
4080b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
4090b57cec5SDimitry Andric
4100b57cec5SDimitry Andric    template <class... Args>
4110b57cec5SDimitry Andric        iterator emplace(Args&&... args);
4120b57cec5SDimitry Andric    template <class... Args>
4130b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
4140b57cec5SDimitry Andric    iterator insert(const value_type& obj);
4150b57cec5SDimitry Andric    template <class P>
4160b57cec5SDimitry Andric        iterator insert(P&& obj);
4170b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
4180b57cec5SDimitry Andric    template <class P>
4190b57cec5SDimitry Andric        iterator insert(const_iterator hint, P&& obj);
4200b57cec5SDimitry Andric    template <class InputIterator>
4210b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
42206c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
42306c3fb27SDimitry Andric      void insert_range(R&& rg);                               // C++23
4240b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
4250b57cec5SDimitry Andric
4260b57cec5SDimitry Andric    node_type extract(const_iterator position);                // C++17
4270b57cec5SDimitry Andric    node_type extract(const key_type& x);                      // C++17
4280b57cec5SDimitry Andric    iterator insert(node_type&& nh);                           // C++17
4290b57cec5SDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);      // C++17
4300b57cec5SDimitry Andric
4310b57cec5SDimitry Andric    iterator erase(const_iterator position);
4320b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
4330b57cec5SDimitry Andric    size_type erase(const key_type& k);
4340b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
4350b57cec5SDimitry Andric    void clear() noexcept;
4360b57cec5SDimitry Andric
4370b57cec5SDimitry Andric    template<class H2, class P2>
4380b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source);    // C++17
4390b57cec5SDimitry Andric    template<class H2, class P2>
4400b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source);   // C++17
4410b57cec5SDimitry Andric    template<class H2, class P2>
4420b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>& source);         // C++17
4430b57cec5SDimitry Andric    template<class H2, class P2>
4440b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>&& source);        // C++17
4450b57cec5SDimitry Andric
4460b57cec5SDimitry Andric    void swap(unordered_multimap&)
4470b57cec5SDimitry Andric        noexcept(
4480b57cec5SDimitry Andric            (!allocator_type::propagate_on_container_swap::value ||
4490b57cec5SDimitry Andric             __is_nothrow_swappable<allocator_type>::value) &&
4500b57cec5SDimitry Andric            __is_nothrow_swappable<hasher>::value &&
4510b57cec5SDimitry Andric            __is_nothrow_swappable<key_equal>::value);
4520b57cec5SDimitry Andric
4530b57cec5SDimitry Andric    hasher hash_function() const;
4540b57cec5SDimitry Andric    key_equal key_eq() const;
4550b57cec5SDimitry Andric
4560b57cec5SDimitry Andric    iterator       find(const key_type& k);
4570b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
458e8d8bef9SDimitry Andric    template<typename K>
459e8d8bef9SDimitry Andric        iterator find(const K& x);              // C++20
460e8d8bef9SDimitry Andric    template<typename K>
461e8d8bef9SDimitry Andric        const_iterator find(const K& x) const;  // C++20
4620b57cec5SDimitry Andric    size_type count(const key_type& k) const;
463e8d8bef9SDimitry Andric    template<typename K>
464e8d8bef9SDimitry Andric        size_type count(const K& k) const; // C++20
4650b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
466e8d8bef9SDimitry Andric    template<typename K>
467e8d8bef9SDimitry Andric        bool contains(const K& k) const; // C++20
4680b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
4690b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
470e8d8bef9SDimitry Andric    template<typename K>
471e8d8bef9SDimitry Andric        pair<iterator, iterator>             equal_range(const K& k); // C++20
472e8d8bef9SDimitry Andric    template<typename K>
473e8d8bef9SDimitry Andric        pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
4740b57cec5SDimitry Andric
4750b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
4760b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
4770b57cec5SDimitry Andric
4780b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
4790b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
4800b57cec5SDimitry Andric
4810b57cec5SDimitry Andric    local_iterator       begin(size_type n);
4820b57cec5SDimitry Andric    local_iterator       end(size_type n);
4830b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
4840b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
4850b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
4860b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
4870b57cec5SDimitry Andric
4880b57cec5SDimitry Andric    float load_factor() const noexcept;
4890b57cec5SDimitry Andric    float max_load_factor() const noexcept;
4900b57cec5SDimitry Andric    void max_load_factor(float z);
4910b57cec5SDimitry Andric    void rehash(size_type n);
4920b57cec5SDimitry Andric    void reserve(size_type n);
4930b57cec5SDimitry Andric};
4940b57cec5SDimitry Andric
495349cc55cSDimitry Andrictemplate<class InputIterator,
496349cc55cSDimitry Andric    class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>,
497349cc55cSDimitry Andric    class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
498349cc55cSDimitry Andricunordered_multimap(InputIterator, InputIterator, typename see below::size_type = see below,
499349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
500349cc55cSDimitry Andric  -> unordered_multimap<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred,
501349cc55cSDimitry Andric    Allocator>; // C++17
502349cc55cSDimitry Andric
50306c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash = hash<range-key-type<R>>,
50406c3fb27SDimitry Andric         class Pred = equal_to<range-key-type<R>>,
50506c3fb27SDimitry Andric         class Allocator = allocator<range-to-alloc-type<R>>>
50606c3fb27SDimitry Andric  unordered_multimap(from_range_t, R&&, typename see below::size_type = see below,
50706c3fb27SDimitry Andric                Hash = Hash(), Pred = Pred(), Allocator = Allocator())
50806c3fb27SDimitry Andric    -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, Hash, Pred, Allocator>; // C++23
50906c3fb27SDimitry Andric
510349cc55cSDimitry Andrictemplate<class Key, class T, class Hash = hash<Key>,
511349cc55cSDimitry Andric    class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>
512349cc55cSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type = see below,
513349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
514349cc55cSDimitry Andric  -> unordered_multimap<Key, T, Hash, Pred, Allocator>; // C++17
515349cc55cSDimitry Andric
516349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
517349cc55cSDimitry Andricunordered_multimap(InputIterator, InputIterator, typename see below::size_type, Allocator)
518349cc55cSDimitry Andric  -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
519349cc55cSDimitry Andric        hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
520349cc55cSDimitry Andric
521349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
522349cc55cSDimitry Andricunordered_multimap(InputIterator, InputIterator, Allocator)
523349cc55cSDimitry Andric  -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
524349cc55cSDimitry Andric        hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
525349cc55cSDimitry Andric
526349cc55cSDimitry Andrictemplate<class InputIterator, class Hash, class Allocator>
527349cc55cSDimitry Andricunordered_multimap(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator)
528349cc55cSDimitry Andric  -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash,
529349cc55cSDimitry Andric          equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
530349cc55cSDimitry Andric
53106c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
53206c3fb27SDimitry Andric  unordered_multimap(from_range_t, R&&, typename see below::size_type, Allocator)
53306c3fb27SDimitry Andric    -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
53406c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
53506c3fb27SDimitry Andric
53606c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
53706c3fb27SDimitry Andric  unordered_multimap(from_range_t, R&&, Allocator)
53806c3fb27SDimitry Andric    -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
53906c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
54006c3fb27SDimitry Andric
54106c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator>
54206c3fb27SDimitry Andric  unordered_multimap(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
54306c3fb27SDimitry Andric    -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, Hash,
54406c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
54506c3fb27SDimitry Andric
546349cc55cSDimitry Andrictemplate<class Key, class T, typename Allocator>
547349cc55cSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator)
548349cc55cSDimitry Andric  -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
549349cc55cSDimitry Andric
550349cc55cSDimitry Andrictemplate<class Key, class T, typename Allocator>
551349cc55cSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, Allocator)
552349cc55cSDimitry Andric  -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
553349cc55cSDimitry Andric
554349cc55cSDimitry Andrictemplate<class Key, class T, class Hash, class Allocator>
555349cc55cSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash,
556349cc55cSDimitry Andric    Allocator)
557349cc55cSDimitry Andric  -> unordered_multimap<Key, T, Hash, equal_to<Key>, Allocator>; // C++17
558349cc55cSDimitry Andric
5590b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
5600b57cec5SDimitry Andric    void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
5610b57cec5SDimitry Andric              unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
5620b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
5630b57cec5SDimitry Andric
5640b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
5655ffd83dbSDimitry Andric    typename unordered_map<K, T, H, P, A>::size_type
5665ffd83dbSDimitry Andric    erase_if(unordered_map<K, T, H, P, A>& c, Predicate pred);       // C++20
5670b57cec5SDimitry Andric
5680b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
5695ffd83dbSDimitry Andric    typename unordered_multimap<K, T, H, P, A>::size_type
5705ffd83dbSDimitry Andric    erase_if(unordered_multimap<K, T, H, P, A>& c, Predicate pred);  // C++20
5710b57cec5SDimitry Andric
5720b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
5730b57cec5SDimitry Andric    bool
5740b57cec5SDimitry Andric    operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
5750b57cec5SDimitry Andric               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
5760b57cec5SDimitry Andric
5770b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
5780b57cec5SDimitry Andric    bool
5790b57cec5SDimitry Andric    operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
58006c3fb27SDimitry Andric               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y); // Removed in C++20
5810b57cec5SDimitry Andric
5820b57cec5SDimitry Andric}  // std
5830b57cec5SDimitry Andric
5840b57cec5SDimitry Andric*/
5850b57cec5SDimitry Andric
58681ad6265SDimitry Andric#include <__algorithm/is_permutation.h>
58781ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler
58806c3fb27SDimitry Andric#include <__availability>
5890b57cec5SDimitry Andric#include <__config>
590fe6060f1SDimitry Andric#include <__functional/is_transparent.h>
59181ad6265SDimitry Andric#include <__functional/operations.h>
5920b57cec5SDimitry Andric#include <__hash_table>
59381ad6265SDimitry Andric#include <__iterator/distance.h>
59481ad6265SDimitry Andric#include <__iterator/erase_if_container.h>
59504eeddc0SDimitry Andric#include <__iterator/iterator_traits.h>
59606c3fb27SDimitry Andric#include <__iterator/ranges_iterator_traits.h>
59704eeddc0SDimitry Andric#include <__memory/addressof.h>
598bdd1243dSDimitry Andric#include <__memory/allocator.h>
599bdd1243dSDimitry Andric#include <__memory_resource/polymorphic_allocator.h>
6000b57cec5SDimitry Andric#include <__node_handle>
60106c3fb27SDimitry Andric#include <__ranges/concepts.h>
60206c3fb27SDimitry Andric#include <__ranges/container_compatible_range.h>
60306c3fb27SDimitry Andric#include <__ranges/from_range.h>
604bdd1243dSDimitry Andric#include <__type_traits/is_allocator.h>
60506c3fb27SDimitry Andric#include <__type_traits/type_identity.h>
606fe6060f1SDimitry Andric#include <__utility/forward.h>
6070b57cec5SDimitry Andric#include <stdexcept>
6080b57cec5SDimitry Andric#include <tuple>
6090b57cec5SDimitry Andric#include <version>
6100b57cec5SDimitry Andric
61181ad6265SDimitry Andric// standard-mandated includes
61281ad6265SDimitry Andric
61381ad6265SDimitry Andric// [iterator.range]
61481ad6265SDimitry Andric#include <__iterator/access.h>
61581ad6265SDimitry Andric#include <__iterator/data.h>
61681ad6265SDimitry Andric#include <__iterator/empty.h>
61781ad6265SDimitry Andric#include <__iterator/reverse_access.h>
61881ad6265SDimitry Andric#include <__iterator/size.h>
61981ad6265SDimitry Andric
62081ad6265SDimitry Andric// [unord.map.syn]
62181ad6265SDimitry Andric#include <compare>
62281ad6265SDimitry Andric#include <initializer_list>
62381ad6265SDimitry Andric
6240b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
6250b57cec5SDimitry Andric#  pragma GCC system_header
6260b57cec5SDimitry Andric#endif
6270b57cec5SDimitry Andric
6280b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
6290b57cec5SDimitry Andric
630*cb14a3feSDimitry Andrictemplate <class _Key,
631*cb14a3feSDimitry Andric          class _Cp,
632*cb14a3feSDimitry Andric          class _Hash,
633*cb14a3feSDimitry Andric          class _Pred,
6340b57cec5SDimitry Andric          bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
635*cb14a3feSDimitry Andricclass __unordered_map_hasher : private _Hash {
6360b57cec5SDimitry Andricpublic:
637*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher() _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value) : _Hash() {}
638*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
6390b57cec5SDimitry Andric      : _Hash(__h) {}
640*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return *this; }
641*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const {
642*cb14a3feSDimitry Andric    return static_cast<const _Hash&>(*this)(__x.__get_value().first);
643*cb14a3feSDimitry Andric  }
644*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); }
64506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
646349cc55cSDimitry Andric  template <typename _K2>
647*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_t operator()(const _K2& __x) const {
648*cb14a3feSDimitry Andric    return static_cast<const _Hash&>(*this)(__x);
649*cb14a3feSDimitry Andric  }
650e8d8bef9SDimitry Andric#endif
651*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) {
6525f757f3fSDimitry Andric    using std::swap;
6530b57cec5SDimitry Andric    swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y));
6540b57cec5SDimitry Andric  }
6550b57cec5SDimitry Andric};
6560b57cec5SDimitry Andric
657e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred>
658*cb14a3feSDimitry Andricclass __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, false> {
6590b57cec5SDimitry Andric  _Hash __hash_;
660*cb14a3feSDimitry Andric
6610b57cec5SDimitry Andricpublic:
662*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher() _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
6630b57cec5SDimitry Andric      : __hash_() {}
664*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
6650b57cec5SDimitry Andric      : __hash_(__h) {}
666*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return __hash_; }
667*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return __hash_(__x.__get_value().first); }
668*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return __hash_(__x); }
66906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
670349cc55cSDimitry Andric  template <typename _K2>
671*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_t operator()(const _K2& __x) const {
672*cb14a3feSDimitry Andric    return __hash_(__x);
673*cb14a3feSDimitry Andric  }
674e8d8bef9SDimitry Andric#endif
675*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) {
6765f757f3fSDimitry Andric    using std::swap;
6770b57cec5SDimitry Andric    swap(__hash_, __y.__hash_);
6780b57cec5SDimitry Andric  }
6790b57cec5SDimitry Andric};
6800b57cec5SDimitry Andric
681e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred, bool __b>
682*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
683e8d8bef9SDimitry Andricswap(__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __x,
684*cb14a3feSDimitry Andric     __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
6850b57cec5SDimitry Andric  __x.swap(__y);
6860b57cec5SDimitry Andric}
6870b57cec5SDimitry Andric
688*cb14a3feSDimitry Andrictemplate <class _Key,
689*cb14a3feSDimitry Andric          class _Cp,
690*cb14a3feSDimitry Andric          class _Pred,
691*cb14a3feSDimitry Andric          class _Hash,
6920b57cec5SDimitry Andric          bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
693*cb14a3feSDimitry Andricclass __unordered_map_equal : private _Pred {
6940b57cec5SDimitry Andricpublic:
695*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __unordered_map_equal() _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value) : _Pred() {}
696*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __unordered_map_equal(const _Pred& __p) _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
6970b57cec5SDimitry Andric      : _Pred(__p) {}
698*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return *this; }
699*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const {
700*cb14a3feSDimitry Andric    return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first);
701*cb14a3feSDimitry Andric  }
702*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const {
703*cb14a3feSDimitry Andric    return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);
704*cb14a3feSDimitry Andric  }
705*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const {
706*cb14a3feSDimitry Andric    return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);
707*cb14a3feSDimitry Andric  }
70806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
709349cc55cSDimitry Andric  template <typename _K2>
710*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {
711*cb14a3feSDimitry Andric    return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);
712*cb14a3feSDimitry Andric  }
713349cc55cSDimitry Andric  template <typename _K2>
714*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const {
715*cb14a3feSDimitry Andric    return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);
716*cb14a3feSDimitry Andric  }
717349cc55cSDimitry Andric  template <typename _K2>
718*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _K2& __y) const {
719*cb14a3feSDimitry Andric    return static_cast<const _Pred&>(*this)(__x, __y);
720*cb14a3feSDimitry Andric  }
721349cc55cSDimitry Andric  template <typename _K2>
722*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Key& __y) const {
723*cb14a3feSDimitry Andric    return static_cast<const _Pred&>(*this)(__x, __y);
724*cb14a3feSDimitry Andric  }
725e8d8bef9SDimitry Andric#endif
726*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) {
7275f757f3fSDimitry Andric    using std::swap;
7280b57cec5SDimitry Andric    swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y));
7290b57cec5SDimitry Andric  }
7300b57cec5SDimitry Andric};
7310b57cec5SDimitry Andric
732e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash>
733*cb14a3feSDimitry Andricclass __unordered_map_equal<_Key, _Cp, _Pred, _Hash, false> {
7340b57cec5SDimitry Andric  _Pred __pred_;
735*cb14a3feSDimitry Andric
7360b57cec5SDimitry Andricpublic:
737*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __unordered_map_equal() _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
7380b57cec5SDimitry Andric      : __pred_() {}
739*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __unordered_map_equal(const _Pred& __p) _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
7400b57cec5SDimitry Andric      : __pred_(__p) {}
741*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return __pred_; }
742*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const {
743*cb14a3feSDimitry Andric    return __pred_(__x.__get_value().first, __y.__get_value().first);
744*cb14a3feSDimitry Andric  }
745*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const {
746*cb14a3feSDimitry Andric    return __pred_(__x.__get_value().first, __y);
747*cb14a3feSDimitry Andric  }
748*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const {
749*cb14a3feSDimitry Andric    return __pred_(__x, __y.__get_value().first);
750*cb14a3feSDimitry Andric  }
75106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
752349cc55cSDimitry Andric  template <typename _K2>
753*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {
754*cb14a3feSDimitry Andric    return __pred_(__x.__get_value().first, __y);
755*cb14a3feSDimitry Andric  }
756349cc55cSDimitry Andric  template <typename _K2>
757*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const {
758*cb14a3feSDimitry Andric    return __pred_(__x, __y.__get_value().first);
759*cb14a3feSDimitry Andric  }
760349cc55cSDimitry Andric  template <typename _K2>
761*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _K2& __y) const {
762*cb14a3feSDimitry Andric    return __pred_(__x, __y);
763*cb14a3feSDimitry Andric  }
764349cc55cSDimitry Andric  template <typename _K2>
765*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Key& __y) const {
766*cb14a3feSDimitry Andric    return __pred_(__x, __y);
767*cb14a3feSDimitry Andric  }
768e8d8bef9SDimitry Andric#endif
769*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) {
7705f757f3fSDimitry Andric    using std::swap;
7710b57cec5SDimitry Andric    swap(__pred_, __y.__pred_);
7720b57cec5SDimitry Andric  }
7730b57cec5SDimitry Andric};
7740b57cec5SDimitry Andric
775e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash, bool __b>
776*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
777*cb14a3feSDimitry Andricswap(__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __x, __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __y)
778*cb14a3feSDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
7790b57cec5SDimitry Andric  __x.swap(__y);
7800b57cec5SDimitry Andric}
7810b57cec5SDimitry Andric
7820b57cec5SDimitry Andrictemplate <class _Alloc>
783*cb14a3feSDimitry Andricclass __hash_map_node_destructor {
7840b57cec5SDimitry Andric  typedef _Alloc allocator_type;
7850b57cec5SDimitry Andric  typedef allocator_traits<allocator_type> __alloc_traits;
7860b57cec5SDimitry Andric
7870b57cec5SDimitry Andricpublic:
7880b57cec5SDimitry Andric  typedef typename __alloc_traits::pointer pointer;
7890b57cec5SDimitry Andric
790*cb14a3feSDimitry Andricprivate:
7910b57cec5SDimitry Andric  allocator_type& __na_;
7920b57cec5SDimitry Andric
7930b57cec5SDimitry Andric  __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
7940b57cec5SDimitry Andric
7950b57cec5SDimitry Andricpublic:
7960b57cec5SDimitry Andric  bool __first_constructed;
7970b57cec5SDimitry Andric  bool __second_constructed;
7980b57cec5SDimitry Andric
799*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
8000b57cec5SDimitry Andric      : __na_(__na),
8010b57cec5SDimitry Andric        __first_constructed(false),
802*cb14a3feSDimitry Andric        __second_constructed(false) {}
8030b57cec5SDimitry Andric
8040b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
805*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) _NOEXCEPT
8060b57cec5SDimitry Andric      : __na_(__x.__na_),
8070b57cec5SDimitry Andric        __first_constructed(__x.__value_constructed),
808*cb14a3feSDimitry Andric        __second_constructed(__x.__value_constructed) {
8090b57cec5SDimitry Andric    __x.__value_constructed = false;
8100b57cec5SDimitry Andric  }
8110b57cec5SDimitry Andric#else  // _LIBCPP_CXX03_LANG
812*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
813*cb14a3feSDimitry Andric      : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) {
8140b57cec5SDimitry Andric    const_cast<bool&>(__x.__value_constructed) = false;
8150b57cec5SDimitry Andric  }
8160b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
8170b57cec5SDimitry Andric
818*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
8190b57cec5SDimitry Andric    if (__second_constructed)
8205f757f3fSDimitry Andric      __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().__get_value().second));
8210b57cec5SDimitry Andric    if (__first_constructed)
8225f757f3fSDimitry Andric      __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().__get_value().first));
8230b57cec5SDimitry Andric    if (__p)
8240b57cec5SDimitry Andric      __alloc_traits::deallocate(__na_, __p, 1);
8250b57cec5SDimitry Andric  }
8260b57cec5SDimitry Andric};
8270b57cec5SDimitry Andric
8280b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8290b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
830*cb14a3feSDimitry Andricstruct _LIBCPP_STANDALONE_DEBUG __hash_value_type {
8310b57cec5SDimitry Andric  typedef _Key key_type;
8320b57cec5SDimitry Andric  typedef _Tp mapped_type;
8330b57cec5SDimitry Andric  typedef pair<const key_type, mapped_type> value_type;
8340b57cec5SDimitry Andric  typedef pair<key_type&, mapped_type&> __nc_ref_pair_type;
8350b57cec5SDimitry Andric  typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
8360b57cec5SDimitry Andric
8370b57cec5SDimitry Andricprivate:
838bdd1243dSDimitry Andric  value_type __cc_;
8390b57cec5SDimitry Andric
8400b57cec5SDimitry Andricpublic:
841*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI value_type& __get_value() {
84206c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 17
8435f757f3fSDimitry Andric    return *std::launder(std::addressof(__cc_));
8440b57cec5SDimitry Andric#  else
845bdd1243dSDimitry Andric    return __cc_;
8460b57cec5SDimitry Andric#  endif
8470b57cec5SDimitry Andric  }
8480b57cec5SDimitry Andric
849*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const {
85006c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 17
8515f757f3fSDimitry Andric    return *std::launder(std::addressof(__cc_));
8520b57cec5SDimitry Andric#  else
853bdd1243dSDimitry Andric    return __cc_;
8540b57cec5SDimitry Andric#  endif
8550b57cec5SDimitry Andric  }
8560b57cec5SDimitry Andric
857*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() {
8580b57cec5SDimitry Andric    value_type& __v = __get_value();
8590b57cec5SDimitry Andric    return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
8600b57cec5SDimitry Andric  }
8610b57cec5SDimitry Andric
862*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __nc_rref_pair_type __move() {
8630b57cec5SDimitry Andric    value_type& __v = __get_value();
864*cb14a3feSDimitry Andric    return __nc_rref_pair_type(std::move(const_cast<key_type&>(__v.first)), std::move(__v.second));
8650b57cec5SDimitry Andric  }
8660b57cec5SDimitry Andric
867*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(const __hash_value_type& __v) {
8680b57cec5SDimitry Andric    __ref() = __v.__get_value();
8690b57cec5SDimitry Andric    return *this;
8700b57cec5SDimitry Andric  }
8710b57cec5SDimitry Andric
872*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(__hash_value_type&& __v) {
8730b57cec5SDimitry Andric    __ref() = __v.__move();
8740b57cec5SDimitry Andric    return *this;
8750b57cec5SDimitry Andric  }
8760b57cec5SDimitry Andric
877*cb14a3feSDimitry Andric  template <class _ValueTp, class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value> >
878*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(_ValueTp&& __v) {
8795f757f3fSDimitry Andric    __ref() = std::forward<_ValueTp>(__v);
8800b57cec5SDimitry Andric    return *this;
8810b57cec5SDimitry Andric  }
8820b57cec5SDimitry Andric
8830b57cec5SDimitry Andricprivate:
8840b57cec5SDimitry Andric  __hash_value_type(const __hash_value_type& __v) = delete;
8850b57cec5SDimitry Andric  __hash_value_type(__hash_value_type&& __v)      = delete;
8860b57cec5SDimitry Andric  template <class... _Args>
8870b57cec5SDimitry Andric  explicit __hash_value_type(_Args&&... __args) = delete;
8880b57cec5SDimitry Andric
8890b57cec5SDimitry Andric  ~__hash_value_type() = delete;
8900b57cec5SDimitry Andric};
8910b57cec5SDimitry Andric
8920b57cec5SDimitry Andric#else
8930b57cec5SDimitry Andric
8940b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
895*cb14a3feSDimitry Andricstruct __hash_value_type {
8960b57cec5SDimitry Andric  typedef _Key key_type;
8970b57cec5SDimitry Andric  typedef _Tp mapped_type;
8980b57cec5SDimitry Andric  typedef pair<const key_type, mapped_type> value_type;
8990b57cec5SDimitry Andric
9000b57cec5SDimitry Andricprivate:
901bdd1243dSDimitry Andric  value_type __cc_;
9020b57cec5SDimitry Andric
9030b57cec5SDimitry Andricpublic:
904*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; }
905*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; }
9060b57cec5SDimitry Andric
9070b57cec5SDimitry Andricprivate:
9080b57cec5SDimitry Andric  ~__hash_value_type();
9090b57cec5SDimitry Andric};
9100b57cec5SDimitry Andric
9110b57cec5SDimitry Andric#endif
9120b57cec5SDimitry Andric
9130b57cec5SDimitry Andrictemplate <class _HashIterator>
914*cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_iterator {
9150b57cec5SDimitry Andric  _HashIterator __i_;
9160b57cec5SDimitry Andric
9170b57cec5SDimitry Andric  typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
9180b57cec5SDimitry Andric
9190b57cec5SDimitry Andricpublic:
9200b57cec5SDimitry Andric  typedef forward_iterator_tag iterator_category;
9210b57cec5SDimitry Andric  typedef typename _NodeTypes::__map_value_type value_type;
9220b57cec5SDimitry Andric  typedef typename _NodeTypes::difference_type difference_type;
9230b57cec5SDimitry Andric  typedef value_type& reference;
9240b57cec5SDimitry Andric  typedef typename _NodeTypes::__map_value_type_pointer pointer;
9250b57cec5SDimitry Andric
926*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_iterator() _NOEXCEPT {}
9270b57cec5SDimitry Andric
928*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
9290b57cec5SDimitry Andric
930*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); }
931*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); }
9320b57cec5SDimitry Andric
933*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_iterator& operator++() {
934*cb14a3feSDimitry Andric    ++__i_;
935*cb14a3feSDimitry Andric    return *this;
936*cb14a3feSDimitry Andric  }
937*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_iterator operator++(int) {
9380b57cec5SDimitry Andric    __hash_map_iterator __t(*this);
9390b57cec5SDimitry Andric    ++(*this);
9400b57cec5SDimitry Andric    return __t;
9410b57cec5SDimitry Andric  }
9420b57cec5SDimitry Andric
943*cb14a3feSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {
944*cb14a3feSDimitry Andric    return __x.__i_ == __y.__i_;
945*cb14a3feSDimitry Andric  }
94606c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
947*cb14a3feSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {
948*cb14a3feSDimitry Andric    return __x.__i_ != __y.__i_;
949*cb14a3feSDimitry Andric  }
95006c3fb27SDimitry Andric#endif
9510b57cec5SDimitry Andric
952*cb14a3feSDimitry Andric  template <class, class, class, class, class>
953*cb14a3feSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_map;
954*cb14a3feSDimitry Andric  template <class, class, class, class, class>
955*cb14a3feSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
956*cb14a3feSDimitry Andric  template <class>
957*cb14a3feSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
958*cb14a3feSDimitry Andric  template <class>
959*cb14a3feSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
960*cb14a3feSDimitry Andric  template <class>
961*cb14a3feSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
9620b57cec5SDimitry Andric};
9630b57cec5SDimitry Andric
9640b57cec5SDimitry Andrictemplate <class _HashIterator>
965*cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator {
9660b57cec5SDimitry Andric  _HashIterator __i_;
9670b57cec5SDimitry Andric
9680b57cec5SDimitry Andric  typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
9690b57cec5SDimitry Andric
9700b57cec5SDimitry Andricpublic:
9710b57cec5SDimitry Andric  typedef forward_iterator_tag iterator_category;
9720b57cec5SDimitry Andric  typedef typename _NodeTypes::__map_value_type value_type;
9730b57cec5SDimitry Andric  typedef typename _NodeTypes::difference_type difference_type;
9740b57cec5SDimitry Andric  typedef const value_type& reference;
9750b57cec5SDimitry Andric  typedef typename _NodeTypes::__const_map_value_type_pointer pointer;
9760b57cec5SDimitry Andric
977*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator() _NOEXCEPT {}
9780b57cec5SDimitry Andric
979*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
9805f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
981*cb14a3feSDimitry Andric  __hash_map_const_iterator(__hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) _NOEXCEPT
9820b57cec5SDimitry Andric      : __i_(__i.__i_) {}
9830b57cec5SDimitry Andric
984*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); }
985*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); }
9860b57cec5SDimitry Andric
987*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator& operator++() {
988*cb14a3feSDimitry Andric    ++__i_;
989*cb14a3feSDimitry Andric    return *this;
990*cb14a3feSDimitry Andric  }
991*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator operator++(int) {
9920b57cec5SDimitry Andric    __hash_map_const_iterator __t(*this);
9930b57cec5SDimitry Andric    ++(*this);
9940b57cec5SDimitry Andric    return __t;
9950b57cec5SDimitry Andric  }
9960b57cec5SDimitry Andric
997*cb14a3feSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool
998*cb14a3feSDimitry Andric  operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {
999*cb14a3feSDimitry Andric    return __x.__i_ == __y.__i_;
1000*cb14a3feSDimitry Andric  }
100106c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
1002*cb14a3feSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool
1003*cb14a3feSDimitry Andric  operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {
1004*cb14a3feSDimitry Andric    return __x.__i_ != __y.__i_;
1005*cb14a3feSDimitry Andric  }
100606c3fb27SDimitry Andric#endif
10070b57cec5SDimitry Andric
1008*cb14a3feSDimitry Andric  template <class, class, class, class, class>
1009*cb14a3feSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_map;
1010*cb14a3feSDimitry Andric  template <class, class, class, class, class>
1011*cb14a3feSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
1012*cb14a3feSDimitry Andric  template <class>
1013*cb14a3feSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
1014*cb14a3feSDimitry Andric  template <class>
1015*cb14a3feSDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
10160b57cec5SDimitry Andric};
10170b57cec5SDimitry Andric
10180b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
10190b57cec5SDimitry Andricclass unordered_multimap;
10200b57cec5SDimitry Andric
1021*cb14a3feSDimitry Andrictemplate <class _Key,
1022*cb14a3feSDimitry Andric          class _Tp,
1023*cb14a3feSDimitry Andric          class _Hash  = hash<_Key>,
1024*cb14a3feSDimitry Andric          class _Pred  = equal_to<_Key>,
10250b57cec5SDimitry Andric          class _Alloc = allocator<pair<const _Key, _Tp> > >
1026*cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_map {
10270b57cec5SDimitry Andricpublic:
10280b57cec5SDimitry Andric  // types
10290b57cec5SDimitry Andric  typedef _Key key_type;
10300b57cec5SDimitry Andric  typedef _Tp mapped_type;
103181ad6265SDimitry Andric  typedef __type_identity_t<_Hash> hasher;
103281ad6265SDimitry Andric  typedef __type_identity_t<_Pred> key_equal;
103381ad6265SDimitry Andric  typedef __type_identity_t<_Alloc> allocator_type;
10340b57cec5SDimitry Andric  typedef pair<const key_type, mapped_type> value_type;
10350b57cec5SDimitry Andric  typedef value_type& reference;
10360b57cec5SDimitry Andric  typedef const value_type& const_reference;
10370b57cec5SDimitry Andric  static_assert((is_same<value_type, typename allocator_type::value_type>::value),
103806c3fb27SDimitry Andric                "Allocator::value_type must be same type as value_type");
10390b57cec5SDimitry Andric
10400b57cec5SDimitry Andricprivate:
10410b57cec5SDimitry Andric  typedef __hash_value_type<key_type, mapped_type> __value_type;
1042e8d8bef9SDimitry Andric  typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
1043e8d8bef9SDimitry Andric  typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
1044bdd1243dSDimitry Andric  typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
10450b57cec5SDimitry Andric
1046*cb14a3feSDimitry Andric  typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table;
10470b57cec5SDimitry Andric
10480b57cec5SDimitry Andric  __table __table_;
10490b57cec5SDimitry Andric
10500b57cec5SDimitry Andric  typedef typename __table::_NodeTypes _NodeTypes;
10510b57cec5SDimitry Andric  typedef typename __table::__node_pointer __node_pointer;
10520b57cec5SDimitry Andric  typedef typename __table::__node_const_pointer __node_const_pointer;
10530b57cec5SDimitry Andric  typedef typename __table::__node_traits __node_traits;
10540b57cec5SDimitry Andric  typedef typename __table::__node_allocator __node_allocator;
10550b57cec5SDimitry Andric  typedef typename __table::__node __node;
10560b57cec5SDimitry Andric  typedef __hash_map_node_destructor<__node_allocator> _Dp;
10570b57cec5SDimitry Andric  typedef unique_ptr<__node, _Dp> __node_holder;
10580b57cec5SDimitry Andric  typedef allocator_traits<allocator_type> __alloc_traits;
10590b57cec5SDimitry Andric
1060bdd1243dSDimitry Andric  static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1061bdd1243dSDimitry Andric                "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1062bdd1243dSDimitry Andric                "original allocator");
1063bdd1243dSDimitry Andric
10640b57cec5SDimitry Andric  static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");
10650b57cec5SDimitry Andric  static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");
1066*cb14a3feSDimitry Andric
10670b57cec5SDimitry Andricpublic:
10680b57cec5SDimitry Andric  typedef typename __alloc_traits::pointer pointer;
10690b57cec5SDimitry Andric  typedef typename __alloc_traits::const_pointer const_pointer;
10700b57cec5SDimitry Andric  typedef typename __table::size_type size_type;
10710b57cec5SDimitry Andric  typedef typename __table::difference_type difference_type;
10720b57cec5SDimitry Andric
10730b57cec5SDimitry Andric  typedef __hash_map_iterator<typename __table::iterator> iterator;
10740b57cec5SDimitry Andric  typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
10750b57cec5SDimitry Andric  typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
10760b57cec5SDimitry Andric  typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
10770b57cec5SDimitry Andric
107806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
10790b57cec5SDimitry Andric  typedef __map_node_handle<__node, allocator_type> node_type;
10800b57cec5SDimitry Andric  typedef __insert_return_type<iterator, node_type> insert_return_type;
10810b57cec5SDimitry Andric#endif
10820b57cec5SDimitry Andric
10830b57cec5SDimitry Andric  template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
10840b57cec5SDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_map;
10850b57cec5SDimitry Andric  template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
10860b57cec5SDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
10870b57cec5SDimitry Andric
1088*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
1089*cb14a3feSDimitry Andric  explicit _LIBCPP_HIDE_FROM_ABI
1090*cb14a3feSDimitry Andric  unordered_map(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
10915f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
1092*cb14a3feSDimitry Andric  unordered_map(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
10930b57cec5SDimitry Andric  template <class _InputIterator>
109406c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(_InputIterator __first, _InputIterator __last);
10950b57cec5SDimitry Andric  template <class _InputIterator>
1096*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
1097*cb14a3feSDimitry Andric  unordered_map(_InputIterator __first,
1098*cb14a3feSDimitry Andric                _InputIterator __last,
1099*cb14a3feSDimitry Andric                size_type __n,
1100*cb14a3feSDimitry Andric                const hasher& __hf     = hasher(),
11010b57cec5SDimitry Andric                const key_equal& __eql = key_equal());
11020b57cec5SDimitry Andric  template <class _InputIterator>
1103*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(
1104*cb14a3feSDimitry Andric      _InputIterator __first,
1105*cb14a3feSDimitry Andric      _InputIterator __last,
1106*cb14a3feSDimitry Andric      size_type __n,
1107*cb14a3feSDimitry Andric      const hasher& __hf,
11080b57cec5SDimitry Andric      const key_equal& __eql,
11090b57cec5SDimitry Andric      const allocator_type& __a);
111006c3fb27SDimitry Andric
111106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
111206c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
1113*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(
1114*cb14a3feSDimitry Andric      from_range_t,
1115*cb14a3feSDimitry Andric      _Range&& __range,
1116*cb14a3feSDimitry Andric      size_type __n             = /*implementation-defined*/ 0,
1117*cb14a3feSDimitry Andric      const hasher& __hf        = hasher(),
1118*cb14a3feSDimitry Andric      const key_equal& __eql    = key_equal(),
111906c3fb27SDimitry Andric      const allocator_type& __a = allocator_type())
112006c3fb27SDimitry Andric      : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
112106c3fb27SDimitry Andric    if (__n > 0) {
112206c3fb27SDimitry Andric      __table_.__rehash_unique(__n);
112306c3fb27SDimitry Andric    }
112406c3fb27SDimitry Andric    insert_range(std::forward<_Range>(__range));
112506c3fb27SDimitry Andric  }
112606c3fb27SDimitry Andric#endif
112706c3fb27SDimitry Andric
1128*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit unordered_map(const allocator_type& __a);
112906c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u);
113006c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u, const allocator_type& __a);
11310b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1132*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
113306c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u, const allocator_type& __a);
113406c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il);
1135*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
1136*cb14a3feSDimitry Andric  unordered_map(initializer_list<value_type> __il,
1137*cb14a3feSDimitry Andric                size_type __n,
1138*cb14a3feSDimitry Andric                const hasher& __hf     = hasher(),
1139*cb14a3feSDimitry Andric                const key_equal& __eql = key_equal());
1140*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(
1141*cb14a3feSDimitry Andric      initializer_list<value_type> __il,
1142*cb14a3feSDimitry Andric      size_type __n,
1143*cb14a3feSDimitry Andric      const hasher& __hf,
1144*cb14a3feSDimitry Andric      const key_equal& __eql,
11450b57cec5SDimitry Andric      const allocator_type& __a);
11460b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
114706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14
1148*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const allocator_type& __a)
11490b57cec5SDimitry Andric      : unordered_map(__n, hasher(), key_equal(), __a) {}
1150*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
11510b57cec5SDimitry Andric      : unordered_map(__n, __hf, key_equal(), __a) {}
11520b57cec5SDimitry Andric  template <class _InputIterator>
11535f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
11540b57cec5SDimitry Andric  unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
11550b57cec5SDimitry Andric      : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
11560b57cec5SDimitry Andric  template <class _InputIterator>
1157*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(
1158*cb14a3feSDimitry Andric      _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
11590b57cec5SDimitry Andric      : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
116006c3fb27SDimitry Andric
116106c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
116206c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
1163*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
116406c3fb27SDimitry Andric      : unordered_map(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
116506c3fb27SDimitry Andric
116606c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
116706c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI
116806c3fb27SDimitry Andric  unordered_map(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
116906c3fb27SDimitry Andric      : unordered_map(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
117006c3fb27SDimitry Andric#  endif
117106c3fb27SDimitry Andric
1172*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
11730b57cec5SDimitry Andric      : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
11745f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
1175*cb14a3feSDimitry Andric  unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
11760b57cec5SDimitry Andric      : unordered_map(__il, __n, __hf, key_equal(), __a) {}
11770b57cec5SDimitry Andric#endif
1178*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ~unordered_map() {
1179bdd1243dSDimitry Andric    static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
11800b57cec5SDimitry Andric  }
11810b57cec5SDimitry Andric
1182*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(const unordered_map& __u) {
11830b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
11840b57cec5SDimitry Andric    __table_ = __u.__table_;
11850b57cec5SDimitry Andric#else
11865f757f3fSDimitry Andric    if (this != std::addressof(__u)) {
11870b57cec5SDimitry Andric      __table_.clear();
11880b57cec5SDimitry Andric      __table_.hash_function()   = __u.__table_.hash_function();
11890b57cec5SDimitry Andric      __table_.key_eq()          = __u.__table_.key_eq();
11900b57cec5SDimitry Andric      __table_.max_load_factor() = __u.__table_.max_load_factor();
11910b57cec5SDimitry Andric      __table_.__copy_assign_alloc(__u.__table_);
11920b57cec5SDimitry Andric      insert(__u.begin(), __u.end());
11930b57cec5SDimitry Andric    }
11940b57cec5SDimitry Andric#endif
11950b57cec5SDimitry Andric    return *this;
11960b57cec5SDimitry Andric  }
11970b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1198*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(unordered_map&& __u)
11990b57cec5SDimitry Andric      _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
1200*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(initializer_list<value_type> __il);
12010b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
12020b57cec5SDimitry Andric
1203*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
1204*cb14a3feSDimitry Andric    return allocator_type(__table_.__node_alloc());
12050b57cec5SDimitry Andric  }
12060b57cec5SDimitry Andric
1207*cb14a3feSDimitry Andric  _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
1208*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
1209*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
1210*cb14a3feSDimitry Andric
1211*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); }
1212*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); }
1213*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); }
1214*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); }
1215*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
1216*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
1217*cb14a3feSDimitry Andric
1218*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); }
1219*cb14a3feSDimitry Andric
1220*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }
1221*cb14a3feSDimitry Andric
12220b57cec5SDimitry Andric  template <class _InputIterator>
1223*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
12240b57cec5SDimitry Andric
122506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
122606c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
1227*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
122806c3fb27SDimitry Andric    for (auto&& __element : __range) {
122906c3fb27SDimitry Andric      __table_.__insert_unique(std::forward<decltype(__element)>(__element));
123006c3fb27SDimitry Andric    }
123106c3fb27SDimitry Andric  }
123206c3fb27SDimitry Andric#endif
123306c3fb27SDimitry Andric
12340b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1235*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
12360b57cec5SDimitry Andric
1237*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) {
1238*cb14a3feSDimitry Andric    return __table_.__insert_unique(std::move(__x));
1239*cb14a3feSDimitry Andric  }
12400b57cec5SDimitry Andric
124106c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) {
12425f757f3fSDimitry Andric    return __table_.__insert_unique(std::move(__x)).first;
12430b57cec5SDimitry Andric  }
12440b57cec5SDimitry Andric
1245*cb14a3feSDimitry Andric  template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1246*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __x) {
1247*cb14a3feSDimitry Andric    return __table_.__insert_unique(std::forward<_Pp>(__x));
1248*cb14a3feSDimitry Andric  }
12490b57cec5SDimitry Andric
1250*cb14a3feSDimitry Andric  template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1251*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, _Pp&& __x) {
12525f757f3fSDimitry Andric    return insert(std::forward<_Pp>(__x)).first;
12530b57cec5SDimitry Andric  }
12540b57cec5SDimitry Andric
12550b57cec5SDimitry Andric  template <class... _Args>
1256*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
12575f757f3fSDimitry Andric    return __table_.__emplace_unique(std::forward<_Args>(__args)...);
12580b57cec5SDimitry Andric  }
12590b57cec5SDimitry Andric
12600b57cec5SDimitry Andric  template <class... _Args>
1261*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator, _Args&&... __args) {
12625f757f3fSDimitry Andric    return __table_.__emplace_unique(std::forward<_Args>(__args)...).first;
12630b57cec5SDimitry Andric  }
12640b57cec5SDimitry Andric
12650b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
12660b57cec5SDimitry Andric
126706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
12680b57cec5SDimitry Andric  template <class... _Args>
1269*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) {
1270*cb14a3feSDimitry Andric    return __table_.__emplace_unique_key_args(
1271*cb14a3feSDimitry Andric        __k, piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple(std::forward<_Args>(__args)...));
12720b57cec5SDimitry Andric  }
12730b57cec5SDimitry Andric
12740b57cec5SDimitry Andric  template <class... _Args>
1275*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) {
1276*cb14a3feSDimitry Andric    return __table_.__emplace_unique_key_args(
1277*cb14a3feSDimitry Andric        __k,
1278*cb14a3feSDimitry Andric        piecewise_construct,
12795f757f3fSDimitry Andric        std::forward_as_tuple(std::move(__k)),
12805f757f3fSDimitry Andric        std::forward_as_tuple(std::forward<_Args>(__args)...));
12810b57cec5SDimitry Andric  }
12820b57cec5SDimitry Andric
12830b57cec5SDimitry Andric  template <class... _Args>
1284*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator, const key_type& __k, _Args&&... __args) {
12855f757f3fSDimitry Andric    return try_emplace(__k, std::forward<_Args>(__args)...).first;
12860b57cec5SDimitry Andric  }
12870b57cec5SDimitry Andric
12880b57cec5SDimitry Andric  template <class... _Args>
1289*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator, key_type&& __k, _Args&&... __args) {
12905f757f3fSDimitry Andric    return try_emplace(std::move(__k), std::forward<_Args>(__args)...).first;
12910b57cec5SDimitry Andric  }
12920b57cec5SDimitry Andric
12930b57cec5SDimitry Andric  template <class _Vp>
1294*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) {
1295*cb14a3feSDimitry Andric    pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k, __k, std::forward<_Vp>(__v));
12960b57cec5SDimitry Andric    if (!__res.second) {
12975f757f3fSDimitry Andric      __res.first->second = std::forward<_Vp>(__v);
12980b57cec5SDimitry Andric    }
12990b57cec5SDimitry Andric    return __res;
13000b57cec5SDimitry Andric  }
13010b57cec5SDimitry Andric
13020b57cec5SDimitry Andric  template <class _Vp>
1303*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) {
1304*cb14a3feSDimitry Andric    pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k, std::move(__k), std::forward<_Vp>(__v));
13050b57cec5SDimitry Andric    if (!__res.second) {
13065f757f3fSDimitry Andric      __res.first->second = std::forward<_Vp>(__v);
13070b57cec5SDimitry Andric    }
13080b57cec5SDimitry Andric    return __res;
13090b57cec5SDimitry Andric  }
13100b57cec5SDimitry Andric
13110b57cec5SDimitry Andric  template <class _Vp>
1312*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator, const key_type& __k, _Vp&& __v) {
13135f757f3fSDimitry Andric    return insert_or_assign(__k, std::forward<_Vp>(__v)).first;
13140b57cec5SDimitry Andric  }
13150b57cec5SDimitry Andric
13160b57cec5SDimitry Andric  template <class _Vp>
1317*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v) {
13185f757f3fSDimitry Andric    return insert_or_assign(std::move(__k), std::forward<_Vp>(__v)).first;
13190b57cec5SDimitry Andric  }
132006c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 17
13210b57cec5SDimitry Andric
1322*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); }
1323*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); }
1324*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_unique(__k); }
1325*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
1326*cb14a3feSDimitry Andric    return __table_.erase(__first.__i_, __last.__i_);
1327*cb14a3feSDimitry Andric  }
1328*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
13290b57cec5SDimitry Andric
133006c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
1331*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
133206c3fb27SDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
13330b57cec5SDimitry Andric                                        "node_type with incompatible allocator passed to unordered_map::insert()");
1334*cb14a3feSDimitry Andric    return __table_.template __node_handle_insert_unique< node_type, insert_return_type>(std::move(__nh));
13350b57cec5SDimitry Andric  }
1336*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {
133706c3fb27SDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
13380b57cec5SDimitry Andric                                        "node_type with incompatible allocator passed to unordered_map::insert()");
1339*cb14a3feSDimitry Andric    return __table_.template __node_handle_insert_unique<node_type>(__hint.__i_, std::move(__nh));
13400b57cec5SDimitry Andric  }
1341*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
13420b57cec5SDimitry Andric    return __table_.template __node_handle_extract<node_type>(__key);
13430b57cec5SDimitry Andric  }
1344*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {
1345*cb14a3feSDimitry Andric    return __table_.template __node_handle_extract<node_type>(__it.__i_);
13460b57cec5SDimitry Andric  }
13470b57cec5SDimitry Andric
13480b57cec5SDimitry Andric  template <class _H2, class _P2>
1349*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source) {
1350*cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1351*cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
13520b57cec5SDimitry Andric    return __table_.__node_handle_merge_unique(__source.__table_);
13530b57cec5SDimitry Andric  }
13540b57cec5SDimitry Andric  template <class _H2, class _P2>
1355*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source) {
1356*cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1357*cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
13580b57cec5SDimitry Andric    return __table_.__node_handle_merge_unique(__source.__table_);
13590b57cec5SDimitry Andric  }
13600b57cec5SDimitry Andric  template <class _H2, class _P2>
1361*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source) {
1362*cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1363*cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
13640b57cec5SDimitry Andric    return __table_.__node_handle_merge_unique(__source.__table_);
13650b57cec5SDimitry Andric  }
13660b57cec5SDimitry Andric  template <class _H2, class _P2>
1367*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source) {
1368*cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1369*cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
13700b57cec5SDimitry Andric    return __table_.__node_handle_merge_unique(__source.__table_);
13710b57cec5SDimitry Andric  }
13720b57cec5SDimitry Andric#endif
13730b57cec5SDimitry Andric
1374*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(unordered_map& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) {
1375*cb14a3feSDimitry Andric    __table_.swap(__u.__table_);
1376*cb14a3feSDimitry Andric  }
13770b57cec5SDimitry Andric
1378*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function().hash_function(); }
1379*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq().key_eq(); }
13800b57cec5SDimitry Andric
1381*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
1382*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
138306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1384*cb14a3feSDimitry Andric  template <class _K2,
1385*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1386*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1387*cb14a3feSDimitry Andric    return __table_.find(__k);
1388*cb14a3feSDimitry Andric  }
1389*cb14a3feSDimitry Andric  template <class _K2,
1390*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1391*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1392*cb14a3feSDimitry Andric    return __table_.find(__k);
1393*cb14a3feSDimitry Andric  }
139406c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1395e8d8bef9SDimitry Andric
1396*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); }
139706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1398*cb14a3feSDimitry Andric  template <class _K2,
1399*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1400*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1401*cb14a3feSDimitry Andric    return __table_.__count_unique(__k);
1402*cb14a3feSDimitry Andric  }
140306c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1404349cc55cSDimitry Andric
140506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1406*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1407e8d8bef9SDimitry Andric
1408*cb14a3feSDimitry Andric  template <class _K2,
1409*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1410*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1411*cb14a3feSDimitry Andric    return find(__k) != end();
1412*cb14a3feSDimitry Andric  }
141306c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1414349cc55cSDimitry Andric
1415*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
1416*cb14a3feSDimitry Andric    return __table_.__equal_range_unique(__k);
1417*cb14a3feSDimitry Andric  }
1418*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
1419*cb14a3feSDimitry Andric    return __table_.__equal_range_unique(__k);
1420*cb14a3feSDimitry Andric  }
142106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1422*cb14a3feSDimitry Andric  template <class _K2,
1423*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1424*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
1425*cb14a3feSDimitry Andric    return __table_.__equal_range_unique(__k);
1426*cb14a3feSDimitry Andric  }
1427*cb14a3feSDimitry Andric  template <class _K2,
1428*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1429*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
1430*cb14a3feSDimitry Andric    return __table_.__equal_range_unique(__k);
1431*cb14a3feSDimitry Andric  }
143206c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
14330b57cec5SDimitry Andric
143406c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k);
14350b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
143606c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);
14370b57cec5SDimitry Andric#endif
14380b57cec5SDimitry Andric
143906c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k);
144006c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const;
14410b57cec5SDimitry Andric
1442*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }
1443*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }
14440b57cec5SDimitry Andric
1445*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); }
1446*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); }
14470b57cec5SDimitry Andric
1448*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); }
1449*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); }
1450*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); }
1451*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); }
1452*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); }
1453*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); }
14540b57cec5SDimitry Andric
1455*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); }
1456*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); }
1457*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); }
1458*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_unique(__n); }
1459*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); }
14600b57cec5SDimitry Andric
14610b57cec5SDimitry Andricprivate:
14620b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG
146306c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k);
14640b57cec5SDimitry Andric#endif
14650b57cec5SDimitry Andric};
14660b57cec5SDimitry Andric
1467349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
14680b57cec5SDimitry Andrictemplate <class _InputIterator,
14690b57cec5SDimitry Andric          class _Hash      = hash<__iter_key_type<_InputIterator>>,
14700b57cec5SDimitry Andric          class _Pred      = equal_to<__iter_key_type<_InputIterator>>,
14710b57cec5SDimitry Andric          class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
147206c3fb27SDimitry Andric          class            = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1473349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
1474349cc55cSDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
1475349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
1476349cc55cSDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
1477*cb14a3feSDimitry Andricunordered_map(_InputIterator,
1478*cb14a3feSDimitry Andric              _InputIterator,
1479*cb14a3feSDimitry Andric              typename allocator_traits<_Allocator>::size_type = 0,
1480*cb14a3feSDimitry Andric              _Hash                                            = _Hash(),
1481*cb14a3feSDimitry Andric              _Pred                                            = _Pred(),
1482*cb14a3feSDimitry Andric              _Allocator                                       = _Allocator())
14830b57cec5SDimitry Andric    -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
14840b57cec5SDimitry Andric
148506c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
148606c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
148706c3fb27SDimitry Andric          class _Hash      = hash<__range_key_type<_Range>>,
148806c3fb27SDimitry Andric          class _Pred      = equal_to<__range_key_type<_Range>>,
148906c3fb27SDimitry Andric          class _Allocator = allocator<__range_to_alloc_type<_Range>>,
149006c3fb27SDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
149106c3fb27SDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
149206c3fb27SDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
149306c3fb27SDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
1494*cb14a3feSDimitry Andricunordered_map(from_range_t,
1495*cb14a3feSDimitry Andric              _Range&&,
1496*cb14a3feSDimitry Andric              typename allocator_traits<_Allocator>::size_type = 0,
1497*cb14a3feSDimitry Andric              _Hash                                            = _Hash(),
1498*cb14a3feSDimitry Andric              _Pred                                            = _Pred(),
1499*cb14a3feSDimitry Andric              _Allocator                                       = _Allocator())
150006c3fb27SDimitry Andric    -> unordered_map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>; // C++23
150106c3fb27SDimitry Andric#  endif
150206c3fb27SDimitry Andric
1503*cb14a3feSDimitry Andrictemplate <class _Key,
1504*cb14a3feSDimitry Andric          class _Tp,
1505*cb14a3feSDimitry Andric          class _Hash      = hash<remove_const_t<_Key>>,
15060b57cec5SDimitry Andric          class _Pred      = equal_to<remove_const_t<_Key>>,
15070b57cec5SDimitry Andric          class _Allocator = allocator<pair<const _Key, _Tp>>,
1508349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
1509349cc55cSDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
1510349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
1511349cc55cSDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
1512*cb14a3feSDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>,
1513*cb14a3feSDimitry Andric              typename allocator_traits<_Allocator>::size_type = 0,
1514*cb14a3feSDimitry Andric              _Hash                                            = _Hash(),
1515*cb14a3feSDimitry Andric              _Pred                                            = _Pred(),
1516*cb14a3feSDimitry Andric              _Allocator = _Allocator()) -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
15170b57cec5SDimitry Andric
1518*cb14a3feSDimitry Andrictemplate <class _InputIterator,
1519*cb14a3feSDimitry Andric          class _Allocator,
152006c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1521349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
15220b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
1523*cb14a3feSDimitry Andric    -> unordered_map<__iter_key_type<_InputIterator>,
1524*cb14a3feSDimitry Andric                     __iter_mapped_type<_InputIterator>,
1525*cb14a3feSDimitry Andric                     hash<__iter_key_type<_InputIterator>>,
1526*cb14a3feSDimitry Andric                     equal_to<__iter_key_type<_InputIterator>>,
1527*cb14a3feSDimitry Andric                     _Allocator>;
15280b57cec5SDimitry Andric
1529*cb14a3feSDimitry Andrictemplate <class _InputIterator,
1530*cb14a3feSDimitry Andric          class _Allocator,
153106c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1532349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
15330b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, _Allocator)
1534*cb14a3feSDimitry Andric    -> unordered_map<__iter_key_type<_InputIterator>,
1535*cb14a3feSDimitry Andric                     __iter_mapped_type<_InputIterator>,
1536*cb14a3feSDimitry Andric                     hash<__iter_key_type<_InputIterator>>,
1537*cb14a3feSDimitry Andric                     equal_to<__iter_key_type<_InputIterator>>,
1538*cb14a3feSDimitry Andric                     _Allocator>;
15390b57cec5SDimitry Andric
1540*cb14a3feSDimitry Andrictemplate <class _InputIterator,
1541*cb14a3feSDimitry Andric          class _Hash,
1542*cb14a3feSDimitry Andric          class _Allocator,
154306c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1544349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
1545349cc55cSDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
1546349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
15470b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1548*cb14a3feSDimitry Andric    -> unordered_map<__iter_key_type<_InputIterator>,
1549*cb14a3feSDimitry Andric                     __iter_mapped_type<_InputIterator>,
1550*cb14a3feSDimitry Andric                     _Hash,
1551*cb14a3feSDimitry Andric                     equal_to<__iter_key_type<_InputIterator>>,
1552*cb14a3feSDimitry Andric                     _Allocator>;
15530b57cec5SDimitry Andric
155406c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
155506c3fb27SDimitry Andric
1556*cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
155706c3fb27SDimitry Andricunordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
1558*cb14a3feSDimitry Andric    -> unordered_map<__range_key_type<_Range>,
1559*cb14a3feSDimitry Andric                     __range_mapped_type<_Range>,
1560*cb14a3feSDimitry Andric                     hash<__range_key_type<_Range>>,
1561*cb14a3feSDimitry Andric                     equal_to<__range_key_type<_Range>>,
1562*cb14a3feSDimitry Andric                     _Allocator>;
156306c3fb27SDimitry Andric
1564*cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
156506c3fb27SDimitry Andricunordered_map(from_range_t, _Range&&, _Allocator)
1566*cb14a3feSDimitry Andric    -> unordered_map<__range_key_type<_Range>,
1567*cb14a3feSDimitry Andric                     __range_mapped_type<_Range>,
1568*cb14a3feSDimitry Andric                     hash<__range_key_type<_Range>>,
1569*cb14a3feSDimitry Andric                     equal_to<__range_key_type<_Range>>,
1570*cb14a3feSDimitry Andric                     _Allocator>;
157106c3fb27SDimitry Andric
1572*cb14a3feSDimitry Andrictemplate <ranges::input_range _Range,
1573*cb14a3feSDimitry Andric          class _Hash,
1574*cb14a3feSDimitry Andric          class _Allocator,
157506c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
157606c3fb27SDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
157706c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
157806c3fb27SDimitry Andricunordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1579*cb14a3feSDimitry Andric    -> unordered_map<__range_key_type<_Range>,
1580*cb14a3feSDimitry Andric                     __range_mapped_type<_Range>,
1581*cb14a3feSDimitry Andric                     _Hash,
1582*cb14a3feSDimitry Andric                     equal_to<__range_key_type<_Range>>,
1583*cb14a3feSDimitry Andric                     _Allocator>;
158406c3fb27SDimitry Andric
158506c3fb27SDimitry Andric#  endif
158606c3fb27SDimitry Andric
1587*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
15880b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
1589*cb14a3feSDimitry Andric    -> unordered_map<remove_const_t<_Key>, _Tp, hash<remove_const_t<_Key>>, equal_to<remove_const_t<_Key>>, _Allocator>;
15900b57cec5SDimitry Andric
1591*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
15920b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator)
1593*cb14a3feSDimitry Andric    -> unordered_map<remove_const_t<_Key>, _Tp, hash<remove_const_t<_Key>>, equal_to<remove_const_t<_Key>>, _Allocator>;
15940b57cec5SDimitry Andric
1595*cb14a3feSDimitry Andrictemplate <class _Key,
1596*cb14a3feSDimitry Andric          class _Tp,
1597*cb14a3feSDimitry Andric          class _Hash,
1598*cb14a3feSDimitry Andric          class _Allocator,
1599349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
1600349cc55cSDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
1601349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
16020b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1603*cb14a3feSDimitry Andric    -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>;
16040b57cec5SDimitry Andric#endif
16050b57cec5SDimitry Andric
16060b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1607*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(size_type __n, const hasher& __hf, const key_equal& __eql)
1608*cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
1609753f127fSDimitry Andric  __table_.__rehash_unique(__n);
16100b57cec5SDimitry Andric}
16110b57cec5SDimitry Andric
16120b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16130b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1614*cb14a3feSDimitry Andric    size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1615*cb14a3feSDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
1616*cb14a3feSDimitry Andric  __table_.__rehash_unique(__n);
1617*cb14a3feSDimitry Andric}
1618*cb14a3feSDimitry Andric
1619*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1620*cb14a3feSDimitry Andricinline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const allocator_type& __a)
1621*cb14a3feSDimitry Andric    : __table_(typename __table::allocator_type(__a)) {}
1622*cb14a3feSDimitry Andric
1623*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1624*cb14a3feSDimitry Andrictemplate <class _InputIterator>
1625*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(_InputIterator __first, _InputIterator __last) {
1626*cb14a3feSDimitry Andric  insert(__first, __last);
1627*cb14a3feSDimitry Andric}
1628*cb14a3feSDimitry Andric
1629*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1630*cb14a3feSDimitry Andrictemplate <class _InputIterator>
1631*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1632*cb14a3feSDimitry Andric    _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql)
1633*cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
1634*cb14a3feSDimitry Andric  __table_.__rehash_unique(__n);
1635*cb14a3feSDimitry Andric  insert(__first, __last);
1636*cb14a3feSDimitry Andric}
1637*cb14a3feSDimitry Andric
1638*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1639*cb14a3feSDimitry Andrictemplate <class _InputIterator>
1640*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1641*cb14a3feSDimitry Andric    _InputIterator __first,
1642*cb14a3feSDimitry Andric    _InputIterator __last,
1643*cb14a3feSDimitry Andric    size_type __n,
1644*cb14a3feSDimitry Andric    const hasher& __hf,
1645*cb14a3feSDimitry Andric    const key_equal& __eql,
16460b57cec5SDimitry Andric    const allocator_type& __a)
1647*cb14a3feSDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
1648753f127fSDimitry Andric  __table_.__rehash_unique(__n);
16490b57cec5SDimitry Andric  insert(__first, __last);
16500b57cec5SDimitry Andric}
16510b57cec5SDimitry Andric
16520b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1653*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_map& __u) : __table_(__u.__table_) {
1654753f127fSDimitry Andric  __table_.__rehash_unique(__u.bucket_count());
16550b57cec5SDimitry Andric  insert(__u.begin(), __u.end());
16560b57cec5SDimitry Andric}
16570b57cec5SDimitry Andric
16580b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1659*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_map& __u, const allocator_type& __a)
1660*cb14a3feSDimitry Andric    : __table_(__u.__table_, typename __table::allocator_type(__a)) {
1661753f127fSDimitry Andric  __table_.__rehash_unique(__u.bucket_count());
16620b57cec5SDimitry Andric  insert(__u.begin(), __u.end());
16630b57cec5SDimitry Andric}
16640b57cec5SDimitry Andric
16650b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
16660b57cec5SDimitry Andric
16670b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1668*cb14a3feSDimitry Andricinline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __u)
16690b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1670*cb14a3feSDimitry Andric    : __table_(std::move(__u.__table_)) {}
16710b57cec5SDimitry Andric
16720b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1673*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __u, const allocator_type& __a)
1674*cb14a3feSDimitry Andric    : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) {
1675*cb14a3feSDimitry Andric  if (__a != __u.get_allocator()) {
16760b57cec5SDimitry Andric    iterator __i = __u.begin();
16770b57cec5SDimitry Andric    while (__u.size() != 0) {
1678*cb14a3feSDimitry Andric      __table_.__emplace_unique(__u.__table_.remove((__i++).__i_)->__get_value().__move());
16790b57cec5SDimitry Andric    }
16800b57cec5SDimitry Andric  }
16810b57cec5SDimitry Andric}
16820b57cec5SDimitry Andric
16830b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1684*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(initializer_list<value_type> __il) {
16850b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
16860b57cec5SDimitry Andric}
16870b57cec5SDimitry Andric
16880b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16890b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1690*cb14a3feSDimitry Andric    initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql)
1691*cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
1692753f127fSDimitry Andric  __table_.__rehash_unique(__n);
16930b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
16940b57cec5SDimitry Andric}
16950b57cec5SDimitry Andric
16960b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16970b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1698*cb14a3feSDimitry Andric    initializer_list<value_type> __il,
1699*cb14a3feSDimitry Andric    size_type __n,
1700*cb14a3feSDimitry Andric    const hasher& __hf,
1701*cb14a3feSDimitry Andric    const key_equal& __eql,
1702*cb14a3feSDimitry Andric    const allocator_type& __a)
1703*cb14a3feSDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
1704753f127fSDimitry Andric  __table_.__rehash_unique(__n);
17050b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
17060b57cec5SDimitry Andric}
17070b57cec5SDimitry Andric
17080b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1709*cb14a3feSDimitry Andricinline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
17100b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
1711*cb14a3feSDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) {
17125f757f3fSDimitry Andric  __table_ = std::move(__u.__table_);
17130b57cec5SDimitry Andric  return *this;
17140b57cec5SDimitry Andric}
17150b57cec5SDimitry Andric
17160b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1717*cb14a3feSDimitry Andricinline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
1718*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) {
17190b57cec5SDimitry Andric  __table_.__assign_unique(__il.begin(), __il.end());
17200b57cec5SDimitry Andric  return *this;
17210b57cec5SDimitry Andric}
17220b57cec5SDimitry Andric
17230b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
17240b57cec5SDimitry Andric
17250b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17260b57cec5SDimitry Andrictemplate <class _InputIterator>
1727*cb14a3feSDimitry Andricinline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
17280b57cec5SDimitry Andric  for (; __first != __last; ++__first)
17290b57cec5SDimitry Andric    __table_.__insert_unique(*__first);
17300b57cec5SDimitry Andric}
17310b57cec5SDimitry Andric
17320b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
17330b57cec5SDimitry Andric
17340b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1735*cb14a3feSDimitry Andric_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) {
1736*cb14a3feSDimitry Andric  return __table_
1737*cb14a3feSDimitry Andric      .__emplace_unique_key_args(__k, piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple())
1738*cb14a3feSDimitry Andric      .first->__get_value()
1739*cb14a3feSDimitry Andric      .second;
17400b57cec5SDimitry Andric}
17410b57cec5SDimitry Andric
17420b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1743*cb14a3feSDimitry Andric_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k) {
1744*cb14a3feSDimitry Andric  return __table_
1745*cb14a3feSDimitry Andric      .__emplace_unique_key_args(
1746*cb14a3feSDimitry Andric          __k, piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple())
1747*cb14a3feSDimitry Andric      .first->__get_value()
1748*cb14a3feSDimitry Andric      .second;
17490b57cec5SDimitry Andric}
17500b57cec5SDimitry Andric#else // _LIBCPP_CXX03_LANG
17510b57cec5SDimitry Andric
17520b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17530b57cec5SDimitry Andrictypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1754*cb14a3feSDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k) {
17550b57cec5SDimitry Andric  __node_allocator& __na = __table_.__node_alloc();
17560b57cec5SDimitry Andric  __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
17575f757f3fSDimitry Andric  __node_traits::construct(__na, std::addressof(__h->__get_value().__get_value().first), __k);
17580b57cec5SDimitry Andric  __h.get_deleter().__first_constructed = true;
17595f757f3fSDimitry Andric  __node_traits::construct(__na, std::addressof(__h->__get_value().__get_value().second));
17600b57cec5SDimitry Andric  __h.get_deleter().__second_constructed = true;
1761e8d8bef9SDimitry Andric  return __h;
17620b57cec5SDimitry Andric}
17630b57cec5SDimitry Andric
17640b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1765*cb14a3feSDimitry Andric_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) {
17660b57cec5SDimitry Andric  iterator __i = find(__k);
17670b57cec5SDimitry Andric  if (__i != end())
17680b57cec5SDimitry Andric    return __i->second;
17690b57cec5SDimitry Andric  __node_holder __h        = __construct_node_with_key(__k);
17700b57cec5SDimitry Andric  pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
17710b57cec5SDimitry Andric  __h.release();
17720b57cec5SDimitry Andric  return __r.first->second;
17730b57cec5SDimitry Andric}
17740b57cec5SDimitry Andric
1775fe6060f1SDimitry Andric#endif // _LIBCPP_CXX03_LANG
17760b57cec5SDimitry Andric
17770b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1778*cb14a3feSDimitry Andric_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) {
17790b57cec5SDimitry Andric  iterator __i = find(__k);
17800b57cec5SDimitry Andric  if (__i == end())
17810b57cec5SDimitry Andric    __throw_out_of_range("unordered_map::at: key not found");
17820b57cec5SDimitry Andric  return __i->second;
17830b57cec5SDimitry Andric}
17840b57cec5SDimitry Andric
17850b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1786*cb14a3feSDimitry Andricconst _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const {
17870b57cec5SDimitry Andric  const_iterator __i = find(__k);
17880b57cec5SDimitry Andric  if (__i == end())
17890b57cec5SDimitry Andric    __throw_out_of_range("unordered_map::at: key not found");
17900b57cec5SDimitry Andric  return __i->second;
17910b57cec5SDimitry Andric}
17920b57cec5SDimitry Andric
17930b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1794*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
1795*cb14a3feSDimitry Andricswap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1796*cb14a3feSDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
17970b57cec5SDimitry Andric  __x.swap(__y);
17980b57cec5SDimitry Andric}
17990b57cec5SDimitry Andric
180006c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1801*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>
1802*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
1803*cb14a3feSDimitry Andricerase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
18045f757f3fSDimitry Andric  return std::__libcpp_erase_if_container(__c, __pred);
18055ffd83dbSDimitry Andric}
18060b57cec5SDimitry Andric#endif
18070b57cec5SDimitry Andric
18080b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1809*cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1810*cb14a3feSDimitry Andric                                      const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) {
18110b57cec5SDimitry Andric  if (__x.size() != __y.size())
18120b57cec5SDimitry Andric    return false;
1813*cb14a3feSDimitry Andric  typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator const_iterator;
1814*cb14a3feSDimitry Andric  for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); __i != __ex; ++__i) {
18150b57cec5SDimitry Andric    const_iterator __j = __y.find(__i->first);
18160b57cec5SDimitry Andric    if (__j == __ey || !(*__i == *__j))
18170b57cec5SDimitry Andric      return false;
18180b57cec5SDimitry Andric  }
18190b57cec5SDimitry Andric  return true;
18200b57cec5SDimitry Andric}
18210b57cec5SDimitry Andric
182206c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
182306c3fb27SDimitry Andric
18240b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1825*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1826*cb14a3feSDimitry Andric                                             const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) {
18270b57cec5SDimitry Andric  return !(__x == __y);
18280b57cec5SDimitry Andric}
18290b57cec5SDimitry Andric
183006c3fb27SDimitry Andric#endif
183106c3fb27SDimitry Andric
1832*cb14a3feSDimitry Andrictemplate <class _Key,
1833*cb14a3feSDimitry Andric          class _Tp,
1834*cb14a3feSDimitry Andric          class _Hash  = hash<_Key>,
1835*cb14a3feSDimitry Andric          class _Pred  = equal_to<_Key>,
18360b57cec5SDimitry Andric          class _Alloc = allocator<pair<const _Key, _Tp> > >
1837*cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multimap {
18380b57cec5SDimitry Andricpublic:
18390b57cec5SDimitry Andric  // types
18400b57cec5SDimitry Andric  typedef _Key key_type;
18410b57cec5SDimitry Andric  typedef _Tp mapped_type;
184281ad6265SDimitry Andric  typedef __type_identity_t<_Hash> hasher;
184381ad6265SDimitry Andric  typedef __type_identity_t<_Pred> key_equal;
184481ad6265SDimitry Andric  typedef __type_identity_t<_Alloc> allocator_type;
18450b57cec5SDimitry Andric  typedef pair<const key_type, mapped_type> value_type;
18460b57cec5SDimitry Andric  typedef value_type& reference;
18470b57cec5SDimitry Andric  typedef const value_type& const_reference;
18480b57cec5SDimitry Andric  static_assert((is_same<value_type, typename allocator_type::value_type>::value),
184906c3fb27SDimitry Andric                "Allocator::value_type must be same type as value_type");
18500b57cec5SDimitry Andric
18510b57cec5SDimitry Andricprivate:
18520b57cec5SDimitry Andric  typedef __hash_value_type<key_type, mapped_type> __value_type;
1853e8d8bef9SDimitry Andric  typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
1854e8d8bef9SDimitry Andric  typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
1855bdd1243dSDimitry Andric  typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
18560b57cec5SDimitry Andric
1857*cb14a3feSDimitry Andric  typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table;
18580b57cec5SDimitry Andric
18590b57cec5SDimitry Andric  __table __table_;
18600b57cec5SDimitry Andric
18610b57cec5SDimitry Andric  typedef typename __table::_NodeTypes _NodeTypes;
18620b57cec5SDimitry Andric  typedef typename __table::__node_traits __node_traits;
18630b57cec5SDimitry Andric  typedef typename __table::__node_allocator __node_allocator;
18640b57cec5SDimitry Andric  typedef typename __table::__node __node;
18650b57cec5SDimitry Andric  typedef __hash_map_node_destructor<__node_allocator> _Dp;
18660b57cec5SDimitry Andric  typedef unique_ptr<__node, _Dp> __node_holder;
18670b57cec5SDimitry Andric  typedef allocator_traits<allocator_type> __alloc_traits;
1868*cb14a3feSDimitry Andric  static_assert((is_same<typename __node_traits::size_type, typename __alloc_traits::size_type>::value),
18690b57cec5SDimitry Andric                "Allocator uses different size_type for different types");
1870bdd1243dSDimitry Andric
1871bdd1243dSDimitry Andric  static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1872bdd1243dSDimitry Andric                "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1873bdd1243dSDimitry Andric                "original allocator");
1874bdd1243dSDimitry Andric
18750b57cec5SDimitry Andricpublic:
18760b57cec5SDimitry Andric  typedef typename __alloc_traits::pointer pointer;
18770b57cec5SDimitry Andric  typedef typename __alloc_traits::const_pointer const_pointer;
18780b57cec5SDimitry Andric  typedef typename __table::size_type size_type;
18790b57cec5SDimitry Andric  typedef typename __table::difference_type difference_type;
18800b57cec5SDimitry Andric
18810b57cec5SDimitry Andric  typedef __hash_map_iterator<typename __table::iterator> iterator;
18820b57cec5SDimitry Andric  typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
18830b57cec5SDimitry Andric  typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
18840b57cec5SDimitry Andric  typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
18850b57cec5SDimitry Andric
188606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
18870b57cec5SDimitry Andric  typedef __map_node_handle<__node, allocator_type> node_type;
18880b57cec5SDimitry Andric#endif
18890b57cec5SDimitry Andric
18900b57cec5SDimitry Andric  template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
18910b57cec5SDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_map;
18920b57cec5SDimitry Andric  template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
18930b57cec5SDimitry Andric  friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
18940b57cec5SDimitry Andric
1895*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
1896*cb14a3feSDimitry Andric  explicit _LIBCPP_HIDE_FROM_ABI
1897*cb14a3feSDimitry Andric  unordered_multimap(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
18985f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
1899*cb14a3feSDimitry Andric  unordered_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
19000b57cec5SDimitry Andric  template <class _InputIterator>
190106c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(_InputIterator __first, _InputIterator __last);
19020b57cec5SDimitry Andric  template <class _InputIterator>
1903*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(
1904*cb14a3feSDimitry Andric      _InputIterator __first,
1905*cb14a3feSDimitry Andric      _InputIterator __last,
1906*cb14a3feSDimitry Andric      size_type __n,
1907*cb14a3feSDimitry Andric      const hasher& __hf     = hasher(),
19080b57cec5SDimitry Andric      const key_equal& __eql = key_equal());
19090b57cec5SDimitry Andric  template <class _InputIterator>
1910*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(
1911*cb14a3feSDimitry Andric      _InputIterator __first,
1912*cb14a3feSDimitry Andric      _InputIterator __last,
1913*cb14a3feSDimitry Andric      size_type __n,
1914*cb14a3feSDimitry Andric      const hasher& __hf,
19150b57cec5SDimitry Andric      const key_equal& __eql,
19160b57cec5SDimitry Andric      const allocator_type& __a);
191706c3fb27SDimitry Andric
191806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
191906c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
1920*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(
1921*cb14a3feSDimitry Andric      from_range_t,
1922*cb14a3feSDimitry Andric      _Range&& __range,
1923*cb14a3feSDimitry Andric      size_type __n             = /*implementation-defined*/ 0,
1924*cb14a3feSDimitry Andric      const hasher& __hf        = hasher(),
1925*cb14a3feSDimitry Andric      const key_equal& __eql    = key_equal(),
192606c3fb27SDimitry Andric      const allocator_type& __a = allocator_type())
192706c3fb27SDimitry Andric      : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
192806c3fb27SDimitry Andric    if (__n > 0) {
192906c3fb27SDimitry Andric      __table_.__rehash_multi(__n);
193006c3fb27SDimitry Andric    }
193106c3fb27SDimitry Andric    insert_range(std::forward<_Range>(__range));
193206c3fb27SDimitry Andric  }
193306c3fb27SDimitry Andric#endif
193406c3fb27SDimitry Andric
1935*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit unordered_multimap(const allocator_type& __a);
193606c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u);
193706c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
19380b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1939*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u)
19400b57cec5SDimitry Andric      _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
194106c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
194206c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il);
1943*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(
1944*cb14a3feSDimitry Andric      initializer_list<value_type> __il,
1945*cb14a3feSDimitry Andric      size_type __n,
19460b57cec5SDimitry Andric      const hasher& __hf     = hasher(),
19470b57cec5SDimitry Andric      const key_equal& __eql = key_equal());
1948*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(
1949*cb14a3feSDimitry Andric      initializer_list<value_type> __il,
1950*cb14a3feSDimitry Andric      size_type __n,
1951*cb14a3feSDimitry Andric      const hasher& __hf,
1952*cb14a3feSDimitry Andric      const key_equal& __eql,
19530b57cec5SDimitry Andric      const allocator_type& __a);
19540b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
195506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14
1956*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const allocator_type& __a)
19570b57cec5SDimitry Andric      : unordered_multimap(__n, hasher(), key_equal(), __a) {}
1958*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
19590b57cec5SDimitry Andric      : unordered_multimap(__n, __hf, key_equal(), __a) {}
19600b57cec5SDimitry Andric  template <class _InputIterator>
19615f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
19620b57cec5SDimitry Andric  unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
19630b57cec5SDimitry Andric      : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
19640b57cec5SDimitry Andric  template <class _InputIterator>
1965*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(
1966*cb14a3feSDimitry Andric      _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
19670b57cec5SDimitry Andric      : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
196806c3fb27SDimitry Andric
196906c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
197006c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
1971*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
197206c3fb27SDimitry Andric      : unordered_multimap(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
197306c3fb27SDimitry Andric
197406c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
197506c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI
197606c3fb27SDimitry Andric  unordered_multimap(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
197706c3fb27SDimitry Andric      : unordered_multimap(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
197806c3fb27SDimitry Andric#  endif
197906c3fb27SDimitry Andric
1980*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
19810b57cec5SDimitry Andric      : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
19825f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
1983*cb14a3feSDimitry Andric  unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
19840b57cec5SDimitry Andric      : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
19850b57cec5SDimitry Andric#endif
1986*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ~unordered_multimap() {
1987bdd1243dSDimitry Andric    static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
19880b57cec5SDimitry Andric  }
19890b57cec5SDimitry Andric
1990*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(const unordered_multimap& __u) {
19910b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
19920b57cec5SDimitry Andric    __table_ = __u.__table_;
19930b57cec5SDimitry Andric#else
19945f757f3fSDimitry Andric    if (this != std::addressof(__u)) {
19950b57cec5SDimitry Andric      __table_.clear();
19960b57cec5SDimitry Andric      __table_.hash_function()   = __u.__table_.hash_function();
19970b57cec5SDimitry Andric      __table_.key_eq()          = __u.__table_.key_eq();
19980b57cec5SDimitry Andric      __table_.max_load_factor() = __u.__table_.max_load_factor();
19990b57cec5SDimitry Andric      __table_.__copy_assign_alloc(__u.__table_);
20000b57cec5SDimitry Andric      insert(__u.begin(), __u.end());
20010b57cec5SDimitry Andric    }
20020b57cec5SDimitry Andric#endif
20030b57cec5SDimitry Andric    return *this;
20040b57cec5SDimitry Andric  }
20050b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2006*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(unordered_multimap&& __u)
20070b57cec5SDimitry Andric      _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
2008*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(initializer_list<value_type> __il);
20090b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
20100b57cec5SDimitry Andric
2011*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
2012*cb14a3feSDimitry Andric    return allocator_type(__table_.__node_alloc());
2013*cb14a3feSDimitry Andric  }
20140b57cec5SDimitry Andric
2015*cb14a3feSDimitry Andric  _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
2016*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
2017*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
20180b57cec5SDimitry Andric
2019*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __table_.begin(); }
2020*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __table_.end(); }
2021*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __table_.begin(); }
2022*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __table_.end(); }
2023*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
2024*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
20250b57cec5SDimitry Andric
2026*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); }
20270b57cec5SDimitry Andric
2028*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) {
2029*cb14a3feSDimitry Andric    return __table_.__insert_multi(__p.__i_, __x);
2030*cb14a3feSDimitry Andric  }
20310b57cec5SDimitry Andric
20320b57cec5SDimitry Andric  template <class _InputIterator>
2033*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
20340b57cec5SDimitry Andric
203506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
203606c3fb27SDimitry Andric  template <_ContainerCompatibleRange<value_type> _Range>
2037*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
203806c3fb27SDimitry Andric    for (auto&& __element : __range) {
203906c3fb27SDimitry Andric      __table_.__insert_multi(std::forward<decltype(__element)>(__element));
204006c3fb27SDimitry Andric    }
204106c3fb27SDimitry Andric  }
204206c3fb27SDimitry Andric#endif
204306c3fb27SDimitry Andric
20440b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2045*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
2046*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__insert_multi(std::move(__x)); }
20470b57cec5SDimitry Andric
2048*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) {
2049*cb14a3feSDimitry Andric    return __table_.__insert_multi(__p.__i_, std::move(__x));
2050*cb14a3feSDimitry Andric  }
20510b57cec5SDimitry Andric
2052*cb14a3feSDimitry Andric  template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
2053*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __x) {
2054*cb14a3feSDimitry Andric    return __table_.__insert_multi(std::forward<_Pp>(__x));
2055*cb14a3feSDimitry Andric  }
20560b57cec5SDimitry Andric
2057*cb14a3feSDimitry Andric  template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
2058*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _Pp&& __x) {
2059*cb14a3feSDimitry Andric    return __table_.__insert_multi(__p.__i_, std::forward<_Pp>(__x));
2060*cb14a3feSDimitry Andric  }
20610b57cec5SDimitry Andric
20620b57cec5SDimitry Andric  template <class... _Args>
206306c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
20645f757f3fSDimitry Andric    return __table_.__emplace_multi(std::forward<_Args>(__args)...);
20650b57cec5SDimitry Andric  }
20660b57cec5SDimitry Andric
20670b57cec5SDimitry Andric  template <class... _Args>
206806c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
20695f757f3fSDimitry Andric    return __table_.__emplace_hint_multi(__p.__i_, std::forward<_Args>(__args)...);
20700b57cec5SDimitry Andric  }
20710b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
20720b57cec5SDimitry Andric
2073*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); }
2074*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); }
2075*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_multi(__k); }
2076*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
2077*cb14a3feSDimitry Andric    return __table_.erase(__first.__i_, __last.__i_);
2078*cb14a3feSDimitry Andric  }
2079*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
20800b57cec5SDimitry Andric
208106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
2082*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {
208306c3fb27SDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
20840b57cec5SDimitry Andric                                        "node_type with incompatible allocator passed to unordered_multimap::insert()");
2085*cb14a3feSDimitry Andric    return __table_.template __node_handle_insert_multi<node_type>(std::move(__nh));
20860b57cec5SDimitry Andric  }
2087*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {
208806c3fb27SDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
20890b57cec5SDimitry Andric                                        "node_type with incompatible allocator passed to unordered_multimap::insert()");
2090*cb14a3feSDimitry Andric    return __table_.template __node_handle_insert_multi<node_type>(__hint.__i_, std::move(__nh));
20910b57cec5SDimitry Andric  }
2092*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
20930b57cec5SDimitry Andric    return __table_.template __node_handle_extract<node_type>(__key);
20940b57cec5SDimitry Andric  }
2095*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {
2096*cb14a3feSDimitry Andric    return __table_.template __node_handle_extract<node_type>(__it.__i_);
20970b57cec5SDimitry Andric  }
20980b57cec5SDimitry Andric
20990b57cec5SDimitry Andric  template <class _H2, class _P2>
2100*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source) {
2101*cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
2102*cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
21030b57cec5SDimitry Andric    return __table_.__node_handle_merge_multi(__source.__table_);
21040b57cec5SDimitry Andric  }
21050b57cec5SDimitry Andric  template <class _H2, class _P2>
2106*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source) {
2107*cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
2108*cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
21090b57cec5SDimitry Andric    return __table_.__node_handle_merge_multi(__source.__table_);
21100b57cec5SDimitry Andric  }
21110b57cec5SDimitry Andric  template <class _H2, class _P2>
2112*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source) {
2113*cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
2114*cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
21150b57cec5SDimitry Andric    return __table_.__node_handle_merge_multi(__source.__table_);
21160b57cec5SDimitry Andric  }
21170b57cec5SDimitry Andric  template <class _H2, class _P2>
2118*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source) {
2119*cb14a3feSDimitry Andric    _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
2120*cb14a3feSDimitry Andric        __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
21210b57cec5SDimitry Andric    return __table_.__node_handle_merge_multi(__source.__table_);
21220b57cec5SDimitry Andric  }
21230b57cec5SDimitry Andric#endif
21240b57cec5SDimitry Andric
2125*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) {
2126*cb14a3feSDimitry Andric    __table_.swap(__u.__table_);
2127*cb14a3feSDimitry Andric  }
21280b57cec5SDimitry Andric
2129*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI hasher hash_function() const { return __table_.hash_function().hash_function(); }
2130*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI key_equal key_eq() const { return __table_.key_eq().key_eq(); }
21310b57cec5SDimitry Andric
2132*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
2133*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
213406c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
2135*cb14a3feSDimitry Andric  template <class _K2,
2136*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2137*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
2138*cb14a3feSDimitry Andric    return __table_.find(__k);
2139*cb14a3feSDimitry Andric  }
2140*cb14a3feSDimitry Andric  template <class _K2,
2141*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2142*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
2143*cb14a3feSDimitry Andric    return __table_.find(__k);
2144*cb14a3feSDimitry Andric  }
214506c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
2146349cc55cSDimitry Andric
2147*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); }
214806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
2149*cb14a3feSDimitry Andric  template <class _K2,
2150*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2151*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
2152*cb14a3feSDimitry Andric    return __table_.__count_multi(__k);
2153*cb14a3feSDimitry Andric  }
215406c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
2155349cc55cSDimitry Andric
215606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
2157*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
2158e8d8bef9SDimitry Andric
2159*cb14a3feSDimitry Andric  template <class _K2,
2160*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2161*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
2162*cb14a3feSDimitry Andric    return find(__k) != end();
2163*cb14a3feSDimitry Andric  }
216406c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
2165349cc55cSDimitry Andric
2166*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
2167*cb14a3feSDimitry Andric    return __table_.__equal_range_multi(__k);
2168*cb14a3feSDimitry Andric  }
2169*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
2170*cb14a3feSDimitry Andric    return __table_.__equal_range_multi(__k);
2171*cb14a3feSDimitry Andric  }
217206c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
2173*cb14a3feSDimitry Andric  template <class _K2,
2174*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2175*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
2176*cb14a3feSDimitry Andric    return __table_.__equal_range_multi(__k);
2177*cb14a3feSDimitry Andric  }
2178*cb14a3feSDimitry Andric  template <class _K2,
2179*cb14a3feSDimitry Andric            enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2180*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
2181*cb14a3feSDimitry Andric    return __table_.__equal_range_multi(__k);
2182*cb14a3feSDimitry Andric  }
218306c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
21840b57cec5SDimitry Andric
2185*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }
2186*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }
21870b57cec5SDimitry Andric
2188*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket_size(size_type __n) const { return __table_.bucket_size(__n); }
2189*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type bucket(const key_type& __k) const { return __table_.bucket(__k); }
21900b57cec5SDimitry Andric
2191*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) { return __table_.begin(__n); }
2192*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) { return __table_.end(__n); }
2193*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator begin(size_type __n) const { return __table_.cbegin(__n); }
2194*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator end(size_type __n) const { return __table_.cend(__n); }
2195*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const { return __table_.cbegin(__n); }
2196*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const { return __table_.cend(__n); }
21970b57cec5SDimitry Andric
2198*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI float load_factor() const _NOEXCEPT { return __table_.load_factor(); }
2199*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __table_.max_load_factor(); }
2200*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) { __table_.max_load_factor(__mlf); }
2201*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void rehash(size_type __n) { __table_.__rehash_multi(__n); }
2202*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); }
22030b57cec5SDimitry Andric};
22040b57cec5SDimitry Andric
2205349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
22060b57cec5SDimitry Andrictemplate <class _InputIterator,
22070b57cec5SDimitry Andric          class _Hash      = hash<__iter_key_type<_InputIterator>>,
22080b57cec5SDimitry Andric          class _Pred      = equal_to<__iter_key_type<_InputIterator>>,
22090b57cec5SDimitry Andric          class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
221006c3fb27SDimitry Andric          class            = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
2211349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
2212349cc55cSDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
2213349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
2214349cc55cSDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
2215*cb14a3feSDimitry Andricunordered_multimap(_InputIterator,
2216*cb14a3feSDimitry Andric                   _InputIterator,
2217*cb14a3feSDimitry Andric                   typename allocator_traits<_Allocator>::size_type = 0,
2218*cb14a3feSDimitry Andric                   _Hash                                            = _Hash(),
2219*cb14a3feSDimitry Andric                   _Pred                                            = _Pred(),
2220*cb14a3feSDimitry Andric                   _Allocator                                       = _Allocator())
2221*cb14a3feSDimitry Andric    -> unordered_multimap<__iter_key_type<_InputIterator>,
2222*cb14a3feSDimitry Andric                          __iter_mapped_type<_InputIterator>,
2223*cb14a3feSDimitry Andric                          _Hash,
2224*cb14a3feSDimitry Andric                          _Pred,
2225*cb14a3feSDimitry Andric                          _Allocator>;
22260b57cec5SDimitry Andric
222706c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
222806c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
222906c3fb27SDimitry Andric          class _Hash      = hash<__range_key_type<_Range>>,
223006c3fb27SDimitry Andric          class _Pred      = equal_to<__range_key_type<_Range>>,
223106c3fb27SDimitry Andric          class _Allocator = allocator<__range_to_alloc_type<_Range>>,
223206c3fb27SDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
223306c3fb27SDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
223406c3fb27SDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
223506c3fb27SDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
2236*cb14a3feSDimitry Andricunordered_multimap(from_range_t,
2237*cb14a3feSDimitry Andric                   _Range&&,
2238*cb14a3feSDimitry Andric                   typename allocator_traits<_Allocator>::size_type = 0,
2239*cb14a3feSDimitry Andric                   _Hash                                            = _Hash(),
2240*cb14a3feSDimitry Andric                   _Pred                                            = _Pred(),
2241*cb14a3feSDimitry Andric                   _Allocator                                       = _Allocator())
224206c3fb27SDimitry Andric    -> unordered_multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>;
224306c3fb27SDimitry Andric#  endif
224406c3fb27SDimitry Andric
2245*cb14a3feSDimitry Andrictemplate <class _Key,
2246*cb14a3feSDimitry Andric          class _Tp,
2247*cb14a3feSDimitry Andric          class _Hash      = hash<remove_const_t<_Key>>,
22480b57cec5SDimitry Andric          class _Pred      = equal_to<remove_const_t<_Key>>,
22490b57cec5SDimitry Andric          class _Allocator = allocator<pair<const _Key, _Tp>>,
2250349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Hash>::value>,
2251349cc55cSDimitry Andric          class            = enable_if_t<!is_integral<_Hash>::value>,
2252349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Pred>::value>,
2253349cc55cSDimitry Andric          class            = enable_if_t<__is_allocator<_Allocator>::value>>
2254*cb14a3feSDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>,
2255*cb14a3feSDimitry Andric                   typename allocator_traits<_Allocator>::size_type = 0,
2256*cb14a3feSDimitry Andric                   _Hash                                            = _Hash(),
2257*cb14a3feSDimitry Andric                   _Pred                                            = _Pred(),
2258*cb14a3feSDimitry Andric                   _Allocator                                       = _Allocator())
22590b57cec5SDimitry Andric    -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
22600b57cec5SDimitry Andric
2261*cb14a3feSDimitry Andrictemplate <class _InputIterator,
2262*cb14a3feSDimitry Andric          class _Allocator,
226306c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
2264349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
22650b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
2266*cb14a3feSDimitry Andric    -> unordered_multimap<__iter_key_type<_InputIterator>,
2267*cb14a3feSDimitry Andric                          __iter_mapped_type<_InputIterator>,
2268*cb14a3feSDimitry Andric                          hash<__iter_key_type<_InputIterator>>,
2269*cb14a3feSDimitry Andric                          equal_to<__iter_key_type<_InputIterator>>,
2270*cb14a3feSDimitry Andric                          _Allocator>;
22710b57cec5SDimitry Andric
2272*cb14a3feSDimitry Andrictemplate <class _InputIterator,
2273*cb14a3feSDimitry Andric          class _Allocator,
227406c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
2275349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
22760b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, _Allocator)
2277*cb14a3feSDimitry Andric    -> unordered_multimap<__iter_key_type<_InputIterator>,
2278*cb14a3feSDimitry Andric                          __iter_mapped_type<_InputIterator>,
2279*cb14a3feSDimitry Andric                          hash<__iter_key_type<_InputIterator>>,
2280*cb14a3feSDimitry Andric                          equal_to<__iter_key_type<_InputIterator>>,
2281*cb14a3feSDimitry Andric                          _Allocator>;
22820b57cec5SDimitry Andric
2283*cb14a3feSDimitry Andrictemplate <class _InputIterator,
2284*cb14a3feSDimitry Andric          class _Hash,
2285*cb14a3feSDimitry Andric          class _Allocator,
228606c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
2287349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
2288349cc55cSDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
2289349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
22900b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
2291*cb14a3feSDimitry Andric    -> unordered_multimap<__iter_key_type<_InputIterator>,
2292*cb14a3feSDimitry Andric                          __iter_mapped_type<_InputIterator>,
2293*cb14a3feSDimitry Andric                          _Hash,
2294*cb14a3feSDimitry Andric                          equal_to<__iter_key_type<_InputIterator>>,
2295*cb14a3feSDimitry Andric                          _Allocator>;
22960b57cec5SDimitry Andric
229706c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
229806c3fb27SDimitry Andric
2299*cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
230006c3fb27SDimitry Andricunordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
2301*cb14a3feSDimitry Andric    -> unordered_multimap<__range_key_type<_Range>,
2302*cb14a3feSDimitry Andric                          __range_mapped_type<_Range>,
2303*cb14a3feSDimitry Andric                          hash<__range_key_type<_Range>>,
2304*cb14a3feSDimitry Andric                          equal_to<__range_key_type<_Range>>,
2305*cb14a3feSDimitry Andric                          _Allocator>;
230606c3fb27SDimitry Andric
2307*cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
230806c3fb27SDimitry Andricunordered_multimap(from_range_t, _Range&&, _Allocator)
2309*cb14a3feSDimitry Andric    -> unordered_multimap<__range_key_type<_Range>,
2310*cb14a3feSDimitry Andric                          __range_mapped_type<_Range>,
2311*cb14a3feSDimitry Andric                          hash<__range_key_type<_Range>>,
2312*cb14a3feSDimitry Andric                          equal_to<__range_key_type<_Range>>,
2313*cb14a3feSDimitry Andric                          _Allocator>;
231406c3fb27SDimitry Andric
2315*cb14a3feSDimitry Andrictemplate <ranges::input_range _Range,
2316*cb14a3feSDimitry Andric          class _Hash,
2317*cb14a3feSDimitry Andric          class _Allocator,
231806c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
231906c3fb27SDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
232006c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
232106c3fb27SDimitry Andricunordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
2322*cb14a3feSDimitry Andric    -> unordered_multimap<__range_key_type<_Range>,
2323*cb14a3feSDimitry Andric                          __range_mapped_type<_Range>,
2324*cb14a3feSDimitry Andric                          _Hash,
2325*cb14a3feSDimitry Andric                          equal_to<__range_key_type<_Range>>,
2326*cb14a3feSDimitry Andric                          _Allocator>;
232706c3fb27SDimitry Andric
232806c3fb27SDimitry Andric#  endif
232906c3fb27SDimitry Andric
2330*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
23310b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
2332*cb14a3feSDimitry Andric    -> unordered_multimap<remove_const_t<_Key>,
2333*cb14a3feSDimitry Andric                          _Tp,
23340b57cec5SDimitry Andric                          hash<remove_const_t<_Key>>,
2335*cb14a3feSDimitry Andric                          equal_to<remove_const_t<_Key>>,
2336*cb14a3feSDimitry Andric                          _Allocator>;
23370b57cec5SDimitry Andric
2338*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
23390b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
2340*cb14a3feSDimitry Andric    -> unordered_multimap<remove_const_t<_Key>,
2341*cb14a3feSDimitry Andric                          _Tp,
23420b57cec5SDimitry Andric                          hash<remove_const_t<_Key>>,
2343*cb14a3feSDimitry Andric                          equal_to<remove_const_t<_Key>>,
2344*cb14a3feSDimitry Andric                          _Allocator>;
23450b57cec5SDimitry Andric
2346*cb14a3feSDimitry Andrictemplate <class _Key,
2347*cb14a3feSDimitry Andric          class _Tp,
2348*cb14a3feSDimitry Andric          class _Hash,
2349*cb14a3feSDimitry Andric          class _Allocator,
2350349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
2351349cc55cSDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
2352349cc55cSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
2353*cb14a3feSDimitry Andricunordered_multimap(
2354*cb14a3feSDimitry Andric    initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
2355*cb14a3feSDimitry Andric    -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>;
23560b57cec5SDimitry Andric#endif
23570b57cec5SDimitry Andric
23580b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
23590b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
23600b57cec5SDimitry Andric    size_type __n, const hasher& __hf, const key_equal& __eql)
2361*cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
2362753f127fSDimitry Andric  __table_.__rehash_multi(__n);
23630b57cec5SDimitry Andric}
23640b57cec5SDimitry Andric
23650b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
23660b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2367*cb14a3feSDimitry Andric    size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
2368*cb14a3feSDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
2369*cb14a3feSDimitry Andric  __table_.__rehash_multi(__n);
2370*cb14a3feSDimitry Andric}
2371*cb14a3feSDimitry Andric
2372*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2373*cb14a3feSDimitry Andrictemplate <class _InputIterator>
2374*cb14a3feSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(_InputIterator __first, _InputIterator __last) {
2375*cb14a3feSDimitry Andric  insert(__first, __last);
2376*cb14a3feSDimitry Andric}
2377*cb14a3feSDimitry Andric
2378*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2379*cb14a3feSDimitry Andrictemplate <class _InputIterator>
2380*cb14a3feSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2381*cb14a3feSDimitry Andric    _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql)
2382*cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
2383*cb14a3feSDimitry Andric  __table_.__rehash_multi(__n);
2384*cb14a3feSDimitry Andric  insert(__first, __last);
2385*cb14a3feSDimitry Andric}
2386*cb14a3feSDimitry Andric
2387*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2388*cb14a3feSDimitry Andrictemplate <class _InputIterator>
2389*cb14a3feSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2390*cb14a3feSDimitry Andric    _InputIterator __first,
2391*cb14a3feSDimitry Andric    _InputIterator __last,
2392*cb14a3feSDimitry Andric    size_type __n,
2393*cb14a3feSDimitry Andric    const hasher& __hf,
2394*cb14a3feSDimitry Andric    const key_equal& __eql,
23950b57cec5SDimitry Andric    const allocator_type& __a)
2396*cb14a3feSDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
2397753f127fSDimitry Andric  __table_.__rehash_multi(__n);
23980b57cec5SDimitry Andric  insert(__first, __last);
23990b57cec5SDimitry Andric}
24000b57cec5SDimitry Andric
24010b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2402*cb14a3feSDimitry Andricinline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(const allocator_type& __a)
2403*cb14a3feSDimitry Andric    : __table_(typename __table::allocator_type(__a)) {}
24040b57cec5SDimitry Andric
24050b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2406*cb14a3feSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(const unordered_multimap& __u)
2407*cb14a3feSDimitry Andric    : __table_(__u.__table_) {
2408753f127fSDimitry Andric  __table_.__rehash_multi(__u.bucket_count());
24090b57cec5SDimitry Andric  insert(__u.begin(), __u.end());
24100b57cec5SDimitry Andric}
24110b57cec5SDimitry Andric
24120b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24130b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24140b57cec5SDimitry Andric    const unordered_multimap& __u, const allocator_type& __a)
2415*cb14a3feSDimitry Andric    : __table_(__u.__table_, typename __table::allocator_type(__a)) {
2416753f127fSDimitry Andric  __table_.__rehash_multi(__u.bucket_count());
24170b57cec5SDimitry Andric  insert(__u.begin(), __u.end());
24180b57cec5SDimitry Andric}
24190b57cec5SDimitry Andric
24200b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
24210b57cec5SDimitry Andric
24220b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2423*cb14a3feSDimitry Andricinline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(unordered_multimap&& __u)
24240b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
2425*cb14a3feSDimitry Andric    : __table_(std::move(__u.__table_)) {}
24260b57cec5SDimitry Andric
24270b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24280b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24290b57cec5SDimitry Andric    unordered_multimap&& __u, const allocator_type& __a)
2430*cb14a3feSDimitry Andric    : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) {
2431*cb14a3feSDimitry Andric  if (__a != __u.get_allocator()) {
24320b57cec5SDimitry Andric    iterator __i = __u.begin();
2433*cb14a3feSDimitry Andric    while (__u.size() != 0) {
2434*cb14a3feSDimitry Andric      __table_.__insert_multi(__u.__table_.remove((__i++).__i_)->__get_value().__move());
24350b57cec5SDimitry Andric    }
24360b57cec5SDimitry Andric  }
24370b57cec5SDimitry Andric}
24380b57cec5SDimitry Andric
24390b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2440*cb14a3feSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(initializer_list<value_type> __il) {
24410b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
24420b57cec5SDimitry Andric}
24430b57cec5SDimitry Andric
24440b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24450b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2446*cb14a3feSDimitry Andric    initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql)
2447*cb14a3feSDimitry Andric    : __table_(__hf, __eql) {
2448753f127fSDimitry Andric  __table_.__rehash_multi(__n);
24490b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
24500b57cec5SDimitry Andric}
24510b57cec5SDimitry Andric
24520b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24530b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2454*cb14a3feSDimitry Andric    initializer_list<value_type> __il,
2455*cb14a3feSDimitry Andric    size_type __n,
2456*cb14a3feSDimitry Andric    const hasher& __hf,
2457*cb14a3feSDimitry Andric    const key_equal& __eql,
2458*cb14a3feSDimitry Andric    const allocator_type& __a)
2459*cb14a3feSDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
2460753f127fSDimitry Andric  __table_.__rehash_multi(__n);
24610b57cec5SDimitry Andric  insert(__il.begin(), __il.end());
24620b57cec5SDimitry Andric}
24630b57cec5SDimitry Andric
24640b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2465*cb14a3feSDimitry Andricinline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
24660b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
2467*cb14a3feSDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) {
24685f757f3fSDimitry Andric  __table_ = std::move(__u.__table_);
24690b57cec5SDimitry Andric  return *this;
24700b57cec5SDimitry Andric}
24710b57cec5SDimitry Andric
24720b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2473*cb14a3feSDimitry Andricinline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
2474*cb14a3feSDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_type> __il) {
24750b57cec5SDimitry Andric  __table_.__assign_multi(__il.begin(), __il.end());
24760b57cec5SDimitry Andric  return *this;
24770b57cec5SDimitry Andric}
24780b57cec5SDimitry Andric
24790b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
24800b57cec5SDimitry Andric
24810b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24820b57cec5SDimitry Andrictemplate <class _InputIterator>
2483*cb14a3feSDimitry Andricinline void unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
24840b57cec5SDimitry Andric  for (; __first != __last; ++__first)
24850b57cec5SDimitry Andric    __table_.__insert_multi(*__first);
24860b57cec5SDimitry Andric}
24870b57cec5SDimitry Andric
24880b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2489*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
2490*cb14a3feSDimitry Andricswap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2491*cb14a3feSDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
24920b57cec5SDimitry Andric  __x.swap(__y);
24930b57cec5SDimitry Andric}
24940b57cec5SDimitry Andric
249506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
2496*cb14a3feSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>
2497*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
2498*cb14a3feSDimitry Andricerase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
24995f757f3fSDimitry Andric  return std::__libcpp_erase_if_container(__c, __pred);
25005ffd83dbSDimitry Andric}
25010b57cec5SDimitry Andric#endif
25020b57cec5SDimitry Andric
25030b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2504*cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2505*cb14a3feSDimitry Andric                                      const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) {
25060b57cec5SDimitry Andric  if (__x.size() != __y.size())
25070b57cec5SDimitry Andric    return false;
2508*cb14a3feSDimitry Andric  typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator const_iterator;
25090b57cec5SDimitry Andric  typedef pair<const_iterator, const_iterator> _EqRng;
2510*cb14a3feSDimitry Andric  for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) {
25110b57cec5SDimitry Andric    _EqRng __xeq = __x.equal_range(__i->first);
25120b57cec5SDimitry Andric    _EqRng __yeq = __y.equal_range(__i->first);
2513*cb14a3feSDimitry Andric    if (std::distance(__xeq.first, __xeq.second) != std::distance(__yeq.first, __yeq.second) ||
25145f757f3fSDimitry Andric        !std::is_permutation(__xeq.first, __xeq.second, __yeq.first))
25150b57cec5SDimitry Andric      return false;
25160b57cec5SDimitry Andric    __i = __xeq.second;
25170b57cec5SDimitry Andric  }
25180b57cec5SDimitry Andric  return true;
25190b57cec5SDimitry Andric}
25200b57cec5SDimitry Andric
252106c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
252206c3fb27SDimitry Andric
25230b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2524*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2525*cb14a3feSDimitry Andric                                             const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) {
25260b57cec5SDimitry Andric  return !(__x == __y);
25270b57cec5SDimitry Andric}
25280b57cec5SDimitry Andric
252906c3fb27SDimitry Andric#endif
253006c3fb27SDimitry Andric
25310b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
25320b57cec5SDimitry Andric
253306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
2534bdd1243dSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
2535bdd1243dSDimitry Andricnamespace pmr {
2536bdd1243dSDimitry Andrictemplate <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
253706c3fb27SDimitry Andricusing unordered_map _LIBCPP_AVAILABILITY_PMR =
2538bdd1243dSDimitry Andric    std::unordered_map<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2539bdd1243dSDimitry Andric
2540bdd1243dSDimitry Andrictemplate <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
254106c3fb27SDimitry Andricusing unordered_multimap _LIBCPP_AVAILABILITY_PMR =
2542bdd1243dSDimitry Andric    std::unordered_multimap<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2543bdd1243dSDimitry Andric} // namespace pmr
2544bdd1243dSDimitry Andric_LIBCPP_END_NAMESPACE_STD
2545bdd1243dSDimitry Andric#endif
2546bdd1243dSDimitry Andric
2547bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2548bdd1243dSDimitry Andric#  include <algorithm>
2549bdd1243dSDimitry Andric#  include <bit>
2550bdd1243dSDimitry Andric#  include <concepts>
255106c3fb27SDimitry Andric#  include <cstdlib>
2552bdd1243dSDimitry Andric#  include <iterator>
255306c3fb27SDimitry Andric#  include <type_traits>
2554bdd1243dSDimitry Andric#endif
2555bdd1243dSDimitry Andric
25560b57cec5SDimitry Andric#endif // _LIBCPP_UNORDERED_MAP
2557