xref: /freebsd/contrib/llvm-project/libcxx/include/unordered_map (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
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());
62*06c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
63*06c3fb27SDimitry Andric      unordered_map(from_range_t, R&& rg, size_type n = see below,
64*06c3fb27SDimitry Andric        const hasher& hf = hasher(), const key_equal& eql = key_equal(),
65*06c3fb27SDimitry Andric        const allocator_type& a = allocator_type()); // C++23
66*06c3fb27SDimitry 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
90*06c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
91*06c3fb27SDimitry Andric      unordered_map(from_range_t, R&& rg, size_type n, const allocator_type& a)
92*06c3fb27SDimitry Andric        : unordered_map(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
93*06c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
94*06c3fb27SDimitry Andric      unordered_map(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
95*06c3fb27SDimitry 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);
136*06c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
137*06c3fb27SDimitry 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
240*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash = hash<range-key-type<R>>,
241*06c3fb27SDimitry Andric         class Pred = equal_to<range-key-type<R>>,
242*06c3fb27SDimitry Andric         class Allocator = allocator<range-to-alloc-type<R>>>
243*06c3fb27SDimitry Andric  unordered_map(from_range_t, R&&, typename see below::size_type = see below,
244*06c3fb27SDimitry Andric                Hash = Hash(), Pred = Pred(), Allocator = Allocator())
245*06c3fb27SDimitry Andric    -> unordered_map<range-key-type<R>, range-mapped-type<R>, Hash, Pred, Allocator>; // C++23
246*06c3fb27SDimitry 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
268*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
269*06c3fb27SDimitry Andric  unordered_map(from_range_t, R&&, typename see below::size_type, Allocator)
270*06c3fb27SDimitry Andric    -> unordered_map<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
271*06c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
272*06c3fb27SDimitry Andric
273*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
274*06c3fb27SDimitry Andric  unordered_map(from_range_t, R&&, Allocator)
275*06c3fb27SDimitry Andric    -> unordered_map<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
276*06c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
277*06c3fb27SDimitry Andric
278*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator>
279*06c3fb27SDimitry Andric  unordered_map(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
280*06c3fb27SDimitry Andric    -> unordered_map<range-key-type<R>, range-mapped-type<R>, Hash,
281*06c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
282*06c3fb27SDimitry 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,
308*06c3fb27SDimitry 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());
349*06c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
350*06c3fb27SDimitry Andric      unordered_multimap(from_range_t, R&& rg, size_type n = see below,
351*06c3fb27SDimitry Andric        const hasher& hf = hasher(), const key_equal& eql = key_equal(),
352*06c3fb27SDimitry 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
376*06c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
377*06c3fb27SDimitry Andric      unordered_multimap(from_range_t, R&& rg, size_type n, const allocator_type& a)
378*06c3fb27SDimitry Andric        : unordered_multimap(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
379*06c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
380*06c3fb27SDimitry Andric      unordered_multimap(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
381*06c3fb27SDimitry 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);
422*06c3fb27SDimitry Andric    template<container-compatible-range<value_type> R>
423*06c3fb27SDimitry 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
503*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash = hash<range-key-type<R>>,
504*06c3fb27SDimitry Andric         class Pred = equal_to<range-key-type<R>>,
505*06c3fb27SDimitry Andric         class Allocator = allocator<range-to-alloc-type<R>>>
506*06c3fb27SDimitry Andric  unordered_multimap(from_range_t, R&&, typename see below::size_type = see below,
507*06c3fb27SDimitry Andric                Hash = Hash(), Pred = Pred(), Allocator = Allocator())
508*06c3fb27SDimitry Andric    -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, Hash, Pred, Allocator>; // C++23
509*06c3fb27SDimitry 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
531*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
532*06c3fb27SDimitry Andric  unordered_multimap(from_range_t, R&&, typename see below::size_type, Allocator)
533*06c3fb27SDimitry Andric    -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
534*06c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
535*06c3fb27SDimitry Andric
536*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
537*06c3fb27SDimitry Andric  unordered_multimap(from_range_t, R&&, Allocator)
538*06c3fb27SDimitry Andric    -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, hash<range-key-type<R>>,
539*06c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
540*06c3fb27SDimitry Andric
541*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Hash, class Allocator>
542*06c3fb27SDimitry Andric  unordered_multimap(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
543*06c3fb27SDimitry Andric    -> unordered_multimap<range-key-type<R>, range-mapped-type<R>, Hash,
544*06c3fb27SDimitry Andric                      equal_to<range-key-type<R>>, Allocator>;   // C++23
545*06c3fb27SDimitry 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,
580*06c3fb27SDimitry 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
588*06c3fb27SDimitry 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>
596*06c3fb27SDimitry 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>
601*06c3fb27SDimitry Andric#include <__ranges/concepts.h>
602*06c3fb27SDimitry Andric#include <__ranges/container_compatible_range.h>
603*06c3fb27SDimitry Andric#include <__ranges/from_range.h>
604bdd1243dSDimitry Andric#include <__type_traits/is_allocator.h>
605*06c3fb27SDimitry 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
630e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred,
6310b57cec5SDimitry Andric          bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
6320b57cec5SDimitry Andricclass __unordered_map_hasher
6330b57cec5SDimitry Andric    : private _Hash
6340b57cec5SDimitry Andric{
6350b57cec5SDimitry Andricpublic:
6360b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6370b57cec5SDimitry Andric    __unordered_map_hasher()
6380b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
6390b57cec5SDimitry Andric        : _Hash() {}
6400b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6410b57cec5SDimitry Andric    __unordered_map_hasher(const _Hash& __h)
6420b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
6430b57cec5SDimitry Andric        : _Hash(__h) {}
6440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6450b57cec5SDimitry Andric    const _Hash& hash_function() const _NOEXCEPT {return *this;}
6460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6470b57cec5SDimitry Andric    size_t operator()(const _Cp& __x) const
6480b57cec5SDimitry Andric        {return static_cast<const _Hash&>(*this)(__x.__get_value().first);}
6490b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6500b57cec5SDimitry Andric    size_t operator()(const _Key& __x) const
6510b57cec5SDimitry Andric        {return static_cast<const _Hash&>(*this)(__x);}
652*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
653349cc55cSDimitry Andric    template <typename _K2>
654e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
655e8d8bef9SDimitry Andric    size_t operator()(const _K2& __x) const
656e8d8bef9SDimitry Andric        {return static_cast<const _Hash&>(*this)(__x);}
657e8d8bef9SDimitry Andric#endif
658349cc55cSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6590b57cec5SDimitry Andric    void swap(__unordered_map_hasher& __y)
6600b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
6610b57cec5SDimitry Andric    {
6620b57cec5SDimitry Andric        using _VSTD::swap;
6630b57cec5SDimitry Andric        swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y));
6640b57cec5SDimitry Andric    }
6650b57cec5SDimitry Andric};
6660b57cec5SDimitry Andric
667e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred>
668e8d8bef9SDimitry Andricclass __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, false>
6690b57cec5SDimitry Andric{
6700b57cec5SDimitry Andric    _Hash __hash_;
6710b57cec5SDimitry Andricpublic:
6720b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6730b57cec5SDimitry Andric    __unordered_map_hasher()
6740b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
6750b57cec5SDimitry Andric        : __hash_() {}
6760b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6770b57cec5SDimitry Andric    __unordered_map_hasher(const _Hash& __h)
6780b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
6790b57cec5SDimitry Andric        : __hash_(__h) {}
6800b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6810b57cec5SDimitry Andric    const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
6820b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6830b57cec5SDimitry Andric    size_t operator()(const _Cp& __x) const
6840b57cec5SDimitry Andric        {return __hash_(__x.__get_value().first);}
6850b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6860b57cec5SDimitry Andric    size_t operator()(const _Key& __x) const
6870b57cec5SDimitry Andric        {return __hash_(__x);}
688*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
689349cc55cSDimitry Andric    template <typename _K2>
690e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
691e8d8bef9SDimitry Andric    size_t operator()(const _K2& __x) const
692e8d8bef9SDimitry Andric        {return __hash_(__x);}
693e8d8bef9SDimitry Andric#endif
694349cc55cSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6950b57cec5SDimitry Andric    void swap(__unordered_map_hasher& __y)
6960b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
6970b57cec5SDimitry Andric    {
6980b57cec5SDimitry Andric        using _VSTD::swap;
6990b57cec5SDimitry Andric        swap(__hash_, __y.__hash_);
7000b57cec5SDimitry Andric    }
7010b57cec5SDimitry Andric};
7020b57cec5SDimitry Andric
703e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred, bool __b>
7040b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
7050b57cec5SDimitry Andricvoid
706e8d8bef9SDimitry Andricswap(__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __x,
707e8d8bef9SDimitry Andric     __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y)
7080b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
7090b57cec5SDimitry Andric{
7100b57cec5SDimitry Andric    __x.swap(__y);
7110b57cec5SDimitry Andric}
7120b57cec5SDimitry Andric
713e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash,
7140b57cec5SDimitry Andric          bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
7150b57cec5SDimitry Andricclass __unordered_map_equal
7160b57cec5SDimitry Andric    : private _Pred
7170b57cec5SDimitry Andric{
7180b57cec5SDimitry Andricpublic:
7190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7200b57cec5SDimitry Andric    __unordered_map_equal()
7210b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
7220b57cec5SDimitry Andric        : _Pred() {}
7230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7240b57cec5SDimitry Andric    __unordered_map_equal(const _Pred& __p)
7250b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
7260b57cec5SDimitry Andric        : _Pred(__p) {}
7270b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7280b57cec5SDimitry Andric    const _Pred& key_eq() const _NOEXCEPT {return *this;}
7290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7300b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Cp& __y) const
7310b57cec5SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first);}
7320b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7330b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Key& __y) const
7340b57cec5SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
7350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7360b57cec5SDimitry Andric    bool operator()(const _Key& __x, const _Cp& __y) const
7370b57cec5SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
738*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
739349cc55cSDimitry Andric    template <typename _K2>
740e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
741e8d8bef9SDimitry Andric    bool operator()(const _Cp& __x, const _K2& __y) const
742e8d8bef9SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
743349cc55cSDimitry Andric    template <typename _K2>
744e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
745e8d8bef9SDimitry Andric    bool operator()(const _K2& __x, const _Cp& __y) const
746e8d8bef9SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
747349cc55cSDimitry Andric    template <typename _K2>
748e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
749e8d8bef9SDimitry Andric    bool operator()(const _Key& __x, const _K2& __y) const
750e8d8bef9SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x, __y);}
751349cc55cSDimitry Andric    template <typename _K2>
752e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
753e8d8bef9SDimitry Andric    bool operator()(const _K2& __x, const _Key& __y) const
754e8d8bef9SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x, __y);}
755e8d8bef9SDimitry Andric#endif
756349cc55cSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7570b57cec5SDimitry Andric    void swap(__unordered_map_equal& __y)
7580b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
7590b57cec5SDimitry Andric    {
7600b57cec5SDimitry Andric        using _VSTD::swap;
7610b57cec5SDimitry Andric        swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y));
7620b57cec5SDimitry Andric    }
7630b57cec5SDimitry Andric};
7640b57cec5SDimitry Andric
765e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash>
766e8d8bef9SDimitry Andricclass __unordered_map_equal<_Key, _Cp, _Pred, _Hash, false>
7670b57cec5SDimitry Andric{
7680b57cec5SDimitry Andric    _Pred __pred_;
7690b57cec5SDimitry Andricpublic:
7700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7710b57cec5SDimitry Andric    __unordered_map_equal()
7720b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
7730b57cec5SDimitry Andric        : __pred_() {}
7740b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7750b57cec5SDimitry Andric    __unordered_map_equal(const _Pred& __p)
7760b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
7770b57cec5SDimitry Andric        : __pred_(__p) {}
7780b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7790b57cec5SDimitry Andric    const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
7800b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7810b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Cp& __y) const
7820b57cec5SDimitry Andric        {return __pred_(__x.__get_value().first, __y.__get_value().first);}
7830b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7840b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Key& __y) const
7850b57cec5SDimitry Andric        {return __pred_(__x.__get_value().first, __y);}
7860b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7870b57cec5SDimitry Andric    bool operator()(const _Key& __x, const _Cp& __y) const
7880b57cec5SDimitry Andric        {return __pred_(__x, __y.__get_value().first);}
789*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
790349cc55cSDimitry Andric    template <typename _K2>
791e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
792e8d8bef9SDimitry Andric    bool operator()(const _Cp& __x, const _K2& __y) const
793e8d8bef9SDimitry Andric        {return __pred_(__x.__get_value().first, __y);}
794349cc55cSDimitry Andric    template <typename _K2>
795e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
796e8d8bef9SDimitry Andric    bool operator()(const _K2& __x, const _Cp& __y) const
797e8d8bef9SDimitry Andric        {return __pred_(__x, __y.__get_value().first);}
798349cc55cSDimitry Andric    template <typename _K2>
799e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
800e8d8bef9SDimitry Andric    bool operator()(const _Key& __x, const _K2& __y) const
801e8d8bef9SDimitry Andric        {return __pred_(__x, __y);}
802349cc55cSDimitry Andric    template <typename _K2>
803e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
804e8d8bef9SDimitry Andric    bool operator()(const _K2& __x, const _Key& __y) const
805e8d8bef9SDimitry Andric        {return __pred_(__x, __y);}
806e8d8bef9SDimitry Andric#endif
807349cc55cSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8080b57cec5SDimitry Andric    void swap(__unordered_map_equal& __y)
8090b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
8100b57cec5SDimitry Andric    {
8110b57cec5SDimitry Andric        using _VSTD::swap;
8120b57cec5SDimitry Andric        swap(__pred_, __y.__pred_);
8130b57cec5SDimitry Andric    }
8140b57cec5SDimitry Andric};
8150b57cec5SDimitry Andric
816e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash, bool __b>
8170b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
8180b57cec5SDimitry Andricvoid
819e8d8bef9SDimitry Andricswap(__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __x,
820e8d8bef9SDimitry Andric     __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __y)
8210b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
8220b57cec5SDimitry Andric{
8230b57cec5SDimitry Andric    __x.swap(__y);
8240b57cec5SDimitry Andric}
8250b57cec5SDimitry Andric
8260b57cec5SDimitry Andrictemplate <class _Alloc>
8270b57cec5SDimitry Andricclass __hash_map_node_destructor
8280b57cec5SDimitry Andric{
8290b57cec5SDimitry Andric    typedef _Alloc                              allocator_type;
8300b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>    __alloc_traits;
8310b57cec5SDimitry Andric
8320b57cec5SDimitry Andricpublic:
8330b57cec5SDimitry Andric
8340b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer       pointer;
8350b57cec5SDimitry Andricprivate:
8360b57cec5SDimitry Andric
8370b57cec5SDimitry Andric    allocator_type& __na_;
8380b57cec5SDimitry Andric
8390b57cec5SDimitry Andric    __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
8400b57cec5SDimitry Andric
8410b57cec5SDimitry Andricpublic:
8420b57cec5SDimitry Andric    bool __first_constructed;
8430b57cec5SDimitry Andric    bool __second_constructed;
8440b57cec5SDimitry Andric
8450b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8460b57cec5SDimitry Andric    explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
8470b57cec5SDimitry Andric        : __na_(__na),
8480b57cec5SDimitry Andric          __first_constructed(false),
8490b57cec5SDimitry Andric          __second_constructed(false)
8500b57cec5SDimitry Andric        {}
8510b57cec5SDimitry Andric
8520b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8530b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8540b57cec5SDimitry Andric    __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
8550b57cec5SDimitry Andric        _NOEXCEPT
8560b57cec5SDimitry Andric        : __na_(__x.__na_),
8570b57cec5SDimitry Andric          __first_constructed(__x.__value_constructed),
8580b57cec5SDimitry Andric          __second_constructed(__x.__value_constructed)
8590b57cec5SDimitry Andric        {
8600b57cec5SDimitry Andric            __x.__value_constructed = false;
8610b57cec5SDimitry Andric        }
8620b57cec5SDimitry Andric#else  // _LIBCPP_CXX03_LANG
8630b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8640b57cec5SDimitry Andric    __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
8650b57cec5SDimitry Andric        : __na_(__x.__na_),
8660b57cec5SDimitry Andric          __first_constructed(__x.__value_constructed),
8670b57cec5SDimitry Andric          __second_constructed(__x.__value_constructed)
8680b57cec5SDimitry Andric        {
8690b57cec5SDimitry Andric            const_cast<bool&>(__x.__value_constructed) = false;
8700b57cec5SDimitry Andric        }
8710b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
8720b57cec5SDimitry Andric
8730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8740b57cec5SDimitry Andric    void operator()(pointer __p) _NOEXCEPT
8750b57cec5SDimitry Andric    {
8760b57cec5SDimitry Andric        if (__second_constructed)
8770b57cec5SDimitry Andric            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
8780b57cec5SDimitry Andric        if (__first_constructed)
8790b57cec5SDimitry Andric            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
8800b57cec5SDimitry Andric        if (__p)
8810b57cec5SDimitry Andric            __alloc_traits::deallocate(__na_, __p, 1);
8820b57cec5SDimitry Andric    }
8830b57cec5SDimitry Andric};
8840b57cec5SDimitry Andric
8850b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8860b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
887fe6060f1SDimitry Andricstruct _LIBCPP_STANDALONE_DEBUG __hash_value_type
8880b57cec5SDimitry Andric{
8890b57cec5SDimitry Andric    typedef _Key                                     key_type;
8900b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
8910b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
8920b57cec5SDimitry Andric    typedef pair<key_type&, mapped_type&>            __nc_ref_pair_type;
8930b57cec5SDimitry Andric    typedef pair<key_type&&, mapped_type&&>          __nc_rref_pair_type;
8940b57cec5SDimitry Andric
8950b57cec5SDimitry Andricprivate:
896bdd1243dSDimitry Andric    value_type __cc_;
8970b57cec5SDimitry Andric
8980b57cec5SDimitry Andricpublic:
8990b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9000b57cec5SDimitry Andric    value_type& __get_value()
9010b57cec5SDimitry Andric    {
902*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
903bdd1243dSDimitry Andric        return *_VSTD::launder(_VSTD::addressof(__cc_));
9040b57cec5SDimitry Andric#else
905bdd1243dSDimitry Andric        return __cc_;
9060b57cec5SDimitry Andric#endif
9070b57cec5SDimitry Andric    }
9080b57cec5SDimitry Andric
9090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9100b57cec5SDimitry Andric    const value_type& __get_value() const
9110b57cec5SDimitry Andric    {
912*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
913bdd1243dSDimitry Andric        return *_VSTD::launder(_VSTD::addressof(__cc_));
9140b57cec5SDimitry Andric#else
915bdd1243dSDimitry Andric        return __cc_;
9160b57cec5SDimitry Andric#endif
9170b57cec5SDimitry Andric    }
9180b57cec5SDimitry Andric
9190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9200b57cec5SDimitry Andric    __nc_ref_pair_type __ref()
9210b57cec5SDimitry Andric    {
9220b57cec5SDimitry Andric        value_type& __v = __get_value();
9230b57cec5SDimitry Andric        return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
9240b57cec5SDimitry Andric    }
9250b57cec5SDimitry Andric
9260b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9270b57cec5SDimitry Andric    __nc_rref_pair_type __move()
9280b57cec5SDimitry Andric    {
9290b57cec5SDimitry Andric        value_type& __v = __get_value();
9300b57cec5SDimitry Andric        return __nc_rref_pair_type(
9310b57cec5SDimitry Andric            _VSTD::move(const_cast<key_type&>(__v.first)),
9320b57cec5SDimitry Andric            _VSTD::move(__v.second));
9330b57cec5SDimitry Andric    }
9340b57cec5SDimitry Andric
9350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9360b57cec5SDimitry Andric    __hash_value_type& operator=(const __hash_value_type& __v)
9370b57cec5SDimitry Andric    {
9380b57cec5SDimitry Andric        __ref() = __v.__get_value();
9390b57cec5SDimitry Andric        return *this;
9400b57cec5SDimitry Andric    }
9410b57cec5SDimitry Andric
9420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9430b57cec5SDimitry Andric    __hash_value_type& operator=(__hash_value_type&& __v)
9440b57cec5SDimitry Andric    {
9450b57cec5SDimitry Andric        __ref() = __v.__move();
9460b57cec5SDimitry Andric        return *this;
9470b57cec5SDimitry Andric    }
9480b57cec5SDimitry Andric
9490b57cec5SDimitry Andric    template <class _ValueTp,
950753f127fSDimitry Andric              class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value>
9510b57cec5SDimitry Andric             >
9520b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9530b57cec5SDimitry Andric    __hash_value_type& operator=(_ValueTp&& __v)
9540b57cec5SDimitry Andric    {
9550b57cec5SDimitry Andric        __ref() = _VSTD::forward<_ValueTp>(__v);
9560b57cec5SDimitry Andric        return *this;
9570b57cec5SDimitry Andric    }
9580b57cec5SDimitry Andric
9590b57cec5SDimitry Andricprivate:
9600b57cec5SDimitry Andric    __hash_value_type(const __hash_value_type& __v) = delete;
9610b57cec5SDimitry Andric    __hash_value_type(__hash_value_type&& __v) = delete;
9620b57cec5SDimitry Andric    template <class ..._Args>
9630b57cec5SDimitry Andric    explicit __hash_value_type(_Args&& ...__args) = delete;
9640b57cec5SDimitry Andric
9650b57cec5SDimitry Andric    ~__hash_value_type() = delete;
9660b57cec5SDimitry Andric};
9670b57cec5SDimitry Andric
9680b57cec5SDimitry Andric#else
9690b57cec5SDimitry Andric
9700b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
9710b57cec5SDimitry Andricstruct __hash_value_type
9720b57cec5SDimitry Andric{
9730b57cec5SDimitry Andric    typedef _Key                                     key_type;
9740b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
9750b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
9760b57cec5SDimitry Andric
9770b57cec5SDimitry Andricprivate:
978bdd1243dSDimitry Andric    value_type __cc_;
9790b57cec5SDimitry Andric
9800b57cec5SDimitry Andricpublic:
9810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
982bdd1243dSDimitry Andric    value_type& __get_value() { return __cc_; }
9830b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
984bdd1243dSDimitry Andric    const value_type& __get_value() const { return __cc_; }
9850b57cec5SDimitry Andric
9860b57cec5SDimitry Andricprivate:
9870b57cec5SDimitry Andric   ~__hash_value_type();
9880b57cec5SDimitry Andric};
9890b57cec5SDimitry Andric
9900b57cec5SDimitry Andric#endif
9910b57cec5SDimitry Andric
9920b57cec5SDimitry Andrictemplate <class _HashIterator>
9930b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_iterator
9940b57cec5SDimitry Andric{
9950b57cec5SDimitry Andric    _HashIterator __i_;
9960b57cec5SDimitry Andric
9970b57cec5SDimitry Andric    typedef  __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
9980b57cec5SDimitry Andric
9990b57cec5SDimitry Andricpublic:
10000b57cec5SDimitry Andric    typedef forward_iterator_tag                                 iterator_category;
10010b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type                value_type;
10020b57cec5SDimitry Andric    typedef typename _NodeTypes::difference_type                 difference_type;
10030b57cec5SDimitry Andric    typedef value_type&                                          reference;
10040b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type_pointer       pointer;
10050b57cec5SDimitry Andric
10060b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10070b57cec5SDimitry Andric    __hash_map_iterator() _NOEXCEPT {}
10080b57cec5SDimitry Andric
10090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10100b57cec5SDimitry Andric    __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
10110b57cec5SDimitry Andric
10120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10130b57cec5SDimitry Andric    reference operator*() const {return __i_->__get_value();}
10140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10150b57cec5SDimitry Andric    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
10160b57cec5SDimitry Andric
10170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10180b57cec5SDimitry Andric    __hash_map_iterator& operator++() {++__i_; return *this;}
10190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10200b57cec5SDimitry Andric    __hash_map_iterator operator++(int)
10210b57cec5SDimitry Andric    {
10220b57cec5SDimitry Andric        __hash_map_iterator __t(*this);
10230b57cec5SDimitry Andric        ++(*this);
10240b57cec5SDimitry Andric        return __t;
10250b57cec5SDimitry Andric    }
10260b57cec5SDimitry Andric
10270b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
10280b57cec5SDimitry Andric        bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
10290b57cec5SDimitry Andric        {return __x.__i_ == __y.__i_;}
1030*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
10310b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
10320b57cec5SDimitry Andric        bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
10330b57cec5SDimitry Andric        {return __x.__i_ != __y.__i_;}
1034*06c3fb27SDimitry Andric#endif
10350b57cec5SDimitry Andric
10360b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
10370b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
10380b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
10390b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
10400b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
10410b57cec5SDimitry Andric};
10420b57cec5SDimitry Andric
10430b57cec5SDimitry Andrictemplate <class _HashIterator>
10440b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator
10450b57cec5SDimitry Andric{
10460b57cec5SDimitry Andric    _HashIterator __i_;
10470b57cec5SDimitry Andric
10480b57cec5SDimitry Andric    typedef  __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
10490b57cec5SDimitry Andric
10500b57cec5SDimitry Andricpublic:
10510b57cec5SDimitry Andric    typedef forward_iterator_tag                                 iterator_category;
10520b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type                value_type;
10530b57cec5SDimitry Andric    typedef typename _NodeTypes::difference_type                 difference_type;
10540b57cec5SDimitry Andric    typedef const value_type&                                    reference;
10550b57cec5SDimitry Andric    typedef typename _NodeTypes::__const_map_value_type_pointer  pointer;
10560b57cec5SDimitry Andric
10570b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10580b57cec5SDimitry Andric    __hash_map_const_iterator() _NOEXCEPT {}
10590b57cec5SDimitry Andric
10600b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10610b57cec5SDimitry Andric    __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
10620b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10630b57cec5SDimitry Andric    __hash_map_const_iterator(
10640b57cec5SDimitry Andric            __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
10650b57cec5SDimitry Andric                 _NOEXCEPT
10660b57cec5SDimitry Andric                : __i_(__i.__i_) {}
10670b57cec5SDimitry Andric
10680b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10690b57cec5SDimitry Andric    reference operator*() const {return __i_->__get_value();}
10700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10710b57cec5SDimitry Andric    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
10720b57cec5SDimitry Andric
10730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10740b57cec5SDimitry Andric    __hash_map_const_iterator& operator++() {++__i_; return *this;}
10750b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10760b57cec5SDimitry Andric    __hash_map_const_iterator operator++(int)
10770b57cec5SDimitry Andric    {
10780b57cec5SDimitry Andric        __hash_map_const_iterator __t(*this);
10790b57cec5SDimitry Andric        ++(*this);
10800b57cec5SDimitry Andric        return __t;
10810b57cec5SDimitry Andric    }
10820b57cec5SDimitry Andric
10830b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
10840b57cec5SDimitry Andric        bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
10850b57cec5SDimitry Andric        {return __x.__i_ == __y.__i_;}
1086*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
10870b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
10880b57cec5SDimitry Andric        bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
10890b57cec5SDimitry Andric        {return __x.__i_ != __y.__i_;}
1090*06c3fb27SDimitry Andric#endif
10910b57cec5SDimitry Andric
10920b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
10930b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
10940b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
10950b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
10960b57cec5SDimitry Andric};
10970b57cec5SDimitry Andric
10980b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
10990b57cec5SDimitry Andricclass unordered_multimap;
11000b57cec5SDimitry Andric
11010b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
11020b57cec5SDimitry Andric          class _Alloc = allocator<pair<const _Key, _Tp> > >
11030b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_map
11040b57cec5SDimitry Andric{
11050b57cec5SDimitry Andricpublic:
11060b57cec5SDimitry Andric    // types
11070b57cec5SDimitry Andric    typedef _Key                                           key_type;
11080b57cec5SDimitry Andric    typedef _Tp                                            mapped_type;
110981ad6265SDimitry Andric    typedef __type_identity_t<_Hash>                       hasher;
111081ad6265SDimitry Andric    typedef __type_identity_t<_Pred>                       key_equal;
111181ad6265SDimitry Andric    typedef __type_identity_t<_Alloc>                      allocator_type;
11120b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>              value_type;
11130b57cec5SDimitry Andric    typedef value_type&                                    reference;
11140b57cec5SDimitry Andric    typedef const value_type&                              const_reference;
11150b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1116*06c3fb27SDimitry Andric                  "Allocator::value_type must be same type as value_type");
11170b57cec5SDimitry Andric
11180b57cec5SDimitry Andricprivate:
11190b57cec5SDimitry Andric    typedef __hash_value_type<key_type, mapped_type>                          __value_type;
1120e8d8bef9SDimitry Andric    typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
1121e8d8bef9SDimitry Andric    typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher>  __key_equal;
1122bdd1243dSDimitry Andric    typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type>    __allocator_type;
11230b57cec5SDimitry Andric
11240b57cec5SDimitry Andric    typedef __hash_table<__value_type, __hasher,
11250b57cec5SDimitry Andric                         __key_equal,  __allocator_type>   __table;
11260b57cec5SDimitry Andric
11270b57cec5SDimitry Andric    __table __table_;
11280b57cec5SDimitry Andric
11290b57cec5SDimitry Andric    typedef typename __table::_NodeTypes                   _NodeTypes;
11300b57cec5SDimitry Andric    typedef typename __table::__node_pointer               __node_pointer;
11310b57cec5SDimitry Andric    typedef typename __table::__node_const_pointer         __node_const_pointer;
11320b57cec5SDimitry Andric    typedef typename __table::__node_traits                __node_traits;
11330b57cec5SDimitry Andric    typedef typename __table::__node_allocator             __node_allocator;
11340b57cec5SDimitry Andric    typedef typename __table::__node                       __node;
11350b57cec5SDimitry Andric    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
11360b57cec5SDimitry Andric    typedef unique_ptr<__node, _Dp>                         __node_holder;
11370b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>               __alloc_traits;
11380b57cec5SDimitry Andric
1139bdd1243dSDimitry Andric    static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1140bdd1243dSDimitry Andric                  "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1141bdd1243dSDimitry Andric                  "original allocator");
1142bdd1243dSDimitry Andric
11430b57cec5SDimitry Andric    static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");
11440b57cec5SDimitry Andric    static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");
11450b57cec5SDimitry Andricpublic:
11460b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer         pointer;
11470b57cec5SDimitry Andric    typedef typename __alloc_traits::const_pointer   const_pointer;
11480b57cec5SDimitry Andric    typedef typename __table::size_type              size_type;
11490b57cec5SDimitry Andric    typedef typename __table::difference_type        difference_type;
11500b57cec5SDimitry Andric
11510b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::iterator>       iterator;
11520b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
11530b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
11540b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
11550b57cec5SDimitry Andric
1156*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
11570b57cec5SDimitry Andric    typedef __map_node_handle<__node, allocator_type> node_type;
11580b57cec5SDimitry Andric    typedef __insert_return_type<iterator, node_type> insert_return_type;
11590b57cec5SDimitry Andric#endif
11600b57cec5SDimitry Andric
11610b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
11620b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_map;
11630b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
11640b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
11650b57cec5SDimitry Andric
11660b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11670b57cec5SDimitry Andric    unordered_map()
11680b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
11690b57cec5SDimitry Andric    {
11700b57cec5SDimitry Andric    }
1171*06c3fb27SDimitry Andric    explicit _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const hasher& __hf = hasher(),
11720b57cec5SDimitry Andric                           const key_equal& __eql = key_equal());
1173*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const hasher& __hf,
11740b57cec5SDimitry Andric                  const key_equal& __eql,
11750b57cec5SDimitry Andric                  const allocator_type& __a);
11760b57cec5SDimitry Andric    template <class _InputIterator>
1177*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(_InputIterator __first, _InputIterator __last);
11780b57cec5SDimitry Andric    template <class _InputIterator>
1179*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(_InputIterator __first, _InputIterator __last,
11800b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
11810b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
11820b57cec5SDimitry Andric    template <class _InputIterator>
1183*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(_InputIterator __first, _InputIterator __last,
11840b57cec5SDimitry Andric                      size_type __n, const hasher& __hf,
11850b57cec5SDimitry Andric                      const key_equal& __eql,
11860b57cec5SDimitry Andric                      const allocator_type& __a);
1187*06c3fb27SDimitry Andric
1188*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
1189*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<value_type> _Range>
1190*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
1191*06c3fb27SDimitry Andric    unordered_map(from_range_t, _Range&& __range, size_type __n = /*implementation-defined*/0,
1192*06c3fb27SDimitry Andric                  const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),
1193*06c3fb27SDimitry Andric                  const allocator_type& __a = allocator_type())
1194*06c3fb27SDimitry Andric        : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
1195*06c3fb27SDimitry Andric      if (__n > 0) {
1196*06c3fb27SDimitry Andric        __table_.__rehash_unique(__n);
1197*06c3fb27SDimitry Andric      }
1198*06c3fb27SDimitry Andric      insert_range(std::forward<_Range>(__range));
1199*06c3fb27SDimitry Andric    }
1200*06c3fb27SDimitry Andric#endif
1201*06c3fb27SDimitry Andric
12020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12030b57cec5SDimitry Andric    explicit unordered_map(const allocator_type& __a);
1204*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u);
1205*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u, const allocator_type& __a);
12060b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
12070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12080b57cec5SDimitry Andric    unordered_map(unordered_map&& __u)
12090b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
1210*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u, const allocator_type& __a);
1211*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il);
1212*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il, size_type __n,
12130b57cec5SDimitry Andric                  const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
1214*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il, size_type __n,
12150b57cec5SDimitry Andric                  const hasher& __hf, const key_equal& __eql,
12160b57cec5SDimitry Andric                  const allocator_type& __a);
12170b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
1218*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14
12190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12200b57cec5SDimitry Andric    unordered_map(size_type __n, const allocator_type& __a)
12210b57cec5SDimitry Andric      : unordered_map(__n, hasher(), key_equal(), __a) {}
12220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12230b57cec5SDimitry Andric    unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
12240b57cec5SDimitry Andric      : unordered_map(__n, __hf, key_equal(), __a) {}
12250b57cec5SDimitry Andric    template <class _InputIterator>
12260b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12270b57cec5SDimitry Andric      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
12280b57cec5SDimitry Andric      : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
12290b57cec5SDimitry Andric    template <class _InputIterator>
12300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12310b57cec5SDimitry Andric      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
12320b57cec5SDimitry Andric        const allocator_type& __a)
12330b57cec5SDimitry Andric      : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
1234*06c3fb27SDimitry Andric
1235*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
1236*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<value_type> _Range>
1237*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
1238*06c3fb27SDimitry Andric    unordered_map(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
1239*06c3fb27SDimitry Andric        : unordered_map(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
1240*06c3fb27SDimitry Andric
1241*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<value_type> _Range>
1242*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
1243*06c3fb27SDimitry Andric    unordered_map(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
1244*06c3fb27SDimitry Andric        : unordered_map(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
1245*06c3fb27SDimitry Andric#endif
1246*06c3fb27SDimitry Andric
12470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12480b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
12490b57cec5SDimitry Andric      : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
12500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12510b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
12520b57cec5SDimitry Andric      const allocator_type& __a)
12530b57cec5SDimitry Andric      : unordered_map(__il, __n, __hf, key_equal(), __a) {}
12540b57cec5SDimitry Andric#endif
12550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12560b57cec5SDimitry Andric    ~unordered_map() {
1257bdd1243dSDimitry Andric        static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
12580b57cec5SDimitry Andric    }
12590b57cec5SDimitry Andric
12600b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12610b57cec5SDimitry Andric    unordered_map& operator=(const unordered_map& __u)
12620b57cec5SDimitry Andric    {
12630b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
12640b57cec5SDimitry Andric        __table_ = __u.__table_;
12650b57cec5SDimitry Andric#else
1266349cc55cSDimitry Andric        if (this != _VSTD::addressof(__u)) {
12670b57cec5SDimitry Andric            __table_.clear();
12680b57cec5SDimitry Andric            __table_.hash_function() = __u.__table_.hash_function();
12690b57cec5SDimitry Andric            __table_.key_eq() = __u.__table_.key_eq();
12700b57cec5SDimitry Andric            __table_.max_load_factor() = __u.__table_.max_load_factor();
12710b57cec5SDimitry Andric            __table_.__copy_assign_alloc(__u.__table_);
12720b57cec5SDimitry Andric            insert(__u.begin(), __u.end());
12730b57cec5SDimitry Andric        }
12740b57cec5SDimitry Andric#endif
12750b57cec5SDimitry Andric        return *this;
12760b57cec5SDimitry Andric    }
12770b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
12780b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12790b57cec5SDimitry Andric    unordered_map& operator=(unordered_map&& __u)
12800b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
12810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12820b57cec5SDimitry Andric    unordered_map& operator=(initializer_list<value_type> __il);
12830b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
12840b57cec5SDimitry Andric
12850b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12860b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
12870b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
12880b57cec5SDimitry Andric
12890b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
12900b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
12910b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12920b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
12930b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12940b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
12950b57cec5SDimitry Andric
12960b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12970b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
12980b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12990b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
13000b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13010b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
13020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13030b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
13040b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13050b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
13060b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13070b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
13080b57cec5SDimitry Andric
13090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13100b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& __x)
13110b57cec5SDimitry Andric        {return __table_.__insert_unique(__x);}
13120b57cec5SDimitry Andric
1313*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) {
13140b57cec5SDimitry Andric        return insert(__x).first;
13150b57cec5SDimitry Andric    }
13160b57cec5SDimitry Andric
13170b57cec5SDimitry Andric    template <class _InputIterator>
13180b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13190b57cec5SDimitry Andric        void insert(_InputIterator __first, _InputIterator __last);
13200b57cec5SDimitry Andric
1321*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
1322*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<value_type> _Range>
1323*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
1324*06c3fb27SDimitry Andric    void insert_range(_Range&& __range) {
1325*06c3fb27SDimitry Andric      for (auto&& __element : __range) {
1326*06c3fb27SDimitry Andric        __table_.__insert_unique(std::forward<decltype(__element)>(__element));
1327*06c3fb27SDimitry Andric      }
1328*06c3fb27SDimitry Andric    }
1329*06c3fb27SDimitry Andric#endif
1330*06c3fb27SDimitry Andric
13310b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
13320b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13330b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
13340b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
13350b57cec5SDimitry Andric
13360b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13370b57cec5SDimitry Andric    pair<iterator, bool> insert(value_type&& __x)
13380b57cec5SDimitry Andric        {return __table_.__insert_unique(_VSTD::move(__x));}
13390b57cec5SDimitry Andric
1340*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) {
13410b57cec5SDimitry Andric        return __table_.__insert_unique(_VSTD::move(__x)).first;
13420b57cec5SDimitry Andric    }
13430b57cec5SDimitry Andric
13440b57cec5SDimitry Andric    template <class _Pp,
1345753f127fSDimitry Andric              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
13460b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13470b57cec5SDimitry Andric        pair<iterator, bool> insert(_Pp&& __x)
13480b57cec5SDimitry Andric            {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
13490b57cec5SDimitry Andric
13500b57cec5SDimitry Andric    template <class _Pp,
1351753f127fSDimitry Andric              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
13520b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1353*06c3fb27SDimitry Andric        iterator insert(const_iterator, _Pp&& __x)
13540b57cec5SDimitry Andric        {
13550b57cec5SDimitry Andric            return insert(_VSTD::forward<_Pp>(__x)).first;
13560b57cec5SDimitry Andric        }
13570b57cec5SDimitry Andric
13580b57cec5SDimitry Andric    template <class... _Args>
13590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13600b57cec5SDimitry Andric    pair<iterator, bool> emplace(_Args&&... __args) {
13610b57cec5SDimitry Andric        return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
13620b57cec5SDimitry Andric    }
13630b57cec5SDimitry Andric
13640b57cec5SDimitry Andric    template <class... _Args>
13650b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1366*06c3fb27SDimitry Andric    iterator emplace_hint(const_iterator, _Args&&... __args) {
13670b57cec5SDimitry Andric        return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
13680b57cec5SDimitry Andric    }
13690b57cec5SDimitry Andric
13700b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
13710b57cec5SDimitry Andric
1372*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
13730b57cec5SDimitry Andric    template <class... _Args>
13740b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13750b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
13760b57cec5SDimitry Andric    {
1377e8d8bef9SDimitry Andric        return __table_.__emplace_unique_key_args(__k, piecewise_construct,
13780b57cec5SDimitry Andric            _VSTD::forward_as_tuple(__k),
13790b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
13800b57cec5SDimitry Andric    }
13810b57cec5SDimitry Andric
13820b57cec5SDimitry Andric    template <class... _Args>
13830b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13840b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
13850b57cec5SDimitry Andric    {
1386e8d8bef9SDimitry Andric        return __table_.__emplace_unique_key_args(__k, piecewise_construct,
13870b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::move(__k)),
13880b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
13890b57cec5SDimitry Andric    }
13900b57cec5SDimitry Andric
13910b57cec5SDimitry Andric    template <class... _Args>
13920b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1393*06c3fb27SDimitry Andric        iterator try_emplace(const_iterator, const key_type& __k, _Args&&... __args)
13940b57cec5SDimitry Andric    {
13950b57cec5SDimitry Andric        return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
13960b57cec5SDimitry Andric    }
13970b57cec5SDimitry Andric
13980b57cec5SDimitry Andric    template <class... _Args>
13990b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1400*06c3fb27SDimitry Andric        iterator try_emplace(const_iterator, key_type&& __k, _Args&&... __args)
14010b57cec5SDimitry Andric    {
14020b57cec5SDimitry Andric        return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first;
14030b57cec5SDimitry Andric    }
14040b57cec5SDimitry Andric
14050b57cec5SDimitry Andric    template <class _Vp>
14060b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
14070b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
14080b57cec5SDimitry Andric    {
14090b57cec5SDimitry Andric        pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
14100b57cec5SDimitry Andric            __k, _VSTD::forward<_Vp>(__v));
14110b57cec5SDimitry Andric        if (!__res.second) {
14120b57cec5SDimitry Andric            __res.first->second = _VSTD::forward<_Vp>(__v);
14130b57cec5SDimitry Andric        }
14140b57cec5SDimitry Andric        return __res;
14150b57cec5SDimitry Andric    }
14160b57cec5SDimitry Andric
14170b57cec5SDimitry Andric    template <class _Vp>
14180b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
14190b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
14200b57cec5SDimitry Andric    {
14210b57cec5SDimitry Andric        pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
14220b57cec5SDimitry Andric            _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
14230b57cec5SDimitry Andric        if (!__res.second) {
14240b57cec5SDimitry Andric            __res.first->second = _VSTD::forward<_Vp>(__v);
14250b57cec5SDimitry Andric        }
14260b57cec5SDimitry Andric        return __res;
14270b57cec5SDimitry Andric    }
14280b57cec5SDimitry Andric
14290b57cec5SDimitry Andric    template <class _Vp>
14300b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
14310b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator, const key_type& __k, _Vp&& __v)
14320b57cec5SDimitry Andric     {
14330b57cec5SDimitry Andric          return insert_or_assign(__k, _VSTD::forward<_Vp>(__v)).first;
14340b57cec5SDimitry Andric     }
14350b57cec5SDimitry Andric
14360b57cec5SDimitry Andric    template <class _Vp>
14370b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
14380b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v)
14390b57cec5SDimitry Andric     {
14400b57cec5SDimitry Andric        return insert_or_assign(_VSTD::move(__k), _VSTD::forward<_Vp>(__v)).first;
14410b57cec5SDimitry Andric     }
1442*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 17
14430b57cec5SDimitry Andric
14440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14450b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
14460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14470b57cec5SDimitry Andric    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
14480b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14490b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
14500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14510b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
14520b57cec5SDimitry Andric        {return __table_.erase(__first.__i_, __last.__i_);}
14530b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14540b57cec5SDimitry Andric        void clear() _NOEXCEPT {__table_.clear();}
14550b57cec5SDimitry Andric
1456*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
14570b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14580b57cec5SDimitry Andric    insert_return_type insert(node_type&& __nh)
14590b57cec5SDimitry Andric    {
1460*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
14610b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_map::insert()");
14620b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<
14630b57cec5SDimitry Andric            node_type, insert_return_type>(_VSTD::move(__nh));
14640b57cec5SDimitry Andric    }
14650b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14660b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
14670b57cec5SDimitry Andric    {
1468*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
14690b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_map::insert()");
14700b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<node_type>(
14710b57cec5SDimitry Andric            __hint.__i_, _VSTD::move(__nh));
14720b57cec5SDimitry Andric    }
14730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14740b57cec5SDimitry Andric    node_type extract(key_type const& __key)
14750b57cec5SDimitry Andric    {
14760b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
14770b57cec5SDimitry Andric    }
14780b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14790b57cec5SDimitry Andric    node_type extract(const_iterator __it)
14800b57cec5SDimitry Andric    {
14810b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(
14820b57cec5SDimitry Andric            __it.__i_);
14830b57cec5SDimitry Andric    }
14840b57cec5SDimitry Andric
14850b57cec5SDimitry Andric    template <class _H2, class _P2>
14860b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14870b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
14880b57cec5SDimitry Andric    {
1489*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(),
14900b57cec5SDimitry Andric                                            "merging container with incompatible allocator");
14910b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
14920b57cec5SDimitry Andric    }
14930b57cec5SDimitry Andric    template <class _H2, class _P2>
14940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14950b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
14960b57cec5SDimitry Andric    {
1497*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(),
14980b57cec5SDimitry Andric                                            "merging container with incompatible allocator");
14990b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
15000b57cec5SDimitry Andric    }
15010b57cec5SDimitry Andric    template <class _H2, class _P2>
15020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15030b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
15040b57cec5SDimitry Andric    {
1505*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(),
15060b57cec5SDimitry Andric                                            "merging container with incompatible allocator");
15070b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
15080b57cec5SDimitry Andric    }
15090b57cec5SDimitry Andric    template <class _H2, class _P2>
15100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15110b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
15120b57cec5SDimitry Andric    {
1513*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(),
15140b57cec5SDimitry Andric                                            "merging container with incompatible allocator");
15150b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
15160b57cec5SDimitry Andric    }
15170b57cec5SDimitry Andric#endif
15180b57cec5SDimitry Andric
15190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15200b57cec5SDimitry Andric    void swap(unordered_map& __u)
15210b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
15220b57cec5SDimitry Andric        { __table_.swap(__u.__table_);}
15230b57cec5SDimitry Andric
15240b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15250b57cec5SDimitry Andric    hasher hash_function() const
15260b57cec5SDimitry Andric        {return __table_.hash_function().hash_function();}
15270b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15280b57cec5SDimitry Andric    key_equal key_eq() const
15290b57cec5SDimitry Andric        {return __table_.key_eq().key_eq();}
15300b57cec5SDimitry Andric
15310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15320b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
15330b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15340b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1535*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1536349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1537e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1538349cc55cSDimitry Andric    iterator       find(const _K2& __k)            {return __table_.find(__k);}
1539349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1540e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1541349cc55cSDimitry Andric    const_iterator find(const _K2& __k) const      {return __table_.find(__k);}
1542*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1543e8d8bef9SDimitry Andric
15440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15450b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
1546*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1547349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1548e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1549349cc55cSDimitry Andric    size_type count(const _K2& __k) const      {return __table_.__count_unique(__k);}
1550*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1551349cc55cSDimitry Andric
1552*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
15530b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15540b57cec5SDimitry Andric    bool contains(const key_type& __k) const {return find(__k) != end();}
1555e8d8bef9SDimitry Andric
1556349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1557e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1558349cc55cSDimitry Andric    bool contains(const _K2& __k) const      {return find(__k) != end();}
1559*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
1560349cc55cSDimitry Andric
15610b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15620b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
15630b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
15640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15650b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
15660b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
1567*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
1568349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1569e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1570349cc55cSDimitry Andric    pair<iterator, iterator>             equal_range(const _K2& __k)
1571349cc55cSDimitry Andric        {return __table_.__equal_range_unique(__k);}
1572349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1573e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1574349cc55cSDimitry Andric    pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
1575349cc55cSDimitry Andric        {return __table_.__equal_range_unique(__k);}
1576*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
15770b57cec5SDimitry Andric
1578*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k);
15790b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1580*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);
15810b57cec5SDimitry Andric#endif
15820b57cec5SDimitry Andric
1583*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI mapped_type&       at(const key_type& __k);
1584*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const;
15850b57cec5SDimitry Andric
15860b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15870b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
15880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15890b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
15900b57cec5SDimitry Andric
15910b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15920b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const
15930b57cec5SDimitry Andric        {return __table_.bucket_size(__n);}
15940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15950b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
15960b57cec5SDimitry Andric
15970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15980b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
15990b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
16000b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
16010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
16020b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
16030b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
16040b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
16050b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
16060b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
16070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
16080b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
16090b57cec5SDimitry Andric
16100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
16110b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
16120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
16130b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
16140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
16150b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
16160b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1617753f127fSDimitry Andric    void rehash(size_type __n) {__table_.__rehash_unique(__n);}
16180b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1619753f127fSDimitry Andric    void reserve(size_type __n) {__table_.__reserve_unique(__n);}
16200b57cec5SDimitry Andric
16210b57cec5SDimitry Andricprivate:
16220b57cec5SDimitry Andric
16230b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG
1624*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k);
16250b57cec5SDimitry Andric#endif
16260b57cec5SDimitry Andric};
16270b57cec5SDimitry Andric
1628349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
16290b57cec5SDimitry Andrictemplate<class _InputIterator,
16300b57cec5SDimitry Andric         class _Hash = hash<__iter_key_type<_InputIterator>>,
16310b57cec5SDimitry Andric         class _Pred = equal_to<__iter_key_type<_InputIterator>>,
16320b57cec5SDimitry Andric         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
1633*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1634349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
1635349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
1636349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Pred>::value>,
1637349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
16380b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
16390b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
16400b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
16410b57cec5SDimitry Andric
1642*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
1643*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
1644*06c3fb27SDimitry Andric          class _Hash = hash<__range_key_type<_Range>>,
1645*06c3fb27SDimitry Andric          class _Pred = equal_to<__range_key_type<_Range>>,
1646*06c3fb27SDimitry Andric          class _Allocator = allocator<__range_to_alloc_type<_Range>>,
1647*06c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
1648*06c3fb27SDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
1649*06c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Pred>::value>,
1650*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
1651*06c3fb27SDimitry Andricunordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type = 0,
1652*06c3fb27SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1653*06c3fb27SDimitry Andric  -> unordered_map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>; // C++23
1654*06c3fb27SDimitry Andric#endif
1655*06c3fb27SDimitry Andric
16560b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>,
16570b57cec5SDimitry Andric         class _Pred = equal_to<remove_const_t<_Key>>,
16580b57cec5SDimitry Andric         class _Allocator = allocator<pair<const _Key, _Tp>>,
1659349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
1660349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
1661349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Pred>::value>,
1662349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
16630b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0,
16640b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
16650b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
16660b57cec5SDimitry Andric
16670b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
1668*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1669349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
16700b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
16710b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
16720b57cec5SDimitry Andric                   hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
16730b57cec5SDimitry Andric
16740b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
1675*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1676349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
16770b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, _Allocator)
16780b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
16790b57cec5SDimitry Andric                   hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
16800b57cec5SDimitry Andric
16810b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
1682*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1683349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
1684349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
1685349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
16860b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
16870b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
16880b57cec5SDimitry Andric                   _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
16890b57cec5SDimitry Andric
1690*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
1691*06c3fb27SDimitry Andric
1692*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator,
1693*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
1694*06c3fb27SDimitry Andricunordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
1695*06c3fb27SDimitry Andric  -> unordered_map<__range_key_type<_Range>, __range_mapped_type<_Range>, hash<__range_key_type<_Range>>,
1696*06c3fb27SDimitry Andric                   equal_to<__range_key_type<_Range>>, _Allocator>;
1697*06c3fb27SDimitry Andric
1698*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator,
1699*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
1700*06c3fb27SDimitry Andricunordered_map(from_range_t, _Range&&, _Allocator)
1701*06c3fb27SDimitry Andric  -> unordered_map<__range_key_type<_Range>, __range_mapped_type<_Range>, hash<__range_key_type<_Range>>,
1702*06c3fb27SDimitry Andric                   equal_to<__range_key_type<_Range>>, _Allocator>;
1703*06c3fb27SDimitry Andric
1704*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Hash, class _Allocator,
1705*06c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
1706*06c3fb27SDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
1707*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
1708*06c3fb27SDimitry Andricunordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1709*06c3fb27SDimitry Andric  -> unordered_map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash,
1710*06c3fb27SDimitry Andric                   equal_to<__range_key_type<_Range>>, _Allocator>;
1711*06c3fb27SDimitry Andric
1712*06c3fb27SDimitry Andric#endif
1713*06c3fb27SDimitry Andric
17140b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
1715349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
17160b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
17170b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp,
17180b57cec5SDimitry Andric                   hash<remove_const_t<_Key>>,
17190b57cec5SDimitry Andric                   equal_to<remove_const_t<_Key>>, _Allocator>;
17200b57cec5SDimitry Andric
17210b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
1722349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
17230b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator)
17240b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp,
17250b57cec5SDimitry Andric                   hash<remove_const_t<_Key>>,
17260b57cec5SDimitry Andric                   equal_to<remove_const_t<_Key>>, _Allocator>;
17270b57cec5SDimitry Andric
17280b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash, class _Allocator,
1729349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
1730349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
1731349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
17320b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
17330b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp, _Hash,
17340b57cec5SDimitry Andric                   equal_to<remove_const_t<_Key>>, _Allocator>;
17350b57cec5SDimitry Andric#endif
17360b57cec5SDimitry Andric
17370b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17380b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17390b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql)
17400b57cec5SDimitry Andric    : __table_(__hf, __eql)
17410b57cec5SDimitry Andric{
1742753f127fSDimitry Andric    __table_.__rehash_unique(__n);
17430b57cec5SDimitry Andric}
17440b57cec5SDimitry Andric
17450b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17460b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17470b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql,
17480b57cec5SDimitry Andric        const allocator_type& __a)
17490b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
17500b57cec5SDimitry Andric{
1751753f127fSDimitry Andric    __table_.__rehash_unique(__n);
17520b57cec5SDimitry Andric}
17530b57cec5SDimitry Andric
17540b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17550b57cec5SDimitry Andricinline
17560b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17570b57cec5SDimitry Andric        const allocator_type& __a)
17580b57cec5SDimitry Andric    : __table_(typename __table::allocator_type(__a))
17590b57cec5SDimitry Andric{
17600b57cec5SDimitry Andric}
17610b57cec5SDimitry Andric
17620b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17630b57cec5SDimitry Andrictemplate <class _InputIterator>
17640b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17650b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
17660b57cec5SDimitry Andric{
17670b57cec5SDimitry Andric    insert(__first, __last);
17680b57cec5SDimitry Andric}
17690b57cec5SDimitry Andric
17700b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17710b57cec5SDimitry Andrictemplate <class _InputIterator>
17720b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17730b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
17740b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
17750b57cec5SDimitry Andric    : __table_(__hf, __eql)
17760b57cec5SDimitry Andric{
1777753f127fSDimitry Andric    __table_.__rehash_unique(__n);
17780b57cec5SDimitry Andric    insert(__first, __last);
17790b57cec5SDimitry Andric}
17800b57cec5SDimitry Andric
17810b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17820b57cec5SDimitry Andrictemplate <class _InputIterator>
17830b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17840b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
17850b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
17860b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
17870b57cec5SDimitry Andric{
1788753f127fSDimitry Andric    __table_.__rehash_unique(__n);
17890b57cec5SDimitry Andric    insert(__first, __last);
17900b57cec5SDimitry Andric}
17910b57cec5SDimitry Andric
17920b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17930b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17940b57cec5SDimitry Andric        const unordered_map& __u)
17950b57cec5SDimitry Andric    : __table_(__u.__table_)
17960b57cec5SDimitry Andric{
1797753f127fSDimitry Andric    __table_.__rehash_unique(__u.bucket_count());
17980b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
17990b57cec5SDimitry Andric}
18000b57cec5SDimitry Andric
18010b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18020b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
18030b57cec5SDimitry Andric        const unordered_map& __u, const allocator_type& __a)
18040b57cec5SDimitry Andric    : __table_(__u.__table_, typename __table::allocator_type(__a))
18050b57cec5SDimitry Andric{
1806753f127fSDimitry Andric    __table_.__rehash_unique(__u.bucket_count());
18070b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
18080b57cec5SDimitry Andric}
18090b57cec5SDimitry Andric
18100b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
18110b57cec5SDimitry Andric
18120b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18130b57cec5SDimitry Andricinline
18140b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
18150b57cec5SDimitry Andric        unordered_map&& __u)
18160b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
18170b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
18180b57cec5SDimitry Andric{
18190b57cec5SDimitry Andric}
18200b57cec5SDimitry Andric
18210b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18220b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
18230b57cec5SDimitry Andric        unordered_map&& __u, const allocator_type& __a)
18240b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
18250b57cec5SDimitry Andric{
18260b57cec5SDimitry Andric    if (__a != __u.get_allocator())
18270b57cec5SDimitry Andric    {
18280b57cec5SDimitry Andric        iterator __i = __u.begin();
18290b57cec5SDimitry Andric        while (__u.size() != 0) {
18300b57cec5SDimitry Andric            __table_.__emplace_unique(
18310b57cec5SDimitry Andric                __u.__table_.remove((__i++).__i_)->__value_.__move());
18320b57cec5SDimitry Andric        }
18330b57cec5SDimitry Andric    }
18340b57cec5SDimitry Andric}
18350b57cec5SDimitry Andric
18360b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18370b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
18380b57cec5SDimitry Andric        initializer_list<value_type> __il)
18390b57cec5SDimitry Andric{
18400b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
18410b57cec5SDimitry Andric}
18420b57cec5SDimitry Andric
18430b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18440b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
18450b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
18460b57cec5SDimitry Andric        const key_equal& __eql)
18470b57cec5SDimitry Andric    : __table_(__hf, __eql)
18480b57cec5SDimitry Andric{
1849753f127fSDimitry Andric    __table_.__rehash_unique(__n);
18500b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
18510b57cec5SDimitry Andric}
18520b57cec5SDimitry Andric
18530b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18540b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
18550b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
18560b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
18570b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
18580b57cec5SDimitry Andric{
1859753f127fSDimitry Andric    __table_.__rehash_unique(__n);
18600b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
18610b57cec5SDimitry Andric}
18620b57cec5SDimitry Andric
18630b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18640b57cec5SDimitry Andricinline
18650b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
18660b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
18670b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
18680b57cec5SDimitry Andric{
18690b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
18700b57cec5SDimitry Andric    return *this;
18710b57cec5SDimitry Andric}
18720b57cec5SDimitry Andric
18730b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18740b57cec5SDimitry Andricinline
18750b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
18760b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
18770b57cec5SDimitry Andric        initializer_list<value_type> __il)
18780b57cec5SDimitry Andric{
18790b57cec5SDimitry Andric    __table_.__assign_unique(__il.begin(), __il.end());
18800b57cec5SDimitry Andric    return *this;
18810b57cec5SDimitry Andric}
18820b57cec5SDimitry Andric
18830b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
18840b57cec5SDimitry Andric
18850b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18860b57cec5SDimitry Andrictemplate <class _InputIterator>
18870b57cec5SDimitry Andricinline
18880b57cec5SDimitry Andricvoid
18890b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
18900b57cec5SDimitry Andric                                                       _InputIterator __last)
18910b57cec5SDimitry Andric{
18920b57cec5SDimitry Andric    for (; __first != __last; ++__first)
18930b57cec5SDimitry Andric        __table_.__insert_unique(*__first);
18940b57cec5SDimitry Andric}
18950b57cec5SDimitry Andric
18960b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
18970b57cec5SDimitry Andric
18980b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18990b57cec5SDimitry Andric_Tp&
19000b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
19010b57cec5SDimitry Andric{
19020b57cec5SDimitry Andric    return __table_.__emplace_unique_key_args(__k,
1903e8d8bef9SDimitry Andric        piecewise_construct, _VSTD::forward_as_tuple(__k),
1904e8d8bef9SDimitry Andric                             _VSTD::forward_as_tuple()).first->__get_value().second;
19050b57cec5SDimitry Andric}
19060b57cec5SDimitry Andric
19070b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19080b57cec5SDimitry Andric_Tp&
19090b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
19100b57cec5SDimitry Andric{
19110b57cec5SDimitry Andric    return __table_.__emplace_unique_key_args(__k,
1912e8d8bef9SDimitry Andric        piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
1913e8d8bef9SDimitry Andric                             _VSTD::forward_as_tuple()).first->__get_value().second;
19140b57cec5SDimitry Andric}
19150b57cec5SDimitry Andric#else // _LIBCPP_CXX03_LANG
19160b57cec5SDimitry Andric
19170b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19180b57cec5SDimitry Andrictypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
19190b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
19200b57cec5SDimitry Andric{
19210b57cec5SDimitry Andric    __node_allocator& __na = __table_.__node_alloc();
19220b57cec5SDimitry Andric    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
19230b57cec5SDimitry Andric    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k);
19240b57cec5SDimitry Andric    __h.get_deleter().__first_constructed = true;
19250b57cec5SDimitry Andric    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
19260b57cec5SDimitry Andric    __h.get_deleter().__second_constructed = true;
1927e8d8bef9SDimitry Andric    return __h;
19280b57cec5SDimitry Andric}
19290b57cec5SDimitry Andric
19300b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19310b57cec5SDimitry Andric_Tp&
19320b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
19330b57cec5SDimitry Andric{
19340b57cec5SDimitry Andric    iterator __i = find(__k);
19350b57cec5SDimitry Andric    if (__i != end())
19360b57cec5SDimitry Andric        return __i->second;
19370b57cec5SDimitry Andric    __node_holder __h = __construct_node_with_key(__k);
19380b57cec5SDimitry Andric    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
19390b57cec5SDimitry Andric    __h.release();
19400b57cec5SDimitry Andric    return __r.first->second;
19410b57cec5SDimitry Andric}
19420b57cec5SDimitry Andric
1943fe6060f1SDimitry Andric#endif // _LIBCPP_CXX03_LANG
19440b57cec5SDimitry Andric
19450b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19460b57cec5SDimitry Andric_Tp&
19470b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k)
19480b57cec5SDimitry Andric{
19490b57cec5SDimitry Andric    iterator __i = find(__k);
19500b57cec5SDimitry Andric    if (__i == end())
19510b57cec5SDimitry Andric        __throw_out_of_range("unordered_map::at: key not found");
19520b57cec5SDimitry Andric    return __i->second;
19530b57cec5SDimitry Andric}
19540b57cec5SDimitry Andric
19550b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19560b57cec5SDimitry Andricconst _Tp&
19570b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const
19580b57cec5SDimitry Andric{
19590b57cec5SDimitry Andric    const_iterator __i = find(__k);
19600b57cec5SDimitry Andric    if (__i == end())
19610b57cec5SDimitry Andric        __throw_out_of_range("unordered_map::at: key not found");
19620b57cec5SDimitry Andric    return __i->second;
19630b57cec5SDimitry Andric}
19640b57cec5SDimitry Andric
19650b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19660b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
19670b57cec5SDimitry Andricvoid
19680b57cec5SDimitry Andricswap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
19690b57cec5SDimitry Andric     unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
19700b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
19710b57cec5SDimitry Andric{
19720b57cec5SDimitry Andric    __x.swap(__y);
19730b57cec5SDimitry Andric}
19740b57cec5SDimitry Andric
1975*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
19765ffd83dbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
19775ffd83dbSDimitry Andric          class _Predicate>
19780b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
19795ffd83dbSDimitry Andric    typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
19805ffd83dbSDimitry Andric    erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c,
19815ffd83dbSDimitry Andric             _Predicate __pred) {
1982fe6060f1SDimitry Andric  return _VSTD::__libcpp_erase_if_container(__c, __pred);
19835ffd83dbSDimitry Andric}
19840b57cec5SDimitry Andric#endif
19850b57cec5SDimitry Andric
19860b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1987bdd1243dSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool
19880b57cec5SDimitry Andricoperator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
19890b57cec5SDimitry Andric           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
19900b57cec5SDimitry Andric{
19910b57cec5SDimitry Andric    if (__x.size() != __y.size())
19920b57cec5SDimitry Andric        return false;
19930b57cec5SDimitry Andric    typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
19940b57cec5SDimitry Andric                                                                 const_iterator;
19950b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
19960b57cec5SDimitry Andric            __i != __ex; ++__i)
19970b57cec5SDimitry Andric    {
19980b57cec5SDimitry Andric        const_iterator __j = __y.find(__i->first);
19990b57cec5SDimitry Andric        if (__j == __ey || !(*__i == *__j))
20000b57cec5SDimitry Andric            return false;
20010b57cec5SDimitry Andric    }
20020b57cec5SDimitry Andric    return true;
20030b57cec5SDimitry Andric}
20040b57cec5SDimitry Andric
2005*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
2006*06c3fb27SDimitry Andric
20070b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
20080b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
20090b57cec5SDimitry Andricbool
20100b57cec5SDimitry Andricoperator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
20110b57cec5SDimitry Andric           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
20120b57cec5SDimitry Andric{
20130b57cec5SDimitry Andric    return !(__x == __y);
20140b57cec5SDimitry Andric}
20150b57cec5SDimitry Andric
2016*06c3fb27SDimitry Andric#endif
2017*06c3fb27SDimitry Andric
20180b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
20190b57cec5SDimitry Andric          class _Alloc = allocator<pair<const _Key, _Tp> > >
20200b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multimap
20210b57cec5SDimitry Andric{
20220b57cec5SDimitry Andricpublic:
20230b57cec5SDimitry Andric    // types
20240b57cec5SDimitry Andric    typedef _Key                                           key_type;
20250b57cec5SDimitry Andric    typedef _Tp                                            mapped_type;
202681ad6265SDimitry Andric    typedef __type_identity_t<_Hash>                       hasher;
202781ad6265SDimitry Andric    typedef __type_identity_t<_Pred>                       key_equal;
202881ad6265SDimitry Andric    typedef __type_identity_t<_Alloc>                      allocator_type;
20290b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>              value_type;
20300b57cec5SDimitry Andric    typedef value_type&                                    reference;
20310b57cec5SDimitry Andric    typedef const value_type&                              const_reference;
20320b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
2033*06c3fb27SDimitry Andric                  "Allocator::value_type must be same type as value_type");
20340b57cec5SDimitry Andric
20350b57cec5SDimitry Andricprivate:
20360b57cec5SDimitry Andric    typedef __hash_value_type<key_type, mapped_type>                          __value_type;
2037e8d8bef9SDimitry Andric    typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
2038e8d8bef9SDimitry Andric    typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher>  __key_equal;
2039bdd1243dSDimitry Andric    typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type>    __allocator_type;
20400b57cec5SDimitry Andric
20410b57cec5SDimitry Andric    typedef __hash_table<__value_type, __hasher,
20420b57cec5SDimitry Andric                         __key_equal,  __allocator_type>   __table;
20430b57cec5SDimitry Andric
20440b57cec5SDimitry Andric    __table __table_;
20450b57cec5SDimitry Andric
20460b57cec5SDimitry Andric    typedef typename __table::_NodeTypes                   _NodeTypes;
20470b57cec5SDimitry Andric    typedef typename __table::__node_traits                __node_traits;
20480b57cec5SDimitry Andric    typedef typename __table::__node_allocator             __node_allocator;
20490b57cec5SDimitry Andric    typedef typename __table::__node                       __node;
20500b57cec5SDimitry Andric    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
20510b57cec5SDimitry Andric    typedef unique_ptr<__node, _Dp>                         __node_holder;
20520b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>               __alloc_traits;
20530b57cec5SDimitry Andric    static_assert((is_same<typename __node_traits::size_type,
20540b57cec5SDimitry Andric                          typename __alloc_traits::size_type>::value),
20550b57cec5SDimitry Andric                 "Allocator uses different size_type for different types");
2056bdd1243dSDimitry Andric
2057bdd1243dSDimitry Andric    static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
2058bdd1243dSDimitry Andric                  "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
2059bdd1243dSDimitry Andric                  "original allocator");
2060bdd1243dSDimitry Andric
20610b57cec5SDimitry Andric  public:
20620b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer         pointer;
20630b57cec5SDimitry Andric    typedef typename __alloc_traits::const_pointer   const_pointer;
20640b57cec5SDimitry Andric    typedef typename __table::size_type              size_type;
20650b57cec5SDimitry Andric    typedef typename __table::difference_type        difference_type;
20660b57cec5SDimitry Andric
20670b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::iterator>       iterator;
20680b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
20690b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
20700b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
20710b57cec5SDimitry Andric
2072*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
20730b57cec5SDimitry Andric    typedef __map_node_handle<__node, allocator_type> node_type;
20740b57cec5SDimitry Andric#endif
20750b57cec5SDimitry Andric
20760b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
20770b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_map;
20780b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
20790b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
20800b57cec5SDimitry Andric
20810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20820b57cec5SDimitry Andric    unordered_multimap()
20830b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
20840b57cec5SDimitry Andric    {
20850b57cec5SDimitry Andric    }
2086*06c3fb27SDimitry Andric    explicit _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const hasher& __hf = hasher(),
20870b57cec5SDimitry Andric                                const key_equal& __eql = key_equal());
2088*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const hasher& __hf,
20890b57cec5SDimitry Andric                                const key_equal& __eql,
20900b57cec5SDimitry Andric                                const allocator_type& __a);
20910b57cec5SDimitry Andric    template <class _InputIterator>
2092*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(_InputIterator __first, _InputIterator __last);
20930b57cec5SDimitry Andric    template <class _InputIterator>
2094*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(_InputIterator __first, _InputIterator __last,
20950b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
20960b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
20970b57cec5SDimitry Andric    template <class _InputIterator>
2098*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(_InputIterator __first, _InputIterator __last,
20990b57cec5SDimitry Andric                      size_type __n, const hasher& __hf,
21000b57cec5SDimitry Andric                      const key_equal& __eql,
21010b57cec5SDimitry Andric                      const allocator_type& __a);
2102*06c3fb27SDimitry Andric
2103*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
2104*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<value_type> _Range>
2105*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
2106*06c3fb27SDimitry Andric    unordered_multimap(from_range_t, _Range&& __range, size_type __n = /*implementation-defined*/0,
2107*06c3fb27SDimitry Andric                       const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),
2108*06c3fb27SDimitry Andric                       const allocator_type& __a = allocator_type())
2109*06c3fb27SDimitry Andric        : __table_(__hf, __eql, typename __table::allocator_type(__a)) {
2110*06c3fb27SDimitry Andric      if (__n > 0) {
2111*06c3fb27SDimitry Andric        __table_.__rehash_multi(__n);
2112*06c3fb27SDimitry Andric      }
2113*06c3fb27SDimitry Andric      insert_range(std::forward<_Range>(__range));
2114*06c3fb27SDimitry Andric    }
2115*06c3fb27SDimitry Andric#endif
2116*06c3fb27SDimitry Andric
21170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21180b57cec5SDimitry Andric    explicit unordered_multimap(const allocator_type& __a);
2119*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u);
2120*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
21210b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
21220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21230b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&& __u)
21240b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
2125*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
2126*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il);
2127*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il, size_type __n,
21280b57cec5SDimitry Andric                       const hasher& __hf = hasher(),
21290b57cec5SDimitry Andric                       const key_equal& __eql = key_equal());
2130*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il, size_type __n,
21310b57cec5SDimitry Andric                       const hasher& __hf, const key_equal& __eql,
21320b57cec5SDimitry Andric                       const allocator_type& __a);
21330b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
2134*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 14
21350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21360b57cec5SDimitry Andric    unordered_multimap(size_type __n, const allocator_type& __a)
21370b57cec5SDimitry Andric      : unordered_multimap(__n, hasher(), key_equal(), __a) {}
21380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21390b57cec5SDimitry Andric    unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
21400b57cec5SDimitry Andric      : unordered_multimap(__n, __hf, key_equal(), __a) {}
21410b57cec5SDimitry Andric    template <class _InputIterator>
21420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21430b57cec5SDimitry Andric      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
21440b57cec5SDimitry Andric      : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
21450b57cec5SDimitry Andric    template <class _InputIterator>
21460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21470b57cec5SDimitry Andric      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
21480b57cec5SDimitry Andric        const allocator_type& __a)
21490b57cec5SDimitry Andric      : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
2150*06c3fb27SDimitry Andric
2151*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
2152*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<value_type> _Range>
2153*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
2154*06c3fb27SDimitry Andric    unordered_multimap(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
2155*06c3fb27SDimitry Andric        : unordered_multimap(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
2156*06c3fb27SDimitry Andric
2157*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<value_type> _Range>
2158*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
2159*06c3fb27SDimitry Andric    unordered_multimap(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
2160*06c3fb27SDimitry Andric        : unordered_multimap(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
2161*06c3fb27SDimitry Andric#endif
2162*06c3fb27SDimitry Andric
21630b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21640b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
21650b57cec5SDimitry Andric      : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
21660b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21670b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
21680b57cec5SDimitry Andric      const allocator_type& __a)
21690b57cec5SDimitry Andric      : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
21700b57cec5SDimitry Andric#endif
21710b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21720b57cec5SDimitry Andric    ~unordered_multimap() {
2173bdd1243dSDimitry Andric        static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
21740b57cec5SDimitry Andric    }
21750b57cec5SDimitry Andric
21760b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21770b57cec5SDimitry Andric    unordered_multimap& operator=(const unordered_multimap& __u)
21780b57cec5SDimitry Andric    {
21790b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
21800b57cec5SDimitry Andric        __table_ = __u.__table_;
21810b57cec5SDimitry Andric#else
2182349cc55cSDimitry Andric        if (this != _VSTD::addressof(__u)) {
21830b57cec5SDimitry Andric            __table_.clear();
21840b57cec5SDimitry Andric            __table_.hash_function() = __u.__table_.hash_function();
21850b57cec5SDimitry Andric            __table_.key_eq() = __u.__table_.key_eq();
21860b57cec5SDimitry Andric            __table_.max_load_factor() = __u.__table_.max_load_factor();
21870b57cec5SDimitry Andric            __table_.__copy_assign_alloc(__u.__table_);
21880b57cec5SDimitry Andric            insert(__u.begin(), __u.end());
21890b57cec5SDimitry Andric        }
21900b57cec5SDimitry Andric#endif
21910b57cec5SDimitry Andric        return *this;
21920b57cec5SDimitry Andric    }
21930b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
21940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21950b57cec5SDimitry Andric    unordered_multimap& operator=(unordered_multimap&& __u)
21960b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
21970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21980b57cec5SDimitry Andric    unordered_multimap& operator=(initializer_list<value_type> __il);
21990b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
22000b57cec5SDimitry Andric
22010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22020b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
22030b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
22040b57cec5SDimitry Andric
22050b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
22060b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
22070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22080b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
22090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22100b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
22110b57cec5SDimitry Andric
22120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22130b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
22140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22150b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
22160b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22170b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
22180b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22190b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
22200b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22210b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
22220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22230b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
22240b57cec5SDimitry Andric
22250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22260b57cec5SDimitry Andric    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
22270b57cec5SDimitry Andric
22280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22290b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __x)
22300b57cec5SDimitry Andric        {return __table_.__insert_multi(__p.__i_, __x);}
22310b57cec5SDimitry Andric
22320b57cec5SDimitry Andric    template <class _InputIterator>
22330b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22340b57cec5SDimitry Andric    void insert(_InputIterator __first, _InputIterator __last);
22350b57cec5SDimitry Andric
2236*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
2237*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<value_type> _Range>
2238*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
2239*06c3fb27SDimitry Andric    void insert_range(_Range&& __range) {
2240*06c3fb27SDimitry Andric      for (auto&& __element : __range) {
2241*06c3fb27SDimitry Andric        __table_.__insert_multi(std::forward<decltype(__element)>(__element));
2242*06c3fb27SDimitry Andric      }
2243*06c3fb27SDimitry Andric    }
2244*06c3fb27SDimitry Andric#endif
2245*06c3fb27SDimitry Andric
22460b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
22470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22480b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
22490b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
22500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22510b57cec5SDimitry Andric    iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
22520b57cec5SDimitry Andric
22530b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22540b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __x)
22550b57cec5SDimitry Andric        {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));}
22560b57cec5SDimitry Andric
22570b57cec5SDimitry Andric    template <class _Pp,
2258753f127fSDimitry Andric              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
22590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22600b57cec5SDimitry Andric    iterator insert(_Pp&& __x)
22610b57cec5SDimitry Andric        {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
22620b57cec5SDimitry Andric
22630b57cec5SDimitry Andric    template <class _Pp,
2264753f127fSDimitry Andric              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
22650b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22660b57cec5SDimitry Andric    iterator insert(const_iterator __p, _Pp&& __x)
22670b57cec5SDimitry Andric        {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
22680b57cec5SDimitry Andric
22690b57cec5SDimitry Andric    template <class... _Args>
2270*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
22710b57cec5SDimitry Andric        return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
22720b57cec5SDimitry Andric    }
22730b57cec5SDimitry Andric
22740b57cec5SDimitry Andric    template <class... _Args>
2275*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
22760b57cec5SDimitry Andric        return __table_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
22770b57cec5SDimitry Andric    }
22780b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
22790b57cec5SDimitry Andric
22800b57cec5SDimitry Andric
22810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22820b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
22830b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22840b57cec5SDimitry Andric    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
22850b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22860b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
22870b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22880b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
22890b57cec5SDimitry Andric        {return __table_.erase(__first.__i_, __last.__i_);}
22900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22910b57cec5SDimitry Andric    void clear() _NOEXCEPT {__table_.clear();}
22920b57cec5SDimitry Andric
2293*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
22940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22950b57cec5SDimitry Andric    iterator insert(node_type&& __nh)
22960b57cec5SDimitry Andric    {
2297*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
22980b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multimap::insert()");
22990b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
23000b57cec5SDimitry Andric            _VSTD::move(__nh));
23010b57cec5SDimitry Andric    }
23020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23030b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
23040b57cec5SDimitry Andric    {
2305*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
23060b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multimap::insert()");
23070b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
23080b57cec5SDimitry Andric            __hint.__i_, _VSTD::move(__nh));
23090b57cec5SDimitry Andric    }
23100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23110b57cec5SDimitry Andric    node_type extract(key_type const& __key)
23120b57cec5SDimitry Andric    {
23130b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
23140b57cec5SDimitry Andric    }
23150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23160b57cec5SDimitry Andric    node_type extract(const_iterator __it)
23170b57cec5SDimitry Andric    {
23180b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(
23190b57cec5SDimitry Andric            __it.__i_);
23200b57cec5SDimitry Andric    }
23210b57cec5SDimitry Andric
23220b57cec5SDimitry Andric    template <class _H2, class _P2>
23230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23240b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
23250b57cec5SDimitry Andric    {
2326*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(),
23270b57cec5SDimitry Andric                                            "merging container with incompatible allocator");
23280b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
23290b57cec5SDimitry Andric    }
23300b57cec5SDimitry Andric    template <class _H2, class _P2>
23310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23320b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
23330b57cec5SDimitry Andric    {
2334*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(),
23350b57cec5SDimitry Andric                                            "merging container with incompatible allocator");
23360b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
23370b57cec5SDimitry Andric    }
23380b57cec5SDimitry Andric    template <class _H2, class _P2>
23390b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23400b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
23410b57cec5SDimitry Andric    {
2342*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(),
23430b57cec5SDimitry Andric                                            "merging container with incompatible allocator");
23440b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
23450b57cec5SDimitry Andric    }
23460b57cec5SDimitry Andric    template <class _H2, class _P2>
23470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23480b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
23490b57cec5SDimitry Andric    {
2350*06c3fb27SDimitry Andric        _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__source.get_allocator() == get_allocator(),
23510b57cec5SDimitry Andric                                            "merging container with incompatible allocator");
23520b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
23530b57cec5SDimitry Andric    }
23540b57cec5SDimitry Andric#endif
23550b57cec5SDimitry Andric
23560b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23570b57cec5SDimitry Andric    void swap(unordered_multimap& __u)
23580b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
23590b57cec5SDimitry Andric        {__table_.swap(__u.__table_);}
23600b57cec5SDimitry Andric
23610b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23620b57cec5SDimitry Andric    hasher hash_function() const
23630b57cec5SDimitry Andric        {return __table_.hash_function().hash_function();}
23640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23650b57cec5SDimitry Andric    key_equal key_eq() const
23660b57cec5SDimitry Andric        {return __table_.key_eq().key_eq();}
23670b57cec5SDimitry Andric
23680b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23690b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
23700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23710b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
2372*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
2373349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2374e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2375349cc55cSDimitry Andric    iterator       find(const _K2& __k)            {return __table_.find(__k);}
2376349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2377e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2378349cc55cSDimitry Andric    const_iterator find(const _K2& __k) const      {return __table_.find(__k);}
2379*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
2380349cc55cSDimitry Andric
23810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23820b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
2383*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
2384349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2385e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2386349cc55cSDimitry Andric    size_type count(const _K2& __k) const      {return __table_.__count_multi(__k);}
2387*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
2388349cc55cSDimitry Andric
2389*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
23900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23910b57cec5SDimitry Andric    bool contains(const key_type& __k) const {return find(__k) != end();}
2392e8d8bef9SDimitry Andric
2393349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2394e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2395349cc55cSDimitry Andric    bool contains(const _K2& __k) const      {return find(__k) != end();}
2396*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
2397349cc55cSDimitry Andric
23980b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23990b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
24000b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
24010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24020b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
24030b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
2404*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
2405349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2406e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2407349cc55cSDimitry Andric    pair<iterator, iterator>             equal_range(const _K2& __k)
2408349cc55cSDimitry Andric        {return __table_.__equal_range_multi(__k);}
2409349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2410e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2411349cc55cSDimitry Andric    pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
2412349cc55cSDimitry Andric        {return __table_.__equal_range_multi(__k);}
2413*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER >= 20
24140b57cec5SDimitry Andric
24150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24160b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
24170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24180b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT
24190b57cec5SDimitry Andric        {return __table_.max_bucket_count();}
24200b57cec5SDimitry Andric
24210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24220b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const
24230b57cec5SDimitry Andric        {return __table_.bucket_size(__n);}
24240b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24250b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
24260b57cec5SDimitry Andric
24270b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24280b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
24290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24300b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
24310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24320b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
24330b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24340b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
24350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24360b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
24370b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24380b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
24390b57cec5SDimitry Andric
24400b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24410b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
24420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24430b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
24440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
24450b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
24460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2447753f127fSDimitry Andric    void rehash(size_type __n) {__table_.__rehash_multi(__n);}
24480b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2449753f127fSDimitry Andric    void reserve(size_type __n) {__table_.__reserve_multi(__n);}
24500b57cec5SDimitry Andric};
24510b57cec5SDimitry Andric
2452349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
24530b57cec5SDimitry Andrictemplate<class _InputIterator,
24540b57cec5SDimitry Andric         class _Hash = hash<__iter_key_type<_InputIterator>>,
24550b57cec5SDimitry Andric         class _Pred = equal_to<__iter_key_type<_InputIterator>>,
24560b57cec5SDimitry Andric         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
2457*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
2458349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
2459349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
2460349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Pred>::value>,
2461349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
24620b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
24630b57cec5SDimitry Andric                   _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
24640b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
24650b57cec5SDimitry Andric
2466*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
2467*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
2468*06c3fb27SDimitry Andric          class _Hash = hash<__range_key_type<_Range>>,
2469*06c3fb27SDimitry Andric          class _Pred = equal_to<__range_key_type<_Range>>,
2470*06c3fb27SDimitry Andric          class _Allocator = allocator<__range_to_alloc_type<_Range>>,
2471*06c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
2472*06c3fb27SDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
2473*06c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Pred>::value>,
2474*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
2475*06c3fb27SDimitry Andricunordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type = 0,
2476*06c3fb27SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
2477*06c3fb27SDimitry Andric  -> unordered_multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>;
2478*06c3fb27SDimitry Andric#endif
2479*06c3fb27SDimitry Andric
24800b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>,
24810b57cec5SDimitry Andric         class _Pred = equal_to<remove_const_t<_Key>>,
24820b57cec5SDimitry Andric         class _Allocator = allocator<pair<const _Key, _Tp>>,
2483349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
2484349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
2485349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Pred>::value>,
2486349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
24870b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0,
24880b57cec5SDimitry Andric                   _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
24890b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
24900b57cec5SDimitry Andric
24910b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
2492*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
2493349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
24940b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
24950b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
24960b57cec5SDimitry Andric                        hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
24970b57cec5SDimitry Andric
24980b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
2499*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
2500349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
25010b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, _Allocator)
25020b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
25030b57cec5SDimitry Andric                        hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
25040b57cec5SDimitry Andric
25050b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
2506*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
2507349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
2508349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
2509349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
25100b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
25110b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
25120b57cec5SDimitry Andric                        _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
25130b57cec5SDimitry Andric
2514*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
2515*06c3fb27SDimitry Andric
2516*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator,
2517*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
2518*06c3fb27SDimitry Andricunordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
2519*06c3fb27SDimitry Andric  -> unordered_multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, hash<__range_key_type<_Range>>,
2520*06c3fb27SDimitry Andric                   equal_to<__range_key_type<_Range>>, _Allocator>;
2521*06c3fb27SDimitry Andric
2522*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Allocator,
2523*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
2524*06c3fb27SDimitry Andricunordered_multimap(from_range_t, _Range&&, _Allocator)
2525*06c3fb27SDimitry Andric  -> unordered_multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, hash<__range_key_type<_Range>>,
2526*06c3fb27SDimitry Andric                   equal_to<__range_key_type<_Range>>, _Allocator>;
2527*06c3fb27SDimitry Andric
2528*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range, class _Hash, class _Allocator,
2529*06c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Hash>::value>,
2530*06c3fb27SDimitry Andric          class = enable_if_t<!is_integral<_Hash>::value>,
2531*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value>>
2532*06c3fb27SDimitry Andricunordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
2533*06c3fb27SDimitry Andric  -> unordered_multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash,
2534*06c3fb27SDimitry Andric                   equal_to<__range_key_type<_Range>>, _Allocator>;
2535*06c3fb27SDimitry Andric
2536*06c3fb27SDimitry Andric#endif
2537*06c3fb27SDimitry Andric
25380b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
2539349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
25400b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
25410b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp,
25420b57cec5SDimitry Andric                        hash<remove_const_t<_Key>>,
25430b57cec5SDimitry Andric                        equal_to<remove_const_t<_Key>>, _Allocator>;
25440b57cec5SDimitry Andric
25450b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
2546349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
25470b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
25480b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp,
25490b57cec5SDimitry Andric                        hash<remove_const_t<_Key>>,
25500b57cec5SDimitry Andric                        equal_to<remove_const_t<_Key>>, _Allocator>;
25510b57cec5SDimitry Andric
25520b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash, class _Allocator,
2553349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
2554349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
2555349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
25560b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
25570b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash,
25580b57cec5SDimitry Andric                        equal_to<remove_const_t<_Key>>, _Allocator>;
25590b57cec5SDimitry Andric#endif
25600b57cec5SDimitry Andric
25610b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25620b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
25630b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql)
25640b57cec5SDimitry Andric    : __table_(__hf, __eql)
25650b57cec5SDimitry Andric{
2566753f127fSDimitry Andric    __table_.__rehash_multi(__n);
25670b57cec5SDimitry Andric}
25680b57cec5SDimitry Andric
25690b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25700b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
25710b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql,
25720b57cec5SDimitry Andric        const allocator_type& __a)
25730b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
25740b57cec5SDimitry Andric{
2575753f127fSDimitry Andric    __table_.__rehash_multi(__n);
25760b57cec5SDimitry Andric}
25770b57cec5SDimitry Andric
25780b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25790b57cec5SDimitry Andrictemplate <class _InputIterator>
25800b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
25810b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
25820b57cec5SDimitry Andric{
25830b57cec5SDimitry Andric    insert(__first, __last);
25840b57cec5SDimitry Andric}
25850b57cec5SDimitry Andric
25860b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25870b57cec5SDimitry Andrictemplate <class _InputIterator>
25880b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
25890b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
25900b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
25910b57cec5SDimitry Andric    : __table_(__hf, __eql)
25920b57cec5SDimitry Andric{
2593753f127fSDimitry Andric    __table_.__rehash_multi(__n);
25940b57cec5SDimitry Andric    insert(__first, __last);
25950b57cec5SDimitry Andric}
25960b57cec5SDimitry Andric
25970b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25980b57cec5SDimitry Andrictemplate <class _InputIterator>
25990b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
26000b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
26010b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
26020b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
26030b57cec5SDimitry Andric{
2604753f127fSDimitry Andric    __table_.__rehash_multi(__n);
26050b57cec5SDimitry Andric    insert(__first, __last);
26060b57cec5SDimitry Andric}
26070b57cec5SDimitry Andric
26080b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26090b57cec5SDimitry Andricinline
26100b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
26110b57cec5SDimitry Andric        const allocator_type& __a)
26120b57cec5SDimitry Andric    : __table_(typename __table::allocator_type(__a))
26130b57cec5SDimitry Andric{
26140b57cec5SDimitry Andric}
26150b57cec5SDimitry Andric
26160b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26170b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
26180b57cec5SDimitry Andric        const unordered_multimap& __u)
26190b57cec5SDimitry Andric    : __table_(__u.__table_)
26200b57cec5SDimitry Andric{
2621753f127fSDimitry Andric    __table_.__rehash_multi(__u.bucket_count());
26220b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
26230b57cec5SDimitry Andric}
26240b57cec5SDimitry Andric
26250b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26260b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
26270b57cec5SDimitry Andric        const unordered_multimap& __u, const allocator_type& __a)
26280b57cec5SDimitry Andric    : __table_(__u.__table_, typename __table::allocator_type(__a))
26290b57cec5SDimitry Andric{
2630753f127fSDimitry Andric    __table_.__rehash_multi(__u.bucket_count());
26310b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
26320b57cec5SDimitry Andric}
26330b57cec5SDimitry Andric
26340b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
26350b57cec5SDimitry Andric
26360b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26370b57cec5SDimitry Andricinline
26380b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
26390b57cec5SDimitry Andric        unordered_multimap&& __u)
26400b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
26410b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
26420b57cec5SDimitry Andric{
26430b57cec5SDimitry Andric}
26440b57cec5SDimitry Andric
26450b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26460b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
26470b57cec5SDimitry Andric        unordered_multimap&& __u, const allocator_type& __a)
26480b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
26490b57cec5SDimitry Andric{
26500b57cec5SDimitry Andric    if (__a != __u.get_allocator())
26510b57cec5SDimitry Andric    {
26520b57cec5SDimitry Andric        iterator __i = __u.begin();
26530b57cec5SDimitry Andric        while (__u.size() != 0)
26540b57cec5SDimitry Andric        {
26550b57cec5SDimitry Andric            __table_.__insert_multi(
26560b57cec5SDimitry Andric                __u.__table_.remove((__i++).__i_)->__value_.__move());
26570b57cec5SDimitry Andric        }
26580b57cec5SDimitry Andric    }
26590b57cec5SDimitry Andric}
26600b57cec5SDimitry Andric
26610b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26620b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
26630b57cec5SDimitry Andric        initializer_list<value_type> __il)
26640b57cec5SDimitry Andric{
26650b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
26660b57cec5SDimitry Andric}
26670b57cec5SDimitry Andric
26680b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26690b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
26700b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
26710b57cec5SDimitry Andric        const key_equal& __eql)
26720b57cec5SDimitry Andric    : __table_(__hf, __eql)
26730b57cec5SDimitry Andric{
2674753f127fSDimitry Andric    __table_.__rehash_multi(__n);
26750b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
26760b57cec5SDimitry Andric}
26770b57cec5SDimitry Andric
26780b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26790b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
26800b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
26810b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
26820b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
26830b57cec5SDimitry Andric{
2684753f127fSDimitry Andric    __table_.__rehash_multi(__n);
26850b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
26860b57cec5SDimitry Andric}
26870b57cec5SDimitry Andric
26880b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26890b57cec5SDimitry Andricinline
26900b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
26910b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
26920b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
26930b57cec5SDimitry Andric{
26940b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
26950b57cec5SDimitry Andric    return *this;
26960b57cec5SDimitry Andric}
26970b57cec5SDimitry Andric
26980b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26990b57cec5SDimitry Andricinline
27000b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
27010b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
27020b57cec5SDimitry Andric        initializer_list<value_type> __il)
27030b57cec5SDimitry Andric{
27040b57cec5SDimitry Andric    __table_.__assign_multi(__il.begin(), __il.end());
27050b57cec5SDimitry Andric    return *this;
27060b57cec5SDimitry Andric}
27070b57cec5SDimitry Andric
27080b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
27090b57cec5SDimitry Andric
27100b57cec5SDimitry Andric
27110b57cec5SDimitry Andric
27120b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
27130b57cec5SDimitry Andrictemplate <class _InputIterator>
27140b57cec5SDimitry Andricinline
27150b57cec5SDimitry Andricvoid
27160b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
27170b57cec5SDimitry Andric                                                            _InputIterator __last)
27180b57cec5SDimitry Andric{
27190b57cec5SDimitry Andric    for (; __first != __last; ++__first)
27200b57cec5SDimitry Andric        __table_.__insert_multi(*__first);
27210b57cec5SDimitry Andric}
27220b57cec5SDimitry Andric
27230b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
27240b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
27250b57cec5SDimitry Andricvoid
27260b57cec5SDimitry Andricswap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
27270b57cec5SDimitry Andric     unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
27280b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
27290b57cec5SDimitry Andric{
27300b57cec5SDimitry Andric    __x.swap(__y);
27310b57cec5SDimitry Andric}
27320b57cec5SDimitry Andric
2733*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
27345ffd83dbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
27355ffd83dbSDimitry Andric          class _Predicate>
27360b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
27375ffd83dbSDimitry Andric    typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
27385ffd83dbSDimitry Andric    erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c,
27395ffd83dbSDimitry Andric             _Predicate __pred) {
2740fe6060f1SDimitry Andric  return _VSTD::__libcpp_erase_if_container(__c, __pred);
27415ffd83dbSDimitry Andric}
27420b57cec5SDimitry Andric#endif
27430b57cec5SDimitry Andric
27440b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2745bdd1243dSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool
27460b57cec5SDimitry Andricoperator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
27470b57cec5SDimitry Andric           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
27480b57cec5SDimitry Andric{
27490b57cec5SDimitry Andric    if (__x.size() != __y.size())
27500b57cec5SDimitry Andric        return false;
27510b57cec5SDimitry Andric    typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
27520b57cec5SDimitry Andric                                                                 const_iterator;
27530b57cec5SDimitry Andric    typedef pair<const_iterator, const_iterator> _EqRng;
27540b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
27550b57cec5SDimitry Andric    {
27560b57cec5SDimitry Andric        _EqRng __xeq = __x.equal_range(__i->first);
27570b57cec5SDimitry Andric        _EqRng __yeq = __y.equal_range(__i->first);
27580b57cec5SDimitry Andric        if (_VSTD::distance(__xeq.first, __xeq.second) !=
27590b57cec5SDimitry Andric            _VSTD::distance(__yeq.first, __yeq.second) ||
27600b57cec5SDimitry Andric                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
27610b57cec5SDimitry Andric            return false;
27620b57cec5SDimitry Andric        __i = __xeq.second;
27630b57cec5SDimitry Andric    }
27640b57cec5SDimitry Andric    return true;
27650b57cec5SDimitry Andric}
27660b57cec5SDimitry Andric
2767*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17
2768*06c3fb27SDimitry Andric
27690b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
27700b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
27710b57cec5SDimitry Andricbool
27720b57cec5SDimitry Andricoperator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
27730b57cec5SDimitry Andric           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
27740b57cec5SDimitry Andric{
27750b57cec5SDimitry Andric    return !(__x == __y);
27760b57cec5SDimitry Andric}
27770b57cec5SDimitry Andric
2778*06c3fb27SDimitry Andric#endif
2779*06c3fb27SDimitry Andric
27800b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
27810b57cec5SDimitry Andric
2782*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
2783bdd1243dSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
2784bdd1243dSDimitry Andricnamespace pmr {
2785bdd1243dSDimitry Andrictemplate <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
2786*06c3fb27SDimitry Andricusing unordered_map _LIBCPP_AVAILABILITY_PMR =
2787bdd1243dSDimitry Andric    std::unordered_map<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2788bdd1243dSDimitry Andric
2789bdd1243dSDimitry Andrictemplate <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
2790*06c3fb27SDimitry Andricusing unordered_multimap _LIBCPP_AVAILABILITY_PMR =
2791bdd1243dSDimitry Andric    std::unordered_multimap<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2792bdd1243dSDimitry Andric} // namespace pmr
2793bdd1243dSDimitry Andric_LIBCPP_END_NAMESPACE_STD
2794bdd1243dSDimitry Andric#endif
2795bdd1243dSDimitry Andric
2796bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2797bdd1243dSDimitry Andric#  include <algorithm>
2798bdd1243dSDimitry Andric#  include <bit>
2799bdd1243dSDimitry Andric#  include <concepts>
2800*06c3fb27SDimitry Andric#  include <cstdlib>
2801bdd1243dSDimitry Andric#  include <iterator>
2802*06c3fb27SDimitry Andric#  include <type_traits>
2803bdd1243dSDimitry Andric#endif
2804bdd1243dSDimitry Andric
28050b57cec5SDimitry Andric#endif // _LIBCPP_UNORDERED_MAP
2806