xref: /freebsd/contrib/llvm-project/libcxx/include/unordered_map (revision 753f127f3ace09432b2baeffd71a308760641a62)
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());
620b57cec5SDimitry Andric    explicit unordered_map(const allocator_type&);
630b57cec5SDimitry Andric    unordered_map(const unordered_map&);
640b57cec5SDimitry Andric    unordered_map(const unordered_map&, const Allocator&);
650b57cec5SDimitry Andric    unordered_map(unordered_map&&)
660b57cec5SDimitry Andric        noexcept(
670b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
680b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
690b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
700b57cec5SDimitry Andric    unordered_map(unordered_map&&, const Allocator&);
710b57cec5SDimitry Andric    unordered_map(initializer_list<value_type>, size_type n = 0,
720b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
730b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
740b57cec5SDimitry Andric    unordered_map(size_type n, const allocator_type& a)
750b57cec5SDimitry Andric      : unordered_map(n, hasher(), key_equal(), a) {}  // C++14
760b57cec5SDimitry Andric    unordered_map(size_type n, const hasher& hf, const allocator_type& a)
770b57cec5SDimitry Andric      : unordered_map(n, hf, key_equal(), a) {}  // C++14
780b57cec5SDimitry Andric    template <class InputIterator>
790b57cec5SDimitry Andric      unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
800b57cec5SDimitry Andric      : unordered_map(f, l, n, hasher(), key_equal(), a) {}  // C++14
810b57cec5SDimitry Andric    template <class InputIterator>
820b57cec5SDimitry Andric      unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
830b57cec5SDimitry Andric        const allocator_type& a)
840b57cec5SDimitry Andric      : unordered_map(f, l, n, hf, key_equal(), a) {}  // C++14
850b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
860b57cec5SDimitry Andric      : unordered_map(il, n, hasher(), key_equal(), a) {}  // C++14
870b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
880b57cec5SDimitry Andric      const allocator_type& a)
890b57cec5SDimitry Andric      : unordered_map(il, n, hf, key_equal(), a) {}  // C++14
900b57cec5SDimitry Andric    ~unordered_map();
910b57cec5SDimitry Andric    unordered_map& operator=(const unordered_map&);
920b57cec5SDimitry Andric    unordered_map& operator=(unordered_map&&)
930b57cec5SDimitry Andric        noexcept(
940b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
950b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
960b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
970b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
980b57cec5SDimitry Andric    unordered_map& operator=(initializer_list<value_type>);
990b57cec5SDimitry Andric
1000b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
1010b57cec5SDimitry Andric
1020b57cec5SDimitry Andric    bool      empty() const noexcept;
1030b57cec5SDimitry Andric    size_type size() const noexcept;
1040b57cec5SDimitry Andric    size_type max_size() const noexcept;
1050b57cec5SDimitry Andric
1060b57cec5SDimitry Andric    iterator       begin() noexcept;
1070b57cec5SDimitry Andric    iterator       end() noexcept;
1080b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
1090b57cec5SDimitry Andric    const_iterator end()    const noexcept;
1100b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
1110b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
1120b57cec5SDimitry Andric
1130b57cec5SDimitry Andric    template <class... Args>
1140b57cec5SDimitry Andric        pair<iterator, bool> emplace(Args&&... args);
1150b57cec5SDimitry Andric    template <class... Args>
1160b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
1170b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& obj);
1180b57cec5SDimitry Andric    template <class P>
1190b57cec5SDimitry Andric        pair<iterator, bool> insert(P&& obj);
1200b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
1210b57cec5SDimitry Andric    template <class P>
1220b57cec5SDimitry Andric        iterator insert(const_iterator hint, P&& obj);
1230b57cec5SDimitry Andric    template <class InputIterator>
1240b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
1250b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
1260b57cec5SDimitry Andric
1270b57cec5SDimitry Andric    node_type extract(const_iterator position);                                       // C++17
1280b57cec5SDimitry Andric    node_type extract(const key_type& x);                                             // C++17
1290b57cec5SDimitry Andric    insert_return_type insert(node_type&& nh);                                        // C++17
1300b57cec5SDimitry Andric    iterator           insert(const_iterator hint, node_type&& nh);                   // C++17
1310b57cec5SDimitry Andric
1320b57cec5SDimitry Andric    template <class... Args>
1330b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);          // C++17
1340b57cec5SDimitry Andric    template <class... Args>
1350b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);               // C++17
1360b57cec5SDimitry Andric    template <class... Args>
1370b57cec5SDimitry Andric        iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
1380b57cec5SDimitry Andric    template <class... Args>
1390b57cec5SDimitry Andric        iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);      // C++17
1400b57cec5SDimitry Andric    template <class M>
1410b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);            // C++17
1420b57cec5SDimitry Andric    template <class M>
1430b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);                 // C++17
1440b57cec5SDimitry Andric    template <class M>
1450b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);   // C++17
1460b57cec5SDimitry Andric    template <class M>
1470b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);        // C++17
1480b57cec5SDimitry Andric
1490b57cec5SDimitry Andric    iterator erase(const_iterator position);
1500b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
1510b57cec5SDimitry Andric    size_type erase(const key_type& k);
1520b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
1530b57cec5SDimitry Andric    void clear() noexcept;
1540b57cec5SDimitry Andric
1550b57cec5SDimitry Andric    template<class H2, class P2>
1560b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>& source);         // C++17
1570b57cec5SDimitry Andric    template<class H2, class P2>
1580b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>&& source);        // C++17
1590b57cec5SDimitry Andric    template<class H2, class P2>
1600b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source);    // C++17
1610b57cec5SDimitry Andric    template<class H2, class P2>
1620b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source);   // C++17
1630b57cec5SDimitry Andric
1640b57cec5SDimitry Andric    void swap(unordered_map&)
1650b57cec5SDimitry Andric        noexcept(
1660b57cec5SDimitry Andric            (!allocator_type::propagate_on_container_swap::value ||
1670b57cec5SDimitry Andric             __is_nothrow_swappable<allocator_type>::value) &&
1680b57cec5SDimitry Andric            __is_nothrow_swappable<hasher>::value &&
1690b57cec5SDimitry Andric            __is_nothrow_swappable<key_equal>::value);
1700b57cec5SDimitry Andric
1710b57cec5SDimitry Andric    hasher hash_function() const;
1720b57cec5SDimitry Andric    key_equal key_eq() const;
1730b57cec5SDimitry Andric
1740b57cec5SDimitry Andric    iterator       find(const key_type& k);
1750b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
176e8d8bef9SDimitry Andric    template<typename K>
177e8d8bef9SDimitry Andric        iterator find(const K& x);              // C++20
178e8d8bef9SDimitry Andric    template<typename K>
179e8d8bef9SDimitry Andric        const_iterator find(const K& x) const;  // C++20
1800b57cec5SDimitry Andric    size_type count(const key_type& k) const;
181e8d8bef9SDimitry Andric    template<typename K>
182e8d8bef9SDimitry Andric        size_type count(const K& k) const; // C++20
1830b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
184e8d8bef9SDimitry Andric    template<typename K>
185e8d8bef9SDimitry Andric        bool contains(const K& k) const; // C++20
1860b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
1870b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
188e8d8bef9SDimitry Andric    template<typename K>
189e8d8bef9SDimitry Andric        pair<iterator, iterator>             equal_range(const K& k); // C++20
190e8d8bef9SDimitry Andric    template<typename K>
191e8d8bef9SDimitry Andric        pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
1920b57cec5SDimitry Andric
1930b57cec5SDimitry Andric    mapped_type& operator[](const key_type& k);
1940b57cec5SDimitry Andric    mapped_type& operator[](key_type&& k);
1950b57cec5SDimitry Andric
1960b57cec5SDimitry Andric    mapped_type&       at(const key_type& k);
1970b57cec5SDimitry Andric    const mapped_type& at(const key_type& k) const;
1980b57cec5SDimitry Andric
1990b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
2000b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
2010b57cec5SDimitry Andric
2020b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
2030b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
2040b57cec5SDimitry Andric
2050b57cec5SDimitry Andric    local_iterator       begin(size_type n);
2060b57cec5SDimitry Andric    local_iterator       end(size_type n);
2070b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
2080b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
2090b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
2100b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
2110b57cec5SDimitry Andric
2120b57cec5SDimitry Andric    float load_factor() const noexcept;
2130b57cec5SDimitry Andric    float max_load_factor() const noexcept;
2140b57cec5SDimitry Andric    void max_load_factor(float z);
2150b57cec5SDimitry Andric    void rehash(size_type n);
2160b57cec5SDimitry Andric    void reserve(size_type n);
2170b57cec5SDimitry Andric};
2180b57cec5SDimitry Andric
219349cc55cSDimitry Andrictemplate<class InputIterator,
220349cc55cSDimitry Andric    class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>,
221349cc55cSDimitry Andric    class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
222349cc55cSDimitry Andricunordered_map(InputIterator, InputIterator, typename see below::size_type = see below,
223349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
224349cc55cSDimitry Andric  -> unordered_map<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred,
225349cc55cSDimitry Andric    Allocator>; // C++17
226349cc55cSDimitry Andric
227349cc55cSDimitry Andrictemplate<class Key, class T, class Hash = hash<Key>,
228349cc55cSDimitry Andric    class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>
229349cc55cSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type = see below,
230349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
231349cc55cSDimitry Andric  -> unordered_map<Key, T, Hash, Pred, Allocator>; // C++17
232349cc55cSDimitry Andric
233349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
234349cc55cSDimitry Andricunordered_map(InputIterator, InputIterator, typename see below::size_type, Allocator)
235349cc55cSDimitry Andric  -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
236349cc55cSDimitry Andric        hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
237349cc55cSDimitry Andric
238349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
239349cc55cSDimitry Andricunordered_map(InputIterator, InputIterator, Allocator)
240349cc55cSDimitry Andric  -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
241349cc55cSDimitry Andric        hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
242349cc55cSDimitry Andric
243349cc55cSDimitry Andrictemplate<class InputIterator, class Hash, class Allocator>
244349cc55cSDimitry Andricunordered_map(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator)
245349cc55cSDimitry Andric  -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash,
246349cc55cSDimitry Andric          equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
247349cc55cSDimitry Andric
248349cc55cSDimitry Andrictemplate<class Key, class T, typename Allocator>
249349cc55cSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator)
250349cc55cSDimitry Andric  -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
251349cc55cSDimitry Andric
252349cc55cSDimitry Andrictemplate<class Key, class T, typename Allocator>
253349cc55cSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, Allocator)
254349cc55cSDimitry Andric  -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
255349cc55cSDimitry Andric
256349cc55cSDimitry Andrictemplate<class Key, class T, class Hash, class Allocator>
257349cc55cSDimitry Andricunordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash, Allocator)
258349cc55cSDimitry Andric  -> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>; // C++17
259349cc55cSDimitry Andric
2600b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
2610b57cec5SDimitry Andric    void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
2620b57cec5SDimitry Andric              unordered_map<Key, T, Hash, Pred, Alloc>& y)
2630b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
2640b57cec5SDimitry Andric
2650b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
2660b57cec5SDimitry Andric    bool
2670b57cec5SDimitry Andric    operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
2680b57cec5SDimitry Andric               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
2690b57cec5SDimitry Andric
2700b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
2710b57cec5SDimitry Andric    bool
2720b57cec5SDimitry Andric    operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
2730b57cec5SDimitry Andric               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
2740b57cec5SDimitry Andric
2750b57cec5SDimitry Andrictemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
2760b57cec5SDimitry Andric          class Alloc = allocator<pair<const Key, T>>>
2770b57cec5SDimitry Andricclass unordered_multimap
2780b57cec5SDimitry Andric{
2790b57cec5SDimitry Andricpublic:
2800b57cec5SDimitry Andric    // types
2810b57cec5SDimitry Andric    typedef Key                                                        key_type;
2820b57cec5SDimitry Andric    typedef T                                                          mapped_type;
2830b57cec5SDimitry Andric    typedef Hash                                                       hasher;
2840b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
2850b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
2860b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>                          value_type;
2870b57cec5SDimitry Andric    typedef value_type&                                                reference;
2880b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
2890b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
2900b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
2910b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
2920b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
2930b57cec5SDimitry Andric
2940b57cec5SDimitry Andric    typedef /unspecified/ iterator;
2950b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
2960b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
2970b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
2980b57cec5SDimitry Andric
2990b57cec5SDimitry Andric    typedef unspecified node_type;    // C++17
3000b57cec5SDimitry Andric
3010b57cec5SDimitry Andric    unordered_multimap()
3020b57cec5SDimitry Andric        noexcept(
3030b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
3040b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
3050b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
3060b57cec5SDimitry Andric    explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
3070b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
3080b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
3090b57cec5SDimitry Andric    template <class InputIterator>
3100b57cec5SDimitry Andric        unordered_multimap(InputIterator f, InputIterator l,
3110b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
3120b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
3130b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
3140b57cec5SDimitry Andric    explicit unordered_multimap(const allocator_type&);
3150b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap&);
3160b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap&, const Allocator&);
3170b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&&)
3180b57cec5SDimitry Andric        noexcept(
3190b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
3200b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
3210b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
3220b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&&, const Allocator&);
3230b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type>, size_type n = 0,
3240b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
3250b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
3260b57cec5SDimitry Andric    unordered_multimap(size_type n, const allocator_type& a)
3270b57cec5SDimitry Andric      : unordered_multimap(n, hasher(), key_equal(), a) {}  // C++14
3280b57cec5SDimitry Andric    unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
3290b57cec5SDimitry Andric      : unordered_multimap(n, hf, key_equal(), a) {}  // C++14
3300b57cec5SDimitry Andric    template <class InputIterator>
3310b57cec5SDimitry Andric      unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
3320b57cec5SDimitry Andric      : unordered_multimap(f, l, n, hasher(), key_equal(), a) {}  // C++14
3330b57cec5SDimitry Andric    template <class InputIterator>
3340b57cec5SDimitry Andric      unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
3350b57cec5SDimitry Andric        const allocator_type& a)
3360b57cec5SDimitry Andric      : unordered_multimap(f, l, n, hf, key_equal(), a) {}  // C++14
3370b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
3380b57cec5SDimitry Andric      : unordered_multimap(il, n, hasher(), key_equal(), a) {}  // C++14
3390b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
3400b57cec5SDimitry Andric      const allocator_type& a)
3410b57cec5SDimitry Andric      : unordered_multimap(il, n, hf, key_equal(), a) {}  // C++14
3420b57cec5SDimitry Andric    ~unordered_multimap();
3430b57cec5SDimitry Andric    unordered_multimap& operator=(const unordered_multimap&);
3440b57cec5SDimitry Andric    unordered_multimap& operator=(unordered_multimap&&)
3450b57cec5SDimitry Andric        noexcept(
3460b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
3470b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
3480b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
3490b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
3500b57cec5SDimitry Andric    unordered_multimap& operator=(initializer_list<value_type>);
3510b57cec5SDimitry Andric
3520b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
3530b57cec5SDimitry Andric
3540b57cec5SDimitry Andric    bool      empty() const noexcept;
3550b57cec5SDimitry Andric    size_type size() const noexcept;
3560b57cec5SDimitry Andric    size_type max_size() const noexcept;
3570b57cec5SDimitry Andric
3580b57cec5SDimitry Andric    iterator       begin() noexcept;
3590b57cec5SDimitry Andric    iterator       end() noexcept;
3600b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
3610b57cec5SDimitry Andric    const_iterator end()    const noexcept;
3620b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
3630b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
3640b57cec5SDimitry Andric
3650b57cec5SDimitry Andric    template <class... Args>
3660b57cec5SDimitry Andric        iterator emplace(Args&&... args);
3670b57cec5SDimitry Andric    template <class... Args>
3680b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
3690b57cec5SDimitry Andric    iterator insert(const value_type& obj);
3700b57cec5SDimitry Andric    template <class P>
3710b57cec5SDimitry Andric        iterator insert(P&& obj);
3720b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
3730b57cec5SDimitry Andric    template <class P>
3740b57cec5SDimitry Andric        iterator insert(const_iterator hint, P&& obj);
3750b57cec5SDimitry Andric    template <class InputIterator>
3760b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
3770b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
3780b57cec5SDimitry Andric
3790b57cec5SDimitry Andric    node_type extract(const_iterator position);                // C++17
3800b57cec5SDimitry Andric    node_type extract(const key_type& x);                      // C++17
3810b57cec5SDimitry Andric    iterator insert(node_type&& nh);                           // C++17
3820b57cec5SDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);      // C++17
3830b57cec5SDimitry Andric
3840b57cec5SDimitry Andric    iterator erase(const_iterator position);
3850b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
3860b57cec5SDimitry Andric    size_type erase(const key_type& k);
3870b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
3880b57cec5SDimitry Andric    void clear() noexcept;
3890b57cec5SDimitry Andric
3900b57cec5SDimitry Andric    template<class H2, class P2>
3910b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source);    // C++17
3920b57cec5SDimitry Andric    template<class H2, class P2>
3930b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source);   // C++17
3940b57cec5SDimitry Andric    template<class H2, class P2>
3950b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>& source);         // C++17
3960b57cec5SDimitry Andric    template<class H2, class P2>
3970b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>&& source);        // C++17
3980b57cec5SDimitry Andric
3990b57cec5SDimitry Andric    void swap(unordered_multimap&)
4000b57cec5SDimitry Andric        noexcept(
4010b57cec5SDimitry Andric            (!allocator_type::propagate_on_container_swap::value ||
4020b57cec5SDimitry Andric             __is_nothrow_swappable<allocator_type>::value) &&
4030b57cec5SDimitry Andric            __is_nothrow_swappable<hasher>::value &&
4040b57cec5SDimitry Andric            __is_nothrow_swappable<key_equal>::value);
4050b57cec5SDimitry Andric
4060b57cec5SDimitry Andric    hasher hash_function() const;
4070b57cec5SDimitry Andric    key_equal key_eq() const;
4080b57cec5SDimitry Andric
4090b57cec5SDimitry Andric    iterator       find(const key_type& k);
4100b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
411e8d8bef9SDimitry Andric    template<typename K>
412e8d8bef9SDimitry Andric        iterator find(const K& x);              // C++20
413e8d8bef9SDimitry Andric    template<typename K>
414e8d8bef9SDimitry Andric        const_iterator find(const K& x) const;  // C++20
4150b57cec5SDimitry Andric    size_type count(const key_type& k) const;
416e8d8bef9SDimitry Andric    template<typename K>
417e8d8bef9SDimitry Andric        size_type count(const K& k) const; // C++20
4180b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
419e8d8bef9SDimitry Andric    template<typename K>
420e8d8bef9SDimitry Andric        bool contains(const K& k) const; // C++20
4210b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
4220b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
423e8d8bef9SDimitry Andric    template<typename K>
424e8d8bef9SDimitry Andric        pair<iterator, iterator>             equal_range(const K& k); // C++20
425e8d8bef9SDimitry Andric    template<typename K>
426e8d8bef9SDimitry Andric        pair<const_iterator, const_iterator> equal_range(const K& k) const; // C++20
4270b57cec5SDimitry Andric
4280b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
4290b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
4300b57cec5SDimitry Andric
4310b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
4320b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
4330b57cec5SDimitry Andric
4340b57cec5SDimitry Andric    local_iterator       begin(size_type n);
4350b57cec5SDimitry Andric    local_iterator       end(size_type n);
4360b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
4370b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
4380b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
4390b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
4400b57cec5SDimitry Andric
4410b57cec5SDimitry Andric    float load_factor() const noexcept;
4420b57cec5SDimitry Andric    float max_load_factor() const noexcept;
4430b57cec5SDimitry Andric    void max_load_factor(float z);
4440b57cec5SDimitry Andric    void rehash(size_type n);
4450b57cec5SDimitry Andric    void reserve(size_type n);
4460b57cec5SDimitry Andric};
4470b57cec5SDimitry Andric
448349cc55cSDimitry Andrictemplate<class InputIterator,
449349cc55cSDimitry Andric    class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>,
450349cc55cSDimitry Andric    class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
451349cc55cSDimitry Andricunordered_multimap(InputIterator, InputIterator, typename see below::size_type = see below,
452349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
453349cc55cSDimitry Andric  -> unordered_multimap<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred,
454349cc55cSDimitry Andric    Allocator>; // C++17
455349cc55cSDimitry Andric
456349cc55cSDimitry Andrictemplate<class Key, class T, class Hash = hash<Key>,
457349cc55cSDimitry Andric    class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>
458349cc55cSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type = see below,
459349cc55cSDimitry Andric    Hash = Hash(), Pred = Pred(), Allocator = Allocator())
460349cc55cSDimitry Andric  -> unordered_multimap<Key, T, Hash, Pred, Allocator>; // C++17
461349cc55cSDimitry Andric
462349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
463349cc55cSDimitry Andricunordered_multimap(InputIterator, InputIterator, typename see below::size_type, Allocator)
464349cc55cSDimitry Andric  -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
465349cc55cSDimitry Andric        hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
466349cc55cSDimitry Andric
467349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
468349cc55cSDimitry Andricunordered_multimap(InputIterator, InputIterator, Allocator)
469349cc55cSDimitry Andric  -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
470349cc55cSDimitry Andric        hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
471349cc55cSDimitry Andric
472349cc55cSDimitry Andrictemplate<class InputIterator, class Hash, class Allocator>
473349cc55cSDimitry Andricunordered_multimap(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator)
474349cc55cSDimitry Andric  -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash,
475349cc55cSDimitry Andric          equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17
476349cc55cSDimitry Andric
477349cc55cSDimitry Andrictemplate<class Key, class T, typename Allocator>
478349cc55cSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator)
479349cc55cSDimitry Andric  -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
480349cc55cSDimitry Andric
481349cc55cSDimitry Andrictemplate<class Key, class T, typename Allocator>
482349cc55cSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, Allocator)
483349cc55cSDimitry Andric  -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17
484349cc55cSDimitry Andric
485349cc55cSDimitry Andrictemplate<class Key, class T, class Hash, class Allocator>
486349cc55cSDimitry Andricunordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash,
487349cc55cSDimitry Andric    Allocator)
488349cc55cSDimitry Andric  -> unordered_multimap<Key, T, Hash, equal_to<Key>, Allocator>; // C++17
489349cc55cSDimitry Andric
4900b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
4910b57cec5SDimitry Andric    void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
4920b57cec5SDimitry Andric              unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
4930b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
4940b57cec5SDimitry Andric
4950b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
4965ffd83dbSDimitry Andric    typename unordered_map<K, T, H, P, A>::size_type
4975ffd83dbSDimitry Andric    erase_if(unordered_map<K, T, H, P, A>& c, Predicate pred);       // C++20
4980b57cec5SDimitry Andric
4990b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
5005ffd83dbSDimitry Andric    typename unordered_multimap<K, T, H, P, A>::size_type
5015ffd83dbSDimitry Andric    erase_if(unordered_multimap<K, T, H, P, A>& c, Predicate pred);  // C++20
5020b57cec5SDimitry Andric
5030b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
5040b57cec5SDimitry Andric    bool
5050b57cec5SDimitry Andric    operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
5060b57cec5SDimitry Andric               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
5070b57cec5SDimitry Andric
5080b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
5090b57cec5SDimitry Andric    bool
5100b57cec5SDimitry Andric    operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
5110b57cec5SDimitry Andric               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
5120b57cec5SDimitry Andric
5130b57cec5SDimitry Andric}  // std
5140b57cec5SDimitry Andric
5150b57cec5SDimitry Andric*/
5160b57cec5SDimitry Andric
51781ad6265SDimitry Andric#include <__algorithm/is_permutation.h>
51881ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler
5190b57cec5SDimitry Andric#include <__config>
520fe6060f1SDimitry Andric#include <__debug>
521fe6060f1SDimitry Andric#include <__functional/is_transparent.h>
52281ad6265SDimitry Andric#include <__functional/operations.h>
5230b57cec5SDimitry Andric#include <__hash_table>
52481ad6265SDimitry Andric#include <__iterator/distance.h>
52581ad6265SDimitry Andric#include <__iterator/erase_if_container.h>
52604eeddc0SDimitry Andric#include <__iterator/iterator_traits.h>
52704eeddc0SDimitry Andric#include <__memory/addressof.h>
5280b57cec5SDimitry Andric#include <__node_handle>
529fe6060f1SDimitry Andric#include <__utility/forward.h>
5300b57cec5SDimitry Andric#include <stdexcept>
5310b57cec5SDimitry Andric#include <tuple>
5320b57cec5SDimitry Andric#include <version>
5330b57cec5SDimitry Andric
53481ad6265SDimitry Andric#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
53581ad6265SDimitry Andric#  include <algorithm>
53681ad6265SDimitry Andric#  include <bit>
53781ad6265SDimitry Andric#  include <iterator>
53881ad6265SDimitry Andric#endif
53981ad6265SDimitry Andric
54081ad6265SDimitry Andric// standard-mandated includes
54181ad6265SDimitry Andric
54281ad6265SDimitry Andric// [iterator.range]
54381ad6265SDimitry Andric#include <__iterator/access.h>
54481ad6265SDimitry Andric#include <__iterator/data.h>
54581ad6265SDimitry Andric#include <__iterator/empty.h>
54681ad6265SDimitry Andric#include <__iterator/reverse_access.h>
54781ad6265SDimitry Andric#include <__iterator/size.h>
54881ad6265SDimitry Andric
54981ad6265SDimitry Andric// [unord.map.syn]
55081ad6265SDimitry Andric#include <compare>
55181ad6265SDimitry Andric#include <initializer_list>
55281ad6265SDimitry Andric
5530b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5540b57cec5SDimitry Andric#  pragma GCC system_header
5550b57cec5SDimitry Andric#endif
5560b57cec5SDimitry Andric
5570b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
5580b57cec5SDimitry Andric
559e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred,
5600b57cec5SDimitry Andric          bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
5610b57cec5SDimitry Andricclass __unordered_map_hasher
5620b57cec5SDimitry Andric    : private _Hash
5630b57cec5SDimitry Andric{
5640b57cec5SDimitry Andricpublic:
5650b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5660b57cec5SDimitry Andric    __unordered_map_hasher()
5670b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
5680b57cec5SDimitry Andric        : _Hash() {}
5690b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5700b57cec5SDimitry Andric    __unordered_map_hasher(const _Hash& __h)
5710b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
5720b57cec5SDimitry Andric        : _Hash(__h) {}
5730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5740b57cec5SDimitry Andric    const _Hash& hash_function() const _NOEXCEPT {return *this;}
5750b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5760b57cec5SDimitry Andric    size_t operator()(const _Cp& __x) const
5770b57cec5SDimitry Andric        {return static_cast<const _Hash&>(*this)(__x.__get_value().first);}
5780b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5790b57cec5SDimitry Andric    size_t operator()(const _Key& __x) const
5800b57cec5SDimitry Andric        {return static_cast<const _Hash&>(*this)(__x);}
581e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
582349cc55cSDimitry Andric    template <typename _K2>
583e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
584e8d8bef9SDimitry Andric    size_t operator()(const _K2& __x) const
585e8d8bef9SDimitry Andric        {return static_cast<const _Hash&>(*this)(__x);}
586e8d8bef9SDimitry Andric#endif
587349cc55cSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5880b57cec5SDimitry Andric    void swap(__unordered_map_hasher& __y)
5890b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
5900b57cec5SDimitry Andric    {
5910b57cec5SDimitry Andric        using _VSTD::swap;
5920b57cec5SDimitry Andric        swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y));
5930b57cec5SDimitry Andric    }
5940b57cec5SDimitry Andric};
5950b57cec5SDimitry Andric
596e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred>
597e8d8bef9SDimitry Andricclass __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, false>
5980b57cec5SDimitry Andric{
5990b57cec5SDimitry Andric    _Hash __hash_;
6000b57cec5SDimitry Andricpublic:
6010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6020b57cec5SDimitry Andric    __unordered_map_hasher()
6030b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
6040b57cec5SDimitry Andric        : __hash_() {}
6050b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6060b57cec5SDimitry Andric    __unordered_map_hasher(const _Hash& __h)
6070b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
6080b57cec5SDimitry Andric        : __hash_(__h) {}
6090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6100b57cec5SDimitry Andric    const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
6110b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6120b57cec5SDimitry Andric    size_t operator()(const _Cp& __x) const
6130b57cec5SDimitry Andric        {return __hash_(__x.__get_value().first);}
6140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6150b57cec5SDimitry Andric    size_t operator()(const _Key& __x) const
6160b57cec5SDimitry Andric        {return __hash_(__x);}
617e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
618349cc55cSDimitry Andric    template <typename _K2>
619e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
620e8d8bef9SDimitry Andric    size_t operator()(const _K2& __x) const
621e8d8bef9SDimitry Andric        {return __hash_(__x);}
622e8d8bef9SDimitry Andric#endif
623349cc55cSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6240b57cec5SDimitry Andric    void swap(__unordered_map_hasher& __y)
6250b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
6260b57cec5SDimitry Andric    {
6270b57cec5SDimitry Andric        using _VSTD::swap;
6280b57cec5SDimitry Andric        swap(__hash_, __y.__hash_);
6290b57cec5SDimitry Andric    }
6300b57cec5SDimitry Andric};
6310b57cec5SDimitry Andric
632e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, class _Pred, bool __b>
6330b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
6340b57cec5SDimitry Andricvoid
635e8d8bef9SDimitry Andricswap(__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __x,
636e8d8bef9SDimitry Andric     __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y)
6370b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
6380b57cec5SDimitry Andric{
6390b57cec5SDimitry Andric    __x.swap(__y);
6400b57cec5SDimitry Andric}
6410b57cec5SDimitry Andric
642e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash,
6430b57cec5SDimitry Andric          bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
6440b57cec5SDimitry Andricclass __unordered_map_equal
6450b57cec5SDimitry Andric    : private _Pred
6460b57cec5SDimitry Andric{
6470b57cec5SDimitry Andricpublic:
6480b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6490b57cec5SDimitry Andric    __unordered_map_equal()
6500b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
6510b57cec5SDimitry Andric        : _Pred() {}
6520b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6530b57cec5SDimitry Andric    __unordered_map_equal(const _Pred& __p)
6540b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
6550b57cec5SDimitry Andric        : _Pred(__p) {}
6560b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6570b57cec5SDimitry Andric    const _Pred& key_eq() const _NOEXCEPT {return *this;}
6580b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6590b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Cp& __y) const
6600b57cec5SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first);}
6610b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6620b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Key& __y) const
6630b57cec5SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
6640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6650b57cec5SDimitry Andric    bool operator()(const _Key& __x, const _Cp& __y) const
6660b57cec5SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
667e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
668349cc55cSDimitry Andric    template <typename _K2>
669e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
670e8d8bef9SDimitry Andric    bool operator()(const _Cp& __x, const _K2& __y) const
671e8d8bef9SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
672349cc55cSDimitry Andric    template <typename _K2>
673e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
674e8d8bef9SDimitry Andric    bool operator()(const _K2& __x, const _Cp& __y) const
675e8d8bef9SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
676349cc55cSDimitry Andric    template <typename _K2>
677e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
678e8d8bef9SDimitry Andric    bool operator()(const _Key& __x, const _K2& __y) const
679e8d8bef9SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x, __y);}
680349cc55cSDimitry Andric    template <typename _K2>
681e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
682e8d8bef9SDimitry Andric    bool operator()(const _K2& __x, const _Key& __y) const
683e8d8bef9SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x, __y);}
684e8d8bef9SDimitry Andric#endif
685349cc55cSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6860b57cec5SDimitry Andric    void swap(__unordered_map_equal& __y)
6870b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
6880b57cec5SDimitry Andric    {
6890b57cec5SDimitry Andric        using _VSTD::swap;
6900b57cec5SDimitry Andric        swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y));
6910b57cec5SDimitry Andric    }
6920b57cec5SDimitry Andric};
6930b57cec5SDimitry Andric
694e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash>
695e8d8bef9SDimitry Andricclass __unordered_map_equal<_Key, _Cp, _Pred, _Hash, false>
6960b57cec5SDimitry Andric{
6970b57cec5SDimitry Andric    _Pred __pred_;
6980b57cec5SDimitry Andricpublic:
6990b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7000b57cec5SDimitry Andric    __unordered_map_equal()
7010b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
7020b57cec5SDimitry Andric        : __pred_() {}
7030b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7040b57cec5SDimitry Andric    __unordered_map_equal(const _Pred& __p)
7050b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
7060b57cec5SDimitry Andric        : __pred_(__p) {}
7070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7080b57cec5SDimitry Andric    const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
7090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7100b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Cp& __y) const
7110b57cec5SDimitry Andric        {return __pred_(__x.__get_value().first, __y.__get_value().first);}
7120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7130b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Key& __y) const
7140b57cec5SDimitry Andric        {return __pred_(__x.__get_value().first, __y);}
7150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7160b57cec5SDimitry Andric    bool operator()(const _Key& __x, const _Cp& __y) const
7170b57cec5SDimitry Andric        {return __pred_(__x, __y.__get_value().first);}
718e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
719349cc55cSDimitry Andric    template <typename _K2>
720e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
721e8d8bef9SDimitry Andric    bool operator()(const _Cp& __x, const _K2& __y) const
722e8d8bef9SDimitry Andric        {return __pred_(__x.__get_value().first, __y);}
723349cc55cSDimitry Andric    template <typename _K2>
724e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
725e8d8bef9SDimitry Andric    bool operator()(const _K2& __x, const _Cp& __y) const
726e8d8bef9SDimitry Andric        {return __pred_(__x, __y.__get_value().first);}
727349cc55cSDimitry Andric    template <typename _K2>
728e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
729e8d8bef9SDimitry Andric    bool operator()(const _Key& __x, const _K2& __y) const
730e8d8bef9SDimitry Andric        {return __pred_(__x, __y);}
731349cc55cSDimitry Andric    template <typename _K2>
732e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
733e8d8bef9SDimitry Andric    bool operator()(const _K2& __x, const _Key& __y) const
734e8d8bef9SDimitry Andric        {return __pred_(__x, __y);}
735e8d8bef9SDimitry Andric#endif
736349cc55cSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7370b57cec5SDimitry Andric    void swap(__unordered_map_equal& __y)
7380b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
7390b57cec5SDimitry Andric    {
7400b57cec5SDimitry Andric        using _VSTD::swap;
7410b57cec5SDimitry Andric        swap(__pred_, __y.__pred_);
7420b57cec5SDimitry Andric    }
7430b57cec5SDimitry Andric};
7440b57cec5SDimitry Andric
745e8d8bef9SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, class _Hash, bool __b>
7460b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
7470b57cec5SDimitry Andricvoid
748e8d8bef9SDimitry Andricswap(__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __x,
749e8d8bef9SDimitry Andric     __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b>& __y)
7500b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
7510b57cec5SDimitry Andric{
7520b57cec5SDimitry Andric    __x.swap(__y);
7530b57cec5SDimitry Andric}
7540b57cec5SDimitry Andric
7550b57cec5SDimitry Andrictemplate <class _Alloc>
7560b57cec5SDimitry Andricclass __hash_map_node_destructor
7570b57cec5SDimitry Andric{
7580b57cec5SDimitry Andric    typedef _Alloc                              allocator_type;
7590b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>    __alloc_traits;
7600b57cec5SDimitry Andric
7610b57cec5SDimitry Andricpublic:
7620b57cec5SDimitry Andric
7630b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer       pointer;
7640b57cec5SDimitry Andricprivate:
7650b57cec5SDimitry Andric
7660b57cec5SDimitry Andric    allocator_type& __na_;
7670b57cec5SDimitry Andric
7680b57cec5SDimitry Andric    __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
7690b57cec5SDimitry Andric
7700b57cec5SDimitry Andricpublic:
7710b57cec5SDimitry Andric    bool __first_constructed;
7720b57cec5SDimitry Andric    bool __second_constructed;
7730b57cec5SDimitry Andric
7740b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7750b57cec5SDimitry Andric    explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
7760b57cec5SDimitry Andric        : __na_(__na),
7770b57cec5SDimitry Andric          __first_constructed(false),
7780b57cec5SDimitry Andric          __second_constructed(false)
7790b57cec5SDimitry Andric        {}
7800b57cec5SDimitry Andric
7810b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7820b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7830b57cec5SDimitry Andric    __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
7840b57cec5SDimitry Andric        _NOEXCEPT
7850b57cec5SDimitry Andric        : __na_(__x.__na_),
7860b57cec5SDimitry Andric          __first_constructed(__x.__value_constructed),
7870b57cec5SDimitry Andric          __second_constructed(__x.__value_constructed)
7880b57cec5SDimitry Andric        {
7890b57cec5SDimitry Andric            __x.__value_constructed = false;
7900b57cec5SDimitry Andric        }
7910b57cec5SDimitry Andric#else  // _LIBCPP_CXX03_LANG
7920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7930b57cec5SDimitry Andric    __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
7940b57cec5SDimitry Andric        : __na_(__x.__na_),
7950b57cec5SDimitry Andric          __first_constructed(__x.__value_constructed),
7960b57cec5SDimitry Andric          __second_constructed(__x.__value_constructed)
7970b57cec5SDimitry Andric        {
7980b57cec5SDimitry Andric            const_cast<bool&>(__x.__value_constructed) = false;
7990b57cec5SDimitry Andric        }
8000b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
8010b57cec5SDimitry Andric
8020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8030b57cec5SDimitry Andric    void operator()(pointer __p) _NOEXCEPT
8040b57cec5SDimitry Andric    {
8050b57cec5SDimitry Andric        if (__second_constructed)
8060b57cec5SDimitry Andric            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
8070b57cec5SDimitry Andric        if (__first_constructed)
8080b57cec5SDimitry Andric            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
8090b57cec5SDimitry Andric        if (__p)
8100b57cec5SDimitry Andric            __alloc_traits::deallocate(__na_, __p, 1);
8110b57cec5SDimitry Andric    }
8120b57cec5SDimitry Andric};
8130b57cec5SDimitry Andric
8140b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8150b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
816fe6060f1SDimitry Andricstruct _LIBCPP_STANDALONE_DEBUG __hash_value_type
8170b57cec5SDimitry Andric{
8180b57cec5SDimitry Andric    typedef _Key                                     key_type;
8190b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
8200b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
8210b57cec5SDimitry Andric    typedef pair<key_type&, mapped_type&>            __nc_ref_pair_type;
8220b57cec5SDimitry Andric    typedef pair<key_type&&, mapped_type&&>          __nc_rref_pair_type;
8230b57cec5SDimitry Andric
8240b57cec5SDimitry Andricprivate:
8250b57cec5SDimitry Andric    value_type __cc;
8260b57cec5SDimitry Andric
8270b57cec5SDimitry Andricpublic:
8280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8290b57cec5SDimitry Andric    value_type& __get_value()
8300b57cec5SDimitry Andric    {
8310b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
8320b57cec5SDimitry Andric        return *_VSTD::launder(_VSTD::addressof(__cc));
8330b57cec5SDimitry Andric#else
8340b57cec5SDimitry Andric        return __cc;
8350b57cec5SDimitry Andric#endif
8360b57cec5SDimitry Andric    }
8370b57cec5SDimitry Andric
8380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8390b57cec5SDimitry Andric    const value_type& __get_value() const
8400b57cec5SDimitry Andric    {
8410b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
8420b57cec5SDimitry Andric        return *_VSTD::launder(_VSTD::addressof(__cc));
8430b57cec5SDimitry Andric#else
8440b57cec5SDimitry Andric        return __cc;
8450b57cec5SDimitry Andric#endif
8460b57cec5SDimitry Andric    }
8470b57cec5SDimitry Andric
8480b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8490b57cec5SDimitry Andric    __nc_ref_pair_type __ref()
8500b57cec5SDimitry Andric    {
8510b57cec5SDimitry Andric        value_type& __v = __get_value();
8520b57cec5SDimitry Andric        return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
8530b57cec5SDimitry Andric    }
8540b57cec5SDimitry Andric
8550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8560b57cec5SDimitry Andric    __nc_rref_pair_type __move()
8570b57cec5SDimitry Andric    {
8580b57cec5SDimitry Andric        value_type& __v = __get_value();
8590b57cec5SDimitry Andric        return __nc_rref_pair_type(
8600b57cec5SDimitry Andric            _VSTD::move(const_cast<key_type&>(__v.first)),
8610b57cec5SDimitry Andric            _VSTD::move(__v.second));
8620b57cec5SDimitry Andric    }
8630b57cec5SDimitry Andric
8640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8650b57cec5SDimitry Andric    __hash_value_type& operator=(const __hash_value_type& __v)
8660b57cec5SDimitry Andric    {
8670b57cec5SDimitry Andric        __ref() = __v.__get_value();
8680b57cec5SDimitry Andric        return *this;
8690b57cec5SDimitry Andric    }
8700b57cec5SDimitry Andric
8710b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8720b57cec5SDimitry Andric    __hash_value_type& operator=(__hash_value_type&& __v)
8730b57cec5SDimitry Andric    {
8740b57cec5SDimitry Andric        __ref() = __v.__move();
8750b57cec5SDimitry Andric        return *this;
8760b57cec5SDimitry Andric    }
8770b57cec5SDimitry Andric
8780b57cec5SDimitry Andric    template <class _ValueTp,
879*753f127fSDimitry Andric              class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value>
8800b57cec5SDimitry Andric             >
8810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8820b57cec5SDimitry Andric    __hash_value_type& operator=(_ValueTp&& __v)
8830b57cec5SDimitry Andric    {
8840b57cec5SDimitry Andric        __ref() = _VSTD::forward<_ValueTp>(__v);
8850b57cec5SDimitry Andric        return *this;
8860b57cec5SDimitry Andric    }
8870b57cec5SDimitry Andric
8880b57cec5SDimitry Andricprivate:
8890b57cec5SDimitry Andric    __hash_value_type(const __hash_value_type& __v) = delete;
8900b57cec5SDimitry Andric    __hash_value_type(__hash_value_type&& __v) = delete;
8910b57cec5SDimitry Andric    template <class ..._Args>
8920b57cec5SDimitry Andric    explicit __hash_value_type(_Args&& ...__args) = delete;
8930b57cec5SDimitry Andric
8940b57cec5SDimitry Andric    ~__hash_value_type() = delete;
8950b57cec5SDimitry Andric};
8960b57cec5SDimitry Andric
8970b57cec5SDimitry Andric#else
8980b57cec5SDimitry Andric
8990b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
9000b57cec5SDimitry Andricstruct __hash_value_type
9010b57cec5SDimitry Andric{
9020b57cec5SDimitry Andric    typedef _Key                                     key_type;
9030b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
9040b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
9050b57cec5SDimitry Andric
9060b57cec5SDimitry Andricprivate:
9070b57cec5SDimitry Andric    value_type __cc;
9080b57cec5SDimitry Andric
9090b57cec5SDimitry Andricpublic:
9100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9110b57cec5SDimitry Andric    value_type& __get_value() { return __cc; }
9120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9130b57cec5SDimitry Andric    const value_type& __get_value() const { return __cc; }
9140b57cec5SDimitry Andric
9150b57cec5SDimitry Andricprivate:
9160b57cec5SDimitry Andric   ~__hash_value_type();
9170b57cec5SDimitry Andric};
9180b57cec5SDimitry Andric
9190b57cec5SDimitry Andric#endif
9200b57cec5SDimitry Andric
9210b57cec5SDimitry Andrictemplate <class _HashIterator>
9220b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_iterator
9230b57cec5SDimitry Andric{
9240b57cec5SDimitry Andric    _HashIterator __i_;
9250b57cec5SDimitry Andric
9260b57cec5SDimitry Andric    typedef  __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
9270b57cec5SDimitry Andric
9280b57cec5SDimitry Andricpublic:
9290b57cec5SDimitry Andric    typedef forward_iterator_tag                                 iterator_category;
9300b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type                value_type;
9310b57cec5SDimitry Andric    typedef typename _NodeTypes::difference_type                 difference_type;
9320b57cec5SDimitry Andric    typedef value_type&                                          reference;
9330b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type_pointer       pointer;
9340b57cec5SDimitry Andric
9350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9360b57cec5SDimitry Andric    __hash_map_iterator() _NOEXCEPT {}
9370b57cec5SDimitry Andric
9380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9390b57cec5SDimitry Andric    __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
9400b57cec5SDimitry Andric
9410b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9420b57cec5SDimitry Andric    reference operator*() const {return __i_->__get_value();}
9430b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9440b57cec5SDimitry Andric    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
9450b57cec5SDimitry Andric
9460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9470b57cec5SDimitry Andric    __hash_map_iterator& operator++() {++__i_; return *this;}
9480b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9490b57cec5SDimitry Andric    __hash_map_iterator operator++(int)
9500b57cec5SDimitry Andric    {
9510b57cec5SDimitry Andric        __hash_map_iterator __t(*this);
9520b57cec5SDimitry Andric        ++(*this);
9530b57cec5SDimitry Andric        return __t;
9540b57cec5SDimitry Andric    }
9550b57cec5SDimitry Andric
9560b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
9570b57cec5SDimitry Andric        bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
9580b57cec5SDimitry Andric        {return __x.__i_ == __y.__i_;}
9590b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
9600b57cec5SDimitry Andric        bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
9610b57cec5SDimitry Andric        {return __x.__i_ != __y.__i_;}
9620b57cec5SDimitry Andric
9630b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
9640b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
9650b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
9660b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
9670b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
9680b57cec5SDimitry Andric};
9690b57cec5SDimitry Andric
9700b57cec5SDimitry Andrictemplate <class _HashIterator>
9710b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator
9720b57cec5SDimitry Andric{
9730b57cec5SDimitry Andric    _HashIterator __i_;
9740b57cec5SDimitry Andric
9750b57cec5SDimitry Andric    typedef  __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
9760b57cec5SDimitry Andric
9770b57cec5SDimitry Andricpublic:
9780b57cec5SDimitry Andric    typedef forward_iterator_tag                                 iterator_category;
9790b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type                value_type;
9800b57cec5SDimitry Andric    typedef typename _NodeTypes::difference_type                 difference_type;
9810b57cec5SDimitry Andric    typedef const value_type&                                    reference;
9820b57cec5SDimitry Andric    typedef typename _NodeTypes::__const_map_value_type_pointer  pointer;
9830b57cec5SDimitry Andric
9840b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9850b57cec5SDimitry Andric    __hash_map_const_iterator() _NOEXCEPT {}
9860b57cec5SDimitry Andric
9870b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9880b57cec5SDimitry Andric    __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
9890b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9900b57cec5SDimitry Andric    __hash_map_const_iterator(
9910b57cec5SDimitry Andric            __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
9920b57cec5SDimitry Andric                 _NOEXCEPT
9930b57cec5SDimitry Andric                : __i_(__i.__i_) {}
9940b57cec5SDimitry Andric
9950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9960b57cec5SDimitry Andric    reference operator*() const {return __i_->__get_value();}
9970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
9980b57cec5SDimitry Andric    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
9990b57cec5SDimitry Andric
10000b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10010b57cec5SDimitry Andric    __hash_map_const_iterator& operator++() {++__i_; return *this;}
10020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10030b57cec5SDimitry Andric    __hash_map_const_iterator operator++(int)
10040b57cec5SDimitry Andric    {
10050b57cec5SDimitry Andric        __hash_map_const_iterator __t(*this);
10060b57cec5SDimitry Andric        ++(*this);
10070b57cec5SDimitry Andric        return __t;
10080b57cec5SDimitry Andric    }
10090b57cec5SDimitry Andric
10100b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
10110b57cec5SDimitry Andric        bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
10120b57cec5SDimitry Andric        {return __x.__i_ == __y.__i_;}
10130b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
10140b57cec5SDimitry Andric        bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
10150b57cec5SDimitry Andric        {return __x.__i_ != __y.__i_;}
10160b57cec5SDimitry Andric
10170b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
10180b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
10190b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
10200b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
10210b57cec5SDimitry Andric};
10220b57cec5SDimitry Andric
10230b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
10240b57cec5SDimitry Andricclass unordered_multimap;
10250b57cec5SDimitry Andric
10260b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
10270b57cec5SDimitry Andric          class _Alloc = allocator<pair<const _Key, _Tp> > >
10280b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_map
10290b57cec5SDimitry Andric{
10300b57cec5SDimitry Andricpublic:
10310b57cec5SDimitry Andric    // types
10320b57cec5SDimitry Andric    typedef _Key                                           key_type;
10330b57cec5SDimitry Andric    typedef _Tp                                            mapped_type;
103481ad6265SDimitry Andric    typedef __type_identity_t<_Hash>                       hasher;
103581ad6265SDimitry Andric    typedef __type_identity_t<_Pred>                       key_equal;
103681ad6265SDimitry Andric    typedef __type_identity_t<_Alloc>                      allocator_type;
10370b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>              value_type;
10380b57cec5SDimitry Andric    typedef value_type&                                    reference;
10390b57cec5SDimitry Andric    typedef const value_type&                              const_reference;
10400b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
10410b57cec5SDimitry Andric                  "Invalid allocator::value_type");
10420b57cec5SDimitry Andric
10430b57cec5SDimitry Andricprivate:
10440b57cec5SDimitry Andric    typedef __hash_value_type<key_type, mapped_type>                          __value_type;
1045e8d8bef9SDimitry Andric    typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
1046e8d8bef9SDimitry Andric    typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher>  __key_equal;
10470b57cec5SDimitry Andric    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
10480b57cec5SDimitry Andric                                                 __value_type>::type          __allocator_type;
10490b57cec5SDimitry Andric
10500b57cec5SDimitry Andric    typedef __hash_table<__value_type, __hasher,
10510b57cec5SDimitry Andric                         __key_equal,  __allocator_type>   __table;
10520b57cec5SDimitry Andric
10530b57cec5SDimitry Andric    __table __table_;
10540b57cec5SDimitry Andric
10550b57cec5SDimitry Andric    typedef typename __table::_NodeTypes                   _NodeTypes;
10560b57cec5SDimitry Andric    typedef typename __table::__node_pointer               __node_pointer;
10570b57cec5SDimitry Andric    typedef typename __table::__node_const_pointer         __node_const_pointer;
10580b57cec5SDimitry Andric    typedef typename __table::__node_traits                __node_traits;
10590b57cec5SDimitry Andric    typedef typename __table::__node_allocator             __node_allocator;
10600b57cec5SDimitry Andric    typedef typename __table::__node                       __node;
10610b57cec5SDimitry Andric    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
10620b57cec5SDimitry Andric    typedef unique_ptr<__node, _Dp>                         __node_holder;
10630b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>               __alloc_traits;
10640b57cec5SDimitry Andric
10650b57cec5SDimitry Andric    static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");
10660b57cec5SDimitry Andric    static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");
10670b57cec5SDimitry Andricpublic:
10680b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer         pointer;
10690b57cec5SDimitry Andric    typedef typename __alloc_traits::const_pointer   const_pointer;
10700b57cec5SDimitry Andric    typedef typename __table::size_type              size_type;
10710b57cec5SDimitry Andric    typedef typename __table::difference_type        difference_type;
10720b57cec5SDimitry Andric
10730b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::iterator>       iterator;
10740b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
10750b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
10760b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
10770b57cec5SDimitry Andric
10780b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
10790b57cec5SDimitry Andric    typedef __map_node_handle<__node, allocator_type> node_type;
10800b57cec5SDimitry Andric    typedef __insert_return_type<iterator, node_type> insert_return_type;
10810b57cec5SDimitry Andric#endif
10820b57cec5SDimitry Andric
10830b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
10840b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_map;
10850b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
10860b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
10870b57cec5SDimitry Andric
10880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
10890b57cec5SDimitry Andric    unordered_map()
10900b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
10910b57cec5SDimitry Andric    {
109204eeddc0SDimitry Andric        _VSTD::__debug_db_insert_c(this);
10930b57cec5SDimitry Andric    }
10940b57cec5SDimitry Andric    explicit unordered_map(size_type __n, const hasher& __hf = hasher(),
10950b57cec5SDimitry Andric                           const key_equal& __eql = key_equal());
10960b57cec5SDimitry Andric    unordered_map(size_type __n, const hasher& __hf,
10970b57cec5SDimitry Andric                  const key_equal& __eql,
10980b57cec5SDimitry Andric                  const allocator_type& __a);
10990b57cec5SDimitry Andric    template <class _InputIterator>
11000b57cec5SDimitry Andric        unordered_map(_InputIterator __first, _InputIterator __last);
11010b57cec5SDimitry Andric    template <class _InputIterator>
11020b57cec5SDimitry Andric        unordered_map(_InputIterator __first, _InputIterator __last,
11030b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
11040b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
11050b57cec5SDimitry Andric    template <class _InputIterator>
11060b57cec5SDimitry Andric        unordered_map(_InputIterator __first, _InputIterator __last,
11070b57cec5SDimitry Andric                      size_type __n, const hasher& __hf,
11080b57cec5SDimitry Andric                      const key_equal& __eql,
11090b57cec5SDimitry Andric                      const allocator_type& __a);
11100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11110b57cec5SDimitry Andric    explicit unordered_map(const allocator_type& __a);
11120b57cec5SDimitry Andric    unordered_map(const unordered_map& __u);
11130b57cec5SDimitry Andric    unordered_map(const unordered_map& __u, const allocator_type& __a);
11140b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
11150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11160b57cec5SDimitry Andric    unordered_map(unordered_map&& __u)
11170b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
11180b57cec5SDimitry Andric    unordered_map(unordered_map&& __u, const allocator_type& __a);
11190b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il);
11200b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n,
11210b57cec5SDimitry Andric                  const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
11220b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n,
11230b57cec5SDimitry Andric                  const hasher& __hf, const key_equal& __eql,
11240b57cec5SDimitry Andric                  const allocator_type& __a);
11250b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
11260b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
11270b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11280b57cec5SDimitry Andric    unordered_map(size_type __n, const allocator_type& __a)
11290b57cec5SDimitry Andric      : unordered_map(__n, hasher(), key_equal(), __a) {}
11300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11310b57cec5SDimitry Andric    unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
11320b57cec5SDimitry Andric      : unordered_map(__n, __hf, key_equal(), __a) {}
11330b57cec5SDimitry Andric    template <class _InputIterator>
11340b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11350b57cec5SDimitry Andric      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
11360b57cec5SDimitry Andric      : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
11370b57cec5SDimitry Andric    template <class _InputIterator>
11380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11390b57cec5SDimitry Andric      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
11400b57cec5SDimitry Andric        const allocator_type& __a)
11410b57cec5SDimitry Andric      : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
11420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11430b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
11440b57cec5SDimitry Andric      : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
11450b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11460b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
11470b57cec5SDimitry Andric      const allocator_type& __a)
11480b57cec5SDimitry Andric      : unordered_map(__il, __n, __hf, key_equal(), __a) {}
11490b57cec5SDimitry Andric#endif
11500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11510b57cec5SDimitry Andric    ~unordered_map() {
11520b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
11530b57cec5SDimitry Andric    }
11540b57cec5SDimitry Andric
11550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11560b57cec5SDimitry Andric    unordered_map& operator=(const unordered_map& __u)
11570b57cec5SDimitry Andric    {
11580b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
11590b57cec5SDimitry Andric        __table_ = __u.__table_;
11600b57cec5SDimitry Andric#else
1161349cc55cSDimitry Andric        if (this != _VSTD::addressof(__u)) {
11620b57cec5SDimitry Andric            __table_.clear();
11630b57cec5SDimitry Andric            __table_.hash_function() = __u.__table_.hash_function();
11640b57cec5SDimitry Andric            __table_.key_eq() = __u.__table_.key_eq();
11650b57cec5SDimitry Andric            __table_.max_load_factor() = __u.__table_.max_load_factor();
11660b57cec5SDimitry Andric            __table_.__copy_assign_alloc(__u.__table_);
11670b57cec5SDimitry Andric            insert(__u.begin(), __u.end());
11680b57cec5SDimitry Andric        }
11690b57cec5SDimitry Andric#endif
11700b57cec5SDimitry Andric        return *this;
11710b57cec5SDimitry Andric    }
11720b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
11730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11740b57cec5SDimitry Andric    unordered_map& operator=(unordered_map&& __u)
11750b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
11760b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11770b57cec5SDimitry Andric    unordered_map& operator=(initializer_list<value_type> __il);
11780b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
11790b57cec5SDimitry Andric
11800b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11810b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
11820b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
11830b57cec5SDimitry Andric
11840b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
11850b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
11860b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11870b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
11880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11890b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
11900b57cec5SDimitry Andric
11910b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11920b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
11930b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11940b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
11950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11960b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
11970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
11980b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
11990b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12000b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
12010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12020b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
12030b57cec5SDimitry Andric
12040b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12050b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& __x)
12060b57cec5SDimitry Andric        {return __table_.__insert_unique(__x);}
12070b57cec5SDimitry Andric
12080b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __x) {
120904eeddc0SDimitry Andric        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
12100b57cec5SDimitry Andric                             "unordered_map::insert(const_iterator, const value_type&) called with an iterator not "
12110b57cec5SDimitry Andric                             "referring to this unordered_map");
12120b57cec5SDimitry Andric        ((void)__p);
12130b57cec5SDimitry Andric        return insert(__x).first;
12140b57cec5SDimitry Andric    }
12150b57cec5SDimitry Andric
12160b57cec5SDimitry Andric    template <class _InputIterator>
12170b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12180b57cec5SDimitry Andric        void insert(_InputIterator __first, _InputIterator __last);
12190b57cec5SDimitry Andric
12200b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
12210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12220b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
12230b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
12240b57cec5SDimitry Andric
12250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12260b57cec5SDimitry Andric    pair<iterator, bool> insert(value_type&& __x)
12270b57cec5SDimitry Andric        {return __table_.__insert_unique(_VSTD::move(__x));}
12280b57cec5SDimitry Andric
12290b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __x) {
123004eeddc0SDimitry Andric        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
12310b57cec5SDimitry Andric                             "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
12320b57cec5SDimitry Andric                             " referring to this unordered_map");
12330b57cec5SDimitry Andric        ((void)__p);
12340b57cec5SDimitry Andric        return __table_.__insert_unique(_VSTD::move(__x)).first;
12350b57cec5SDimitry Andric    }
12360b57cec5SDimitry Andric
12370b57cec5SDimitry Andric    template <class _Pp,
1238*753f127fSDimitry Andric              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
12390b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12400b57cec5SDimitry Andric        pair<iterator, bool> insert(_Pp&& __x)
12410b57cec5SDimitry Andric            {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
12420b57cec5SDimitry Andric
12430b57cec5SDimitry Andric    template <class _Pp,
1244*753f127fSDimitry Andric              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
12450b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12460b57cec5SDimitry Andric        iterator insert(const_iterator __p, _Pp&& __x)
12470b57cec5SDimitry Andric        {
124804eeddc0SDimitry Andric            _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
12490b57cec5SDimitry Andric                                 "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
12500b57cec5SDimitry Andric                                 " referring to this unordered_map");
12510b57cec5SDimitry Andric          ((void)__p);
12520b57cec5SDimitry Andric            return insert(_VSTD::forward<_Pp>(__x)).first;
12530b57cec5SDimitry Andric        }
12540b57cec5SDimitry Andric
12550b57cec5SDimitry Andric    template <class... _Args>
12560b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12570b57cec5SDimitry Andric    pair<iterator, bool> emplace(_Args&&... __args) {
12580b57cec5SDimitry Andric        return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
12590b57cec5SDimitry Andric    }
12600b57cec5SDimitry Andric
12610b57cec5SDimitry Andric    template <class... _Args>
12620b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
12630b57cec5SDimitry Andric    iterator emplace_hint(const_iterator __p, _Args&&... __args) {
126404eeddc0SDimitry Andric        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
12650b57cec5SDimitry Andric                             "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
12660b57cec5SDimitry Andric                             " referring to this unordered_map");
12670b57cec5SDimitry Andric          ((void)__p);
12680b57cec5SDimitry Andric        return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
12690b57cec5SDimitry Andric    }
12700b57cec5SDimitry Andric
12710b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
12720b57cec5SDimitry Andric
12730b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
12740b57cec5SDimitry Andric    template <class... _Args>
12750b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12760b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
12770b57cec5SDimitry Andric    {
1278e8d8bef9SDimitry Andric        return __table_.__emplace_unique_key_args(__k, piecewise_construct,
12790b57cec5SDimitry Andric            _VSTD::forward_as_tuple(__k),
12800b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
12810b57cec5SDimitry Andric    }
12820b57cec5SDimitry Andric
12830b57cec5SDimitry Andric    template <class... _Args>
12840b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12850b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
12860b57cec5SDimitry Andric    {
1287e8d8bef9SDimitry Andric        return __table_.__emplace_unique_key_args(__k, piecewise_construct,
12880b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::move(__k)),
12890b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
12900b57cec5SDimitry Andric    }
12910b57cec5SDimitry Andric
12920b57cec5SDimitry Andric    template <class... _Args>
12930b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
12940b57cec5SDimitry Andric        iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
12950b57cec5SDimitry Andric    {
129604eeddc0SDimitry Andric        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__h)) == this,
12970b57cec5SDimitry Andric                             "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
12980b57cec5SDimitry Andric                             " referring to this unordered_map");
12990b57cec5SDimitry Andric        ((void)__h);
13000b57cec5SDimitry Andric        return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
13010b57cec5SDimitry Andric    }
13020b57cec5SDimitry Andric
13030b57cec5SDimitry Andric    template <class... _Args>
13040b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13050b57cec5SDimitry Andric        iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
13060b57cec5SDimitry Andric    {
130704eeddc0SDimitry Andric        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__h)) == this,
13080b57cec5SDimitry Andric                             "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
13090b57cec5SDimitry Andric                             " referring to this unordered_map");
13100b57cec5SDimitry Andric        ((void)__h);
13110b57cec5SDimitry Andric        return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first;
13120b57cec5SDimitry Andric    }
13130b57cec5SDimitry Andric
13140b57cec5SDimitry Andric    template <class _Vp>
13150b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13160b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
13170b57cec5SDimitry Andric    {
13180b57cec5SDimitry Andric        pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
13190b57cec5SDimitry Andric            __k, _VSTD::forward<_Vp>(__v));
13200b57cec5SDimitry Andric        if (!__res.second) {
13210b57cec5SDimitry Andric            __res.first->second = _VSTD::forward<_Vp>(__v);
13220b57cec5SDimitry Andric        }
13230b57cec5SDimitry Andric        return __res;
13240b57cec5SDimitry Andric    }
13250b57cec5SDimitry Andric
13260b57cec5SDimitry Andric    template <class _Vp>
13270b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13280b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
13290b57cec5SDimitry Andric    {
13300b57cec5SDimitry Andric        pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
13310b57cec5SDimitry Andric            _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
13320b57cec5SDimitry Andric        if (!__res.second) {
13330b57cec5SDimitry Andric            __res.first->second = _VSTD::forward<_Vp>(__v);
13340b57cec5SDimitry Andric        }
13350b57cec5SDimitry Andric        return __res;
13360b57cec5SDimitry Andric    }
13370b57cec5SDimitry Andric
13380b57cec5SDimitry Andric    template <class _Vp>
13390b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13400b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator, const key_type& __k, _Vp&& __v)
13410b57cec5SDimitry Andric     {
13420b57cec5SDimitry Andric          // FIXME: Add debug mode checking for the iterator input
13430b57cec5SDimitry Andric          return insert_or_assign(__k, _VSTD::forward<_Vp>(__v)).first;
13440b57cec5SDimitry Andric     }
13450b57cec5SDimitry Andric
13460b57cec5SDimitry Andric    template <class _Vp>
13470b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
13480b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v)
13490b57cec5SDimitry Andric     {
13500b57cec5SDimitry Andric        // FIXME: Add debug mode checking for the iterator input
13510b57cec5SDimitry Andric        return insert_or_assign(_VSTD::move(__k), _VSTD::forward<_Vp>(__v)).first;
13520b57cec5SDimitry Andric     }
13530b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 14
13540b57cec5SDimitry Andric
13550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13560b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
13570b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13580b57cec5SDimitry Andric    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
13590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13600b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
13610b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13620b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
13630b57cec5SDimitry Andric        {return __table_.erase(__first.__i_, __last.__i_);}
13640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13650b57cec5SDimitry Andric        void clear() _NOEXCEPT {__table_.clear();}
13660b57cec5SDimitry Andric
13670b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
13680b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13690b57cec5SDimitry Andric    insert_return_type insert(node_type&& __nh)
13700b57cec5SDimitry Andric    {
13710b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
13720b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_map::insert()");
13730b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<
13740b57cec5SDimitry Andric            node_type, insert_return_type>(_VSTD::move(__nh));
13750b57cec5SDimitry Andric    }
13760b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13770b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
13780b57cec5SDimitry Andric    {
13790b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
13800b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_map::insert()");
13810b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<node_type>(
13820b57cec5SDimitry Andric            __hint.__i_, _VSTD::move(__nh));
13830b57cec5SDimitry Andric    }
13840b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13850b57cec5SDimitry Andric    node_type extract(key_type const& __key)
13860b57cec5SDimitry Andric    {
13870b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
13880b57cec5SDimitry Andric    }
13890b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13900b57cec5SDimitry Andric    node_type extract(const_iterator __it)
13910b57cec5SDimitry Andric    {
13920b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(
13930b57cec5SDimitry Andric            __it.__i_);
13940b57cec5SDimitry Andric    }
13950b57cec5SDimitry Andric
13960b57cec5SDimitry Andric    template <class _H2, class _P2>
13970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
13980b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
13990b57cec5SDimitry Andric    {
14000b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
14010b57cec5SDimitry Andric                       "merging container with incompatible allocator");
14020b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
14030b57cec5SDimitry Andric    }
14040b57cec5SDimitry Andric    template <class _H2, class _P2>
14050b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14060b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
14070b57cec5SDimitry Andric    {
14080b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
14090b57cec5SDimitry Andric                       "merging container with incompatible allocator");
14100b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
14110b57cec5SDimitry Andric    }
14120b57cec5SDimitry Andric    template <class _H2, class _P2>
14130b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14140b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
14150b57cec5SDimitry Andric    {
14160b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
14170b57cec5SDimitry Andric                       "merging container with incompatible allocator");
14180b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
14190b57cec5SDimitry Andric    }
14200b57cec5SDimitry Andric    template <class _H2, class _P2>
14210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14220b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
14230b57cec5SDimitry Andric    {
14240b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
14250b57cec5SDimitry Andric                       "merging container with incompatible allocator");
14260b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
14270b57cec5SDimitry Andric    }
14280b57cec5SDimitry Andric#endif
14290b57cec5SDimitry Andric
14300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14310b57cec5SDimitry Andric    void swap(unordered_map& __u)
14320b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
14330b57cec5SDimitry Andric        { __table_.swap(__u.__table_);}
14340b57cec5SDimitry Andric
14350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14360b57cec5SDimitry Andric    hasher hash_function() const
14370b57cec5SDimitry Andric        {return __table_.hash_function().hash_function();}
14380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14390b57cec5SDimitry Andric    key_equal key_eq() const
14400b57cec5SDimitry Andric        {return __table_.key_eq().key_eq();}
14410b57cec5SDimitry Andric
14420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14430b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
14440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14450b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1446e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
1447349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1448e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1449349cc55cSDimitry Andric    iterator       find(const _K2& __k)            {return __table_.find(__k);}
1450349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1451e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1452349cc55cSDimitry Andric    const_iterator find(const _K2& __k) const      {return __table_.find(__k);}
1453e8d8bef9SDimitry Andric#endif // _LIBCPP_STD_VER > 17
1454e8d8bef9SDimitry Andric
14550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14560b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
14570b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
1458349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1459e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1460349cc55cSDimitry Andric    size_type count(const _K2& __k) const      {return __table_.__count_unique(__k);}
1461e8d8bef9SDimitry Andric#endif // _LIBCPP_STD_VER > 17
1462349cc55cSDimitry Andric
1463e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
14640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14650b57cec5SDimitry Andric    bool contains(const key_type& __k) const {return find(__k) != end();}
1466e8d8bef9SDimitry Andric
1467349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1468e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1469349cc55cSDimitry Andric    bool contains(const _K2& __k) const      {return find(__k) != end();}
14700b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 17
1471349cc55cSDimitry Andric
14720b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14730b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
14740b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
14750b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14760b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
14770b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
1478e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
1479349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1480e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1481349cc55cSDimitry Andric    pair<iterator, iterator>             equal_range(const _K2& __k)
1482349cc55cSDimitry Andric        {return __table_.__equal_range_unique(__k);}
1483349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1484e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1485349cc55cSDimitry Andric    pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
1486349cc55cSDimitry Andric        {return __table_.__equal_range_unique(__k);}
1487e8d8bef9SDimitry Andric#endif // _LIBCPP_STD_VER > 17
14880b57cec5SDimitry Andric
14890b57cec5SDimitry Andric    mapped_type& operator[](const key_type& __k);
14900b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
14910b57cec5SDimitry Andric    mapped_type& operator[](key_type&& __k);
14920b57cec5SDimitry Andric#endif
14930b57cec5SDimitry Andric
14940b57cec5SDimitry Andric    mapped_type&       at(const key_type& __k);
14950b57cec5SDimitry Andric    const mapped_type& at(const key_type& __k) const;
14960b57cec5SDimitry Andric
14970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
14980b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
14990b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15000b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
15010b57cec5SDimitry Andric
15020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15030b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const
15040b57cec5SDimitry Andric        {return __table_.bucket_size(__n);}
15050b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15060b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
15070b57cec5SDimitry Andric
15080b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15090b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
15100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15110b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
15120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15130b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
15140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15150b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
15160b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15170b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
15180b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15190b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
15200b57cec5SDimitry Andric
15210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15220b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
15230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15240b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
15250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
15260b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
15270b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1528*753f127fSDimitry Andric    void rehash(size_type __n) {__table_.__rehash_unique(__n);}
15290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1530*753f127fSDimitry Andric    void reserve(size_type __n) {__table_.__reserve_unique(__n);}
15310b57cec5SDimitry Andric
153281ad6265SDimitry Andric#ifdef _LIBCPP_ENABLE_DEBUG_MODE
15330b57cec5SDimitry Andric
15340b57cec5SDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
1535349cc55cSDimitry Andric        {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
15360b57cec5SDimitry Andric    bool __decrementable(const const_iterator* __i) const
1537349cc55cSDimitry Andric        {return __table_.__decrementable(_VSTD::addressof(__i->__i_));}
15380b57cec5SDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1539349cc55cSDimitry Andric        {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
15400b57cec5SDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1541349cc55cSDimitry Andric        {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
15420b57cec5SDimitry Andric
154381ad6265SDimitry Andric#endif // _LIBCPP_ENABLE_DEBUG_MODE
15440b57cec5SDimitry Andric
15450b57cec5SDimitry Andricprivate:
15460b57cec5SDimitry Andric
15470b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG
15480b57cec5SDimitry Andric    __node_holder __construct_node_with_key(const key_type& __k);
15490b57cec5SDimitry Andric#endif
15500b57cec5SDimitry Andric};
15510b57cec5SDimitry Andric
1552349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
15530b57cec5SDimitry Andrictemplate<class _InputIterator,
15540b57cec5SDimitry Andric         class _Hash = hash<__iter_key_type<_InputIterator>>,
15550b57cec5SDimitry Andric         class _Pred = equal_to<__iter_key_type<_InputIterator>>,
15560b57cec5SDimitry Andric         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
1557349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
1558349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
1559349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
1560349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Pred>::value>,
1561349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
15620b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
15630b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
15640b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
15650b57cec5SDimitry Andric
15660b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>,
15670b57cec5SDimitry Andric         class _Pred = equal_to<remove_const_t<_Key>>,
15680b57cec5SDimitry Andric         class _Allocator = allocator<pair<const _Key, _Tp>>,
1569349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
1570349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
1571349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Pred>::value>,
1572349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
15730b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0,
15740b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
15750b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
15760b57cec5SDimitry Andric
15770b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
1578349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
1579349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
15800b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
15810b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
15820b57cec5SDimitry Andric                   hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
15830b57cec5SDimitry Andric
15840b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
1585349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
1586349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
15870b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, _Allocator)
15880b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
15890b57cec5SDimitry Andric                   hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
15900b57cec5SDimitry Andric
15910b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
1592349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
1593349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
1594349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
1595349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
15960b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
15970b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
15980b57cec5SDimitry Andric                   _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
15990b57cec5SDimitry Andric
16000b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
1601349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
16020b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
16030b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp,
16040b57cec5SDimitry Andric                   hash<remove_const_t<_Key>>,
16050b57cec5SDimitry Andric                   equal_to<remove_const_t<_Key>>, _Allocator>;
16060b57cec5SDimitry Andric
16070b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
1608349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
16090b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator)
16100b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp,
16110b57cec5SDimitry Andric                   hash<remove_const_t<_Key>>,
16120b57cec5SDimitry Andric                   equal_to<remove_const_t<_Key>>, _Allocator>;
16130b57cec5SDimitry Andric
16140b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash, class _Allocator,
1615349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
1616349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
1617349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
16180b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
16190b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp, _Hash,
16200b57cec5SDimitry Andric                   equal_to<remove_const_t<_Key>>, _Allocator>;
16210b57cec5SDimitry Andric#endif
16220b57cec5SDimitry Andric
16230b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16240b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
16250b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql)
16260b57cec5SDimitry Andric    : __table_(__hf, __eql)
16270b57cec5SDimitry Andric{
162804eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
1629*753f127fSDimitry Andric    __table_.__rehash_unique(__n);
16300b57cec5SDimitry Andric}
16310b57cec5SDimitry Andric
16320b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16330b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
16340b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql,
16350b57cec5SDimitry Andric        const allocator_type& __a)
16360b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
16370b57cec5SDimitry Andric{
163804eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
1639*753f127fSDimitry Andric    __table_.__rehash_unique(__n);
16400b57cec5SDimitry Andric}
16410b57cec5SDimitry Andric
16420b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16430b57cec5SDimitry Andricinline
16440b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
16450b57cec5SDimitry Andric        const allocator_type& __a)
16460b57cec5SDimitry Andric    : __table_(typename __table::allocator_type(__a))
16470b57cec5SDimitry Andric{
164804eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
16490b57cec5SDimitry Andric}
16500b57cec5SDimitry Andric
16510b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16520b57cec5SDimitry Andrictemplate <class _InputIterator>
16530b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
16540b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
16550b57cec5SDimitry Andric{
165604eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
16570b57cec5SDimitry Andric    insert(__first, __last);
16580b57cec5SDimitry Andric}
16590b57cec5SDimitry Andric
16600b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16610b57cec5SDimitry Andrictemplate <class _InputIterator>
16620b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
16630b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
16640b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
16650b57cec5SDimitry Andric    : __table_(__hf, __eql)
16660b57cec5SDimitry Andric{
166704eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
1668*753f127fSDimitry Andric    __table_.__rehash_unique(__n);
16690b57cec5SDimitry Andric    insert(__first, __last);
16700b57cec5SDimitry Andric}
16710b57cec5SDimitry Andric
16720b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16730b57cec5SDimitry Andrictemplate <class _InputIterator>
16740b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
16750b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
16760b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
16770b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
16780b57cec5SDimitry Andric{
167904eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
1680*753f127fSDimitry Andric    __table_.__rehash_unique(__n);
16810b57cec5SDimitry Andric    insert(__first, __last);
16820b57cec5SDimitry Andric}
16830b57cec5SDimitry Andric
16840b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16850b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
16860b57cec5SDimitry Andric        const unordered_map& __u)
16870b57cec5SDimitry Andric    : __table_(__u.__table_)
16880b57cec5SDimitry Andric{
168904eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
1690*753f127fSDimitry Andric    __table_.__rehash_unique(__u.bucket_count());
16910b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
16920b57cec5SDimitry Andric}
16930b57cec5SDimitry Andric
16940b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
16950b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
16960b57cec5SDimitry Andric        const unordered_map& __u, const allocator_type& __a)
16970b57cec5SDimitry Andric    : __table_(__u.__table_, typename __table::allocator_type(__a))
16980b57cec5SDimitry Andric{
169904eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
1700*753f127fSDimitry Andric    __table_.__rehash_unique(__u.bucket_count());
17010b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
17020b57cec5SDimitry Andric}
17030b57cec5SDimitry Andric
17040b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
17050b57cec5SDimitry Andric
17060b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17070b57cec5SDimitry Andricinline
17080b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17090b57cec5SDimitry Andric        unordered_map&& __u)
17100b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
17110b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
17120b57cec5SDimitry Andric{
171304eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
171481ad6265SDimitry Andric    std::__debug_db_swap(this, std::addressof(__u));
17150b57cec5SDimitry Andric}
17160b57cec5SDimitry Andric
17170b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17180b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17190b57cec5SDimitry Andric        unordered_map&& __u, const allocator_type& __a)
17200b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
17210b57cec5SDimitry Andric{
172204eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
17230b57cec5SDimitry Andric    if (__a != __u.get_allocator())
17240b57cec5SDimitry Andric    {
17250b57cec5SDimitry Andric        iterator __i = __u.begin();
17260b57cec5SDimitry Andric        while (__u.size() != 0) {
17270b57cec5SDimitry Andric            __table_.__emplace_unique(
17280b57cec5SDimitry Andric                __u.__table_.remove((__i++).__i_)->__value_.__move());
17290b57cec5SDimitry Andric        }
17300b57cec5SDimitry Andric    }
17310b57cec5SDimitry Andric    else
173281ad6265SDimitry Andric        std::__debug_db_swap(this, std::addressof(__u));
17330b57cec5SDimitry Andric}
17340b57cec5SDimitry Andric
17350b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17360b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17370b57cec5SDimitry Andric        initializer_list<value_type> __il)
17380b57cec5SDimitry Andric{
173904eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
17400b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
17410b57cec5SDimitry Andric}
17420b57cec5SDimitry Andric
17430b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17440b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17450b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
17460b57cec5SDimitry Andric        const key_equal& __eql)
17470b57cec5SDimitry Andric    : __table_(__hf, __eql)
17480b57cec5SDimitry Andric{
174904eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
1750*753f127fSDimitry Andric    __table_.__rehash_unique(__n);
17510b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
17520b57cec5SDimitry Andric}
17530b57cec5SDimitry Andric
17540b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17550b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
17560b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
17570b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
17580b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
17590b57cec5SDimitry Andric{
176004eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
1761*753f127fSDimitry Andric    __table_.__rehash_unique(__n);
17620b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
17630b57cec5SDimitry Andric}
17640b57cec5SDimitry Andric
17650b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17660b57cec5SDimitry Andricinline
17670b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
17680b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
17690b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
17700b57cec5SDimitry Andric{
17710b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
17720b57cec5SDimitry Andric    return *this;
17730b57cec5SDimitry Andric}
17740b57cec5SDimitry Andric
17750b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17760b57cec5SDimitry Andricinline
17770b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
17780b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
17790b57cec5SDimitry Andric        initializer_list<value_type> __il)
17800b57cec5SDimitry Andric{
17810b57cec5SDimitry Andric    __table_.__assign_unique(__il.begin(), __il.end());
17820b57cec5SDimitry Andric    return *this;
17830b57cec5SDimitry Andric}
17840b57cec5SDimitry Andric
17850b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
17860b57cec5SDimitry Andric
17870b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17880b57cec5SDimitry Andrictemplate <class _InputIterator>
17890b57cec5SDimitry Andricinline
17900b57cec5SDimitry Andricvoid
17910b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
17920b57cec5SDimitry Andric                                                       _InputIterator __last)
17930b57cec5SDimitry Andric{
17940b57cec5SDimitry Andric    for (; __first != __last; ++__first)
17950b57cec5SDimitry Andric        __table_.__insert_unique(*__first);
17960b57cec5SDimitry Andric}
17970b57cec5SDimitry Andric
17980b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
17990b57cec5SDimitry Andric
18000b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18010b57cec5SDimitry Andric_Tp&
18020b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
18030b57cec5SDimitry Andric{
18040b57cec5SDimitry Andric    return __table_.__emplace_unique_key_args(__k,
1805e8d8bef9SDimitry Andric        piecewise_construct, _VSTD::forward_as_tuple(__k),
1806e8d8bef9SDimitry Andric                             _VSTD::forward_as_tuple()).first->__get_value().second;
18070b57cec5SDimitry Andric}
18080b57cec5SDimitry Andric
18090b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18100b57cec5SDimitry Andric_Tp&
18110b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
18120b57cec5SDimitry Andric{
18130b57cec5SDimitry Andric    return __table_.__emplace_unique_key_args(__k,
1814e8d8bef9SDimitry Andric        piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
1815e8d8bef9SDimitry Andric                             _VSTD::forward_as_tuple()).first->__get_value().second;
18160b57cec5SDimitry Andric}
18170b57cec5SDimitry Andric#else // _LIBCPP_CXX03_LANG
18180b57cec5SDimitry Andric
18190b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18200b57cec5SDimitry Andrictypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
18210b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
18220b57cec5SDimitry Andric{
18230b57cec5SDimitry Andric    __node_allocator& __na = __table_.__node_alloc();
18240b57cec5SDimitry Andric    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
18250b57cec5SDimitry Andric    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k);
18260b57cec5SDimitry Andric    __h.get_deleter().__first_constructed = true;
18270b57cec5SDimitry Andric    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
18280b57cec5SDimitry Andric    __h.get_deleter().__second_constructed = true;
1829e8d8bef9SDimitry Andric    return __h;
18300b57cec5SDimitry Andric}
18310b57cec5SDimitry Andric
18320b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18330b57cec5SDimitry Andric_Tp&
18340b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
18350b57cec5SDimitry Andric{
18360b57cec5SDimitry Andric    iterator __i = find(__k);
18370b57cec5SDimitry Andric    if (__i != end())
18380b57cec5SDimitry Andric        return __i->second;
18390b57cec5SDimitry Andric    __node_holder __h = __construct_node_with_key(__k);
18400b57cec5SDimitry Andric    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
18410b57cec5SDimitry Andric    __h.release();
18420b57cec5SDimitry Andric    return __r.first->second;
18430b57cec5SDimitry Andric}
18440b57cec5SDimitry Andric
1845fe6060f1SDimitry Andric#endif // _LIBCPP_CXX03_LANG
18460b57cec5SDimitry Andric
18470b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18480b57cec5SDimitry Andric_Tp&
18490b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k)
18500b57cec5SDimitry Andric{
18510b57cec5SDimitry Andric    iterator __i = find(__k);
18520b57cec5SDimitry Andric    if (__i == end())
18530b57cec5SDimitry Andric        __throw_out_of_range("unordered_map::at: key not found");
18540b57cec5SDimitry Andric    return __i->second;
18550b57cec5SDimitry Andric}
18560b57cec5SDimitry Andric
18570b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18580b57cec5SDimitry Andricconst _Tp&
18590b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const
18600b57cec5SDimitry Andric{
18610b57cec5SDimitry Andric    const_iterator __i = find(__k);
18620b57cec5SDimitry Andric    if (__i == end())
18630b57cec5SDimitry Andric        __throw_out_of_range("unordered_map::at: key not found");
18640b57cec5SDimitry Andric    return __i->second;
18650b57cec5SDimitry Andric}
18660b57cec5SDimitry Andric
18670b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18680b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
18690b57cec5SDimitry Andricvoid
18700b57cec5SDimitry Andricswap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
18710b57cec5SDimitry Andric     unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
18720b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
18730b57cec5SDimitry Andric{
18740b57cec5SDimitry Andric    __x.swap(__y);
18750b57cec5SDimitry Andric}
18760b57cec5SDimitry Andric
18770b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
18785ffd83dbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
18795ffd83dbSDimitry Andric          class _Predicate>
18800b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
18815ffd83dbSDimitry Andric    typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
18825ffd83dbSDimitry Andric    erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c,
18835ffd83dbSDimitry Andric             _Predicate __pred) {
1884fe6060f1SDimitry Andric  return _VSTD::__libcpp_erase_if_container(__c, __pred);
18855ffd83dbSDimitry Andric}
18860b57cec5SDimitry Andric#endif
18870b57cec5SDimitry Andric
18880b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18890b57cec5SDimitry Andricbool
18900b57cec5SDimitry Andricoperator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
18910b57cec5SDimitry Andric           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
18920b57cec5SDimitry Andric{
18930b57cec5SDimitry Andric    if (__x.size() != __y.size())
18940b57cec5SDimitry Andric        return false;
18950b57cec5SDimitry Andric    typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
18960b57cec5SDimitry Andric                                                                 const_iterator;
18970b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
18980b57cec5SDimitry Andric            __i != __ex; ++__i)
18990b57cec5SDimitry Andric    {
19000b57cec5SDimitry Andric        const_iterator __j = __y.find(__i->first);
19010b57cec5SDimitry Andric        if (__j == __ey || !(*__i == *__j))
19020b57cec5SDimitry Andric            return false;
19030b57cec5SDimitry Andric    }
19040b57cec5SDimitry Andric    return true;
19050b57cec5SDimitry Andric}
19060b57cec5SDimitry Andric
19070b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19080b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
19090b57cec5SDimitry Andricbool
19100b57cec5SDimitry Andricoperator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
19110b57cec5SDimitry Andric           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
19120b57cec5SDimitry Andric{
19130b57cec5SDimitry Andric    return !(__x == __y);
19140b57cec5SDimitry Andric}
19150b57cec5SDimitry Andric
19160b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
19170b57cec5SDimitry Andric          class _Alloc = allocator<pair<const _Key, _Tp> > >
19180b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multimap
19190b57cec5SDimitry Andric{
19200b57cec5SDimitry Andricpublic:
19210b57cec5SDimitry Andric    // types
19220b57cec5SDimitry Andric    typedef _Key                                           key_type;
19230b57cec5SDimitry Andric    typedef _Tp                                            mapped_type;
192481ad6265SDimitry Andric    typedef __type_identity_t<_Hash>                       hasher;
192581ad6265SDimitry Andric    typedef __type_identity_t<_Pred>                       key_equal;
192681ad6265SDimitry Andric    typedef __type_identity_t<_Alloc>                      allocator_type;
19270b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>              value_type;
19280b57cec5SDimitry Andric    typedef value_type&                                    reference;
19290b57cec5SDimitry Andric    typedef const value_type&                              const_reference;
19300b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
19310b57cec5SDimitry Andric                  "Invalid allocator::value_type");
19320b57cec5SDimitry Andric
19330b57cec5SDimitry Andricprivate:
19340b57cec5SDimitry Andric    typedef __hash_value_type<key_type, mapped_type>                          __value_type;
1935e8d8bef9SDimitry Andric    typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
1936e8d8bef9SDimitry Andric    typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher>  __key_equal;
19370b57cec5SDimitry Andric    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
19380b57cec5SDimitry Andric                                                 __value_type>::type          __allocator_type;
19390b57cec5SDimitry Andric
19400b57cec5SDimitry Andric    typedef __hash_table<__value_type, __hasher,
19410b57cec5SDimitry Andric                         __key_equal,  __allocator_type>   __table;
19420b57cec5SDimitry Andric
19430b57cec5SDimitry Andric    __table __table_;
19440b57cec5SDimitry Andric
19450b57cec5SDimitry Andric    typedef typename __table::_NodeTypes                   _NodeTypes;
19460b57cec5SDimitry Andric    typedef typename __table::__node_traits                __node_traits;
19470b57cec5SDimitry Andric    typedef typename __table::__node_allocator             __node_allocator;
19480b57cec5SDimitry Andric    typedef typename __table::__node                       __node;
19490b57cec5SDimitry Andric    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
19500b57cec5SDimitry Andric    typedef unique_ptr<__node, _Dp>                         __node_holder;
19510b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>               __alloc_traits;
19520b57cec5SDimitry Andric    static_assert((is_same<typename __node_traits::size_type,
19530b57cec5SDimitry Andric                          typename __alloc_traits::size_type>::value),
19540b57cec5SDimitry Andric                 "Allocator uses different size_type for different types");
19550b57cec5SDimitry Andricpublic:
19560b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer         pointer;
19570b57cec5SDimitry Andric    typedef typename __alloc_traits::const_pointer   const_pointer;
19580b57cec5SDimitry Andric    typedef typename __table::size_type              size_type;
19590b57cec5SDimitry Andric    typedef typename __table::difference_type        difference_type;
19600b57cec5SDimitry Andric
19610b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::iterator>       iterator;
19620b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
19630b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
19640b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
19650b57cec5SDimitry Andric
19660b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
19670b57cec5SDimitry Andric    typedef __map_node_handle<__node, allocator_type> node_type;
19680b57cec5SDimitry Andric#endif
19690b57cec5SDimitry Andric
19700b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
19710b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_map;
19720b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
19730b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
19740b57cec5SDimitry Andric
19750b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19760b57cec5SDimitry Andric    unordered_multimap()
19770b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
19780b57cec5SDimitry Andric    {
197904eeddc0SDimitry Andric        _VSTD::__debug_db_insert_c(this);
19800b57cec5SDimitry Andric    }
19810b57cec5SDimitry Andric    explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(),
19820b57cec5SDimitry Andric                                const key_equal& __eql = key_equal());
19830b57cec5SDimitry Andric    unordered_multimap(size_type __n, const hasher& __hf,
19840b57cec5SDimitry Andric                                const key_equal& __eql,
19850b57cec5SDimitry Andric                                const allocator_type& __a);
19860b57cec5SDimitry Andric    template <class _InputIterator>
19870b57cec5SDimitry Andric        unordered_multimap(_InputIterator __first, _InputIterator __last);
19880b57cec5SDimitry Andric    template <class _InputIterator>
19890b57cec5SDimitry Andric        unordered_multimap(_InputIterator __first, _InputIterator __last,
19900b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
19910b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
19920b57cec5SDimitry Andric    template <class _InputIterator>
19930b57cec5SDimitry Andric        unordered_multimap(_InputIterator __first, _InputIterator __last,
19940b57cec5SDimitry Andric                      size_type __n, const hasher& __hf,
19950b57cec5SDimitry Andric                      const key_equal& __eql,
19960b57cec5SDimitry Andric                      const allocator_type& __a);
19970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
19980b57cec5SDimitry Andric    explicit unordered_multimap(const allocator_type& __a);
19990b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap& __u);
20000b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
20010b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
20020b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20030b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&& __u)
20040b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
20050b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
20060b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il);
20070b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n,
20080b57cec5SDimitry Andric                       const hasher& __hf = hasher(),
20090b57cec5SDimitry Andric                       const key_equal& __eql = key_equal());
20100b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n,
20110b57cec5SDimitry Andric                       const hasher& __hf, const key_equal& __eql,
20120b57cec5SDimitry Andric                       const allocator_type& __a);
20130b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
20140b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
20150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20160b57cec5SDimitry Andric    unordered_multimap(size_type __n, const allocator_type& __a)
20170b57cec5SDimitry Andric      : unordered_multimap(__n, hasher(), key_equal(), __a) {}
20180b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20190b57cec5SDimitry Andric    unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
20200b57cec5SDimitry Andric      : unordered_multimap(__n, __hf, key_equal(), __a) {}
20210b57cec5SDimitry Andric    template <class _InputIterator>
20220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20230b57cec5SDimitry Andric      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
20240b57cec5SDimitry Andric      : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
20250b57cec5SDimitry Andric    template <class _InputIterator>
20260b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20270b57cec5SDimitry Andric      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
20280b57cec5SDimitry Andric        const allocator_type& __a)
20290b57cec5SDimitry Andric      : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
20300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20310b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
20320b57cec5SDimitry Andric      : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
20330b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20340b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
20350b57cec5SDimitry Andric      const allocator_type& __a)
20360b57cec5SDimitry Andric      : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
20370b57cec5SDimitry Andric#endif
20380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20390b57cec5SDimitry Andric    ~unordered_multimap() {
20400b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
20410b57cec5SDimitry Andric    }
20420b57cec5SDimitry Andric
20430b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20440b57cec5SDimitry Andric    unordered_multimap& operator=(const unordered_multimap& __u)
20450b57cec5SDimitry Andric    {
20460b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
20470b57cec5SDimitry Andric        __table_ = __u.__table_;
20480b57cec5SDimitry Andric#else
2049349cc55cSDimitry Andric        if (this != _VSTD::addressof(__u)) {
20500b57cec5SDimitry Andric            __table_.clear();
20510b57cec5SDimitry Andric            __table_.hash_function() = __u.__table_.hash_function();
20520b57cec5SDimitry Andric            __table_.key_eq() = __u.__table_.key_eq();
20530b57cec5SDimitry Andric            __table_.max_load_factor() = __u.__table_.max_load_factor();
20540b57cec5SDimitry Andric            __table_.__copy_assign_alloc(__u.__table_);
20550b57cec5SDimitry Andric            insert(__u.begin(), __u.end());
20560b57cec5SDimitry Andric        }
20570b57cec5SDimitry Andric#endif
20580b57cec5SDimitry Andric        return *this;
20590b57cec5SDimitry Andric    }
20600b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
20610b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20620b57cec5SDimitry Andric    unordered_multimap& operator=(unordered_multimap&& __u)
20630b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
20640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20650b57cec5SDimitry Andric    unordered_multimap& operator=(initializer_list<value_type> __il);
20660b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
20670b57cec5SDimitry Andric
20680b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20690b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
20700b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
20710b57cec5SDimitry Andric
20720b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
20730b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
20740b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20750b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
20760b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20770b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
20780b57cec5SDimitry Andric
20790b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20800b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
20810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20820b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
20830b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20840b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
20850b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20860b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
20870b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20880b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
20890b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20900b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
20910b57cec5SDimitry Andric
20920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20930b57cec5SDimitry Andric    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
20940b57cec5SDimitry Andric
20950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
20960b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __x)
20970b57cec5SDimitry Andric        {return __table_.__insert_multi(__p.__i_, __x);}
20980b57cec5SDimitry Andric
20990b57cec5SDimitry Andric    template <class _InputIterator>
21000b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21010b57cec5SDimitry Andric    void insert(_InputIterator __first, _InputIterator __last);
21020b57cec5SDimitry Andric
21030b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
21040b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21050b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
21060b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
21070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21080b57cec5SDimitry Andric    iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
21090b57cec5SDimitry Andric
21100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21110b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __x)
21120b57cec5SDimitry Andric        {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));}
21130b57cec5SDimitry Andric
21140b57cec5SDimitry Andric    template <class _Pp,
2115*753f127fSDimitry Andric              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
21160b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21170b57cec5SDimitry Andric    iterator insert(_Pp&& __x)
21180b57cec5SDimitry Andric        {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
21190b57cec5SDimitry Andric
21200b57cec5SDimitry Andric    template <class _Pp,
2121*753f127fSDimitry Andric              class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
21220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21230b57cec5SDimitry Andric    iterator insert(const_iterator __p, _Pp&& __x)
21240b57cec5SDimitry Andric        {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
21250b57cec5SDimitry Andric
21260b57cec5SDimitry Andric    template <class... _Args>
21270b57cec5SDimitry Andric    iterator emplace(_Args&&... __args) {
21280b57cec5SDimitry Andric        return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
21290b57cec5SDimitry Andric    }
21300b57cec5SDimitry Andric
21310b57cec5SDimitry Andric    template <class... _Args>
21320b57cec5SDimitry Andric    iterator emplace_hint(const_iterator __p, _Args&&... __args) {
21330b57cec5SDimitry Andric        return __table_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
21340b57cec5SDimitry Andric    }
21350b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
21360b57cec5SDimitry Andric
21370b57cec5SDimitry Andric
21380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21390b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
21400b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21410b57cec5SDimitry Andric    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
21420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21430b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
21440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21450b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
21460b57cec5SDimitry Andric        {return __table_.erase(__first.__i_, __last.__i_);}
21470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21480b57cec5SDimitry Andric    void clear() _NOEXCEPT {__table_.clear();}
21490b57cec5SDimitry Andric
21500b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
21510b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21520b57cec5SDimitry Andric    iterator insert(node_type&& __nh)
21530b57cec5SDimitry Andric    {
21540b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
21550b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multimap::insert()");
21560b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
21570b57cec5SDimitry Andric            _VSTD::move(__nh));
21580b57cec5SDimitry Andric    }
21590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21600b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
21610b57cec5SDimitry Andric    {
21620b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
21630b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multimap::insert()");
21640b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
21650b57cec5SDimitry Andric            __hint.__i_, _VSTD::move(__nh));
21660b57cec5SDimitry Andric    }
21670b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21680b57cec5SDimitry Andric    node_type extract(key_type const& __key)
21690b57cec5SDimitry Andric    {
21700b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
21710b57cec5SDimitry Andric    }
21720b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21730b57cec5SDimitry Andric    node_type extract(const_iterator __it)
21740b57cec5SDimitry Andric    {
21750b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(
21760b57cec5SDimitry Andric            __it.__i_);
21770b57cec5SDimitry Andric    }
21780b57cec5SDimitry Andric
21790b57cec5SDimitry Andric    template <class _H2, class _P2>
21800b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21810b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
21820b57cec5SDimitry Andric    {
21830b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
21840b57cec5SDimitry Andric                       "merging container with incompatible allocator");
21850b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
21860b57cec5SDimitry Andric    }
21870b57cec5SDimitry Andric    template <class _H2, class _P2>
21880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21890b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
21900b57cec5SDimitry Andric    {
21910b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
21920b57cec5SDimitry Andric                       "merging container with incompatible allocator");
21930b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
21940b57cec5SDimitry Andric    }
21950b57cec5SDimitry Andric    template <class _H2, class _P2>
21960b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
21970b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
21980b57cec5SDimitry Andric    {
21990b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
22000b57cec5SDimitry Andric                       "merging container with incompatible allocator");
22010b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
22020b57cec5SDimitry Andric    }
22030b57cec5SDimitry Andric    template <class _H2, class _P2>
22040b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22050b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
22060b57cec5SDimitry Andric    {
22070b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
22080b57cec5SDimitry Andric                       "merging container with incompatible allocator");
22090b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
22100b57cec5SDimitry Andric    }
22110b57cec5SDimitry Andric#endif
22120b57cec5SDimitry Andric
22130b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22140b57cec5SDimitry Andric    void swap(unordered_multimap& __u)
22150b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
22160b57cec5SDimitry Andric        {__table_.swap(__u.__table_);}
22170b57cec5SDimitry Andric
22180b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22190b57cec5SDimitry Andric    hasher hash_function() const
22200b57cec5SDimitry Andric        {return __table_.hash_function().hash_function();}
22210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22220b57cec5SDimitry Andric    key_equal key_eq() const
22230b57cec5SDimitry Andric        {return __table_.key_eq().key_eq();}
22240b57cec5SDimitry Andric
22250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22260b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
22270b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22280b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
2229e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
2230349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2231e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2232349cc55cSDimitry Andric    iterator       find(const _K2& __k)            {return __table_.find(__k);}
2233349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2234e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2235349cc55cSDimitry Andric    const_iterator find(const _K2& __k) const      {return __table_.find(__k);}
2236e8d8bef9SDimitry Andric#endif // _LIBCPP_STD_VER > 17
2237349cc55cSDimitry Andric
22380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22390b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
22400b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
2241349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2242e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2243349cc55cSDimitry Andric    size_type count(const _K2& __k) const      {return __table_.__count_multi(__k);}
2244e8d8bef9SDimitry Andric#endif // _LIBCPP_STD_VER > 17
2245349cc55cSDimitry Andric
2246e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
22470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22480b57cec5SDimitry Andric    bool contains(const key_type& __k) const {return find(__k) != end();}
2249e8d8bef9SDimitry Andric
2250349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2251e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2252349cc55cSDimitry Andric    bool contains(const _K2& __k) const      {return find(__k) != end();}
22530b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 17
2254349cc55cSDimitry Andric
22550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22560b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
22570b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
22580b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22590b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
22600b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
2261e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 17
2262349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2263e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2264349cc55cSDimitry Andric    pair<iterator, iterator>             equal_range(const _K2& __k)
2265349cc55cSDimitry Andric        {return __table_.__equal_range_multi(__k);}
2266349cc55cSDimitry Andric    template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2267e8d8bef9SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2268349cc55cSDimitry Andric    pair<const_iterator, const_iterator> equal_range(const _K2& __k) const
2269349cc55cSDimitry Andric        {return __table_.__equal_range_multi(__k);}
2270e8d8bef9SDimitry Andric#endif // _LIBCPP_STD_VER > 17
22710b57cec5SDimitry Andric
22720b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22730b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
22740b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22750b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT
22760b57cec5SDimitry Andric        {return __table_.max_bucket_count();}
22770b57cec5SDimitry Andric
22780b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22790b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const
22800b57cec5SDimitry Andric        {return __table_.bucket_size(__n);}
22810b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22820b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
22830b57cec5SDimitry Andric
22840b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22850b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
22860b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22870b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
22880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22890b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
22900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22910b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
22920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22930b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
22940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22950b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
22960b57cec5SDimitry Andric
22970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
22980b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
22990b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23000b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
23010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
23020b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
23030b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2304*753f127fSDimitry Andric    void rehash(size_type __n) {__table_.__rehash_multi(__n);}
23050b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2306*753f127fSDimitry Andric    void reserve(size_type __n) {__table_.__reserve_multi(__n);}
23070b57cec5SDimitry Andric
230881ad6265SDimitry Andric#ifdef _LIBCPP_ENABLE_DEBUG_MODE
23090b57cec5SDimitry Andric
23100b57cec5SDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
2311349cc55cSDimitry Andric        {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));}
23120b57cec5SDimitry Andric    bool __decrementable(const const_iterator* __i) const
2313349cc55cSDimitry Andric        {return __table_.__decrementable(_VSTD::addressof(__i->__i_));}
23140b57cec5SDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
2315349cc55cSDimitry Andric        {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
23160b57cec5SDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
2317349cc55cSDimitry Andric        {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);}
23180b57cec5SDimitry Andric
231981ad6265SDimitry Andric#endif // _LIBCPP_ENABLE_DEBUG_MODE
23200b57cec5SDimitry Andric
23210b57cec5SDimitry Andric
23220b57cec5SDimitry Andric};
23230b57cec5SDimitry Andric
2324349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
23250b57cec5SDimitry Andrictemplate<class _InputIterator,
23260b57cec5SDimitry Andric         class _Hash = hash<__iter_key_type<_InputIterator>>,
23270b57cec5SDimitry Andric         class _Pred = equal_to<__iter_key_type<_InputIterator>>,
23280b57cec5SDimitry Andric         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
2329349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
2330349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
2331349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
2332349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Pred>::value>,
2333349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
23340b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
23350b57cec5SDimitry Andric                   _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
23360b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
23370b57cec5SDimitry Andric
23380b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>,
23390b57cec5SDimitry Andric         class _Pred = equal_to<remove_const_t<_Key>>,
23400b57cec5SDimitry Andric         class _Allocator = allocator<pair<const _Key, _Tp>>,
2341349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
2342349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
2343349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Pred>::value>,
2344349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
23450b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0,
23460b57cec5SDimitry Andric                   _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
23470b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
23480b57cec5SDimitry Andric
23490b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
2350349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
2351349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
23520b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
23530b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
23540b57cec5SDimitry Andric                        hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
23550b57cec5SDimitry Andric
23560b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
2357349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
2358349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
23590b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, _Allocator)
23600b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
23610b57cec5SDimitry Andric                        hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
23620b57cec5SDimitry Andric
23630b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
2364349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
2365349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
2366349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
2367349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
23680b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
23690b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
23700b57cec5SDimitry Andric                        _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
23710b57cec5SDimitry Andric
23720b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
2373349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
23740b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
23750b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp,
23760b57cec5SDimitry Andric                        hash<remove_const_t<_Key>>,
23770b57cec5SDimitry Andric                        equal_to<remove_const_t<_Key>>, _Allocator>;
23780b57cec5SDimitry Andric
23790b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
2380349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
23810b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
23820b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp,
23830b57cec5SDimitry Andric                        hash<remove_const_t<_Key>>,
23840b57cec5SDimitry Andric                        equal_to<remove_const_t<_Key>>, _Allocator>;
23850b57cec5SDimitry Andric
23860b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash, class _Allocator,
2387349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Hash>::value>,
2388349cc55cSDimitry Andric         class = enable_if_t<!is_integral<_Hash>::value>,
2389349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>>
23900b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
23910b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash,
23920b57cec5SDimitry Andric                        equal_to<remove_const_t<_Key>>, _Allocator>;
23930b57cec5SDimitry Andric#endif
23940b57cec5SDimitry Andric
23950b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
23960b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
23970b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql)
23980b57cec5SDimitry Andric    : __table_(__hf, __eql)
23990b57cec5SDimitry Andric{
240004eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
2401*753f127fSDimitry Andric    __table_.__rehash_multi(__n);
24020b57cec5SDimitry Andric}
24030b57cec5SDimitry Andric
24040b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24050b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24060b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql,
24070b57cec5SDimitry Andric        const allocator_type& __a)
24080b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
24090b57cec5SDimitry Andric{
241004eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
2411*753f127fSDimitry Andric    __table_.__rehash_multi(__n);
24120b57cec5SDimitry Andric}
24130b57cec5SDimitry Andric
24140b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24150b57cec5SDimitry Andrictemplate <class _InputIterator>
24160b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24170b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
24180b57cec5SDimitry Andric{
241904eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
24200b57cec5SDimitry Andric    insert(__first, __last);
24210b57cec5SDimitry Andric}
24220b57cec5SDimitry Andric
24230b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24240b57cec5SDimitry Andrictemplate <class _InputIterator>
24250b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24260b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
24270b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
24280b57cec5SDimitry Andric    : __table_(__hf, __eql)
24290b57cec5SDimitry Andric{
243004eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
2431*753f127fSDimitry Andric    __table_.__rehash_multi(__n);
24320b57cec5SDimitry Andric    insert(__first, __last);
24330b57cec5SDimitry Andric}
24340b57cec5SDimitry Andric
24350b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24360b57cec5SDimitry Andrictemplate <class _InputIterator>
24370b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24380b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
24390b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
24400b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
24410b57cec5SDimitry Andric{
244204eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
2443*753f127fSDimitry Andric    __table_.__rehash_multi(__n);
24440b57cec5SDimitry Andric    insert(__first, __last);
24450b57cec5SDimitry Andric}
24460b57cec5SDimitry Andric
24470b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24480b57cec5SDimitry Andricinline
24490b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24500b57cec5SDimitry Andric        const allocator_type& __a)
24510b57cec5SDimitry Andric    : __table_(typename __table::allocator_type(__a))
24520b57cec5SDimitry Andric{
245304eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
24540b57cec5SDimitry Andric}
24550b57cec5SDimitry Andric
24560b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24570b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24580b57cec5SDimitry Andric        const unordered_multimap& __u)
24590b57cec5SDimitry Andric    : __table_(__u.__table_)
24600b57cec5SDimitry Andric{
246104eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
2462*753f127fSDimitry Andric    __table_.__rehash_multi(__u.bucket_count());
24630b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
24640b57cec5SDimitry Andric}
24650b57cec5SDimitry Andric
24660b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24670b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24680b57cec5SDimitry Andric        const unordered_multimap& __u, const allocator_type& __a)
24690b57cec5SDimitry Andric    : __table_(__u.__table_, typename __table::allocator_type(__a))
24700b57cec5SDimitry Andric{
247104eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
2472*753f127fSDimitry Andric    __table_.__rehash_multi(__u.bucket_count());
24730b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
24740b57cec5SDimitry Andric}
24750b57cec5SDimitry Andric
24760b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
24770b57cec5SDimitry Andric
24780b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24790b57cec5SDimitry Andricinline
24800b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24810b57cec5SDimitry Andric        unordered_multimap&& __u)
24820b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
24830b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
24840b57cec5SDimitry Andric{
248504eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
248681ad6265SDimitry Andric    std::__debug_db_swap(this, std::addressof(__u));
24870b57cec5SDimitry Andric}
24880b57cec5SDimitry Andric
24890b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
24900b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
24910b57cec5SDimitry Andric        unordered_multimap&& __u, const allocator_type& __a)
24920b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
24930b57cec5SDimitry Andric{
249404eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
24950b57cec5SDimitry Andric    if (__a != __u.get_allocator())
24960b57cec5SDimitry Andric    {
24970b57cec5SDimitry Andric        iterator __i = __u.begin();
24980b57cec5SDimitry Andric        while (__u.size() != 0)
24990b57cec5SDimitry Andric        {
25000b57cec5SDimitry Andric            __table_.__insert_multi(
25010b57cec5SDimitry Andric                __u.__table_.remove((__i++).__i_)->__value_.__move());
25020b57cec5SDimitry Andric        }
25030b57cec5SDimitry Andric    }
25040b57cec5SDimitry Andric    else
250581ad6265SDimitry Andric        std::__debug_db_swap(this, std::addressof(__u));
25060b57cec5SDimitry Andric}
25070b57cec5SDimitry Andric
25080b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25090b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
25100b57cec5SDimitry Andric        initializer_list<value_type> __il)
25110b57cec5SDimitry Andric{
251204eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
25130b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
25140b57cec5SDimitry Andric}
25150b57cec5SDimitry Andric
25160b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25170b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
25180b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
25190b57cec5SDimitry Andric        const key_equal& __eql)
25200b57cec5SDimitry Andric    : __table_(__hf, __eql)
25210b57cec5SDimitry Andric{
252204eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
2523*753f127fSDimitry Andric    __table_.__rehash_multi(__n);
25240b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
25250b57cec5SDimitry Andric}
25260b57cec5SDimitry Andric
25270b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25280b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
25290b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
25300b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
25310b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
25320b57cec5SDimitry Andric{
253304eeddc0SDimitry Andric    _VSTD::__debug_db_insert_c(this);
2534*753f127fSDimitry Andric    __table_.__rehash_multi(__n);
25350b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
25360b57cec5SDimitry Andric}
25370b57cec5SDimitry Andric
25380b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25390b57cec5SDimitry Andricinline
25400b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
25410b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
25420b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
25430b57cec5SDimitry Andric{
25440b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
25450b57cec5SDimitry Andric    return *this;
25460b57cec5SDimitry Andric}
25470b57cec5SDimitry Andric
25480b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25490b57cec5SDimitry Andricinline
25500b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
25510b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
25520b57cec5SDimitry Andric        initializer_list<value_type> __il)
25530b57cec5SDimitry Andric{
25540b57cec5SDimitry Andric    __table_.__assign_multi(__il.begin(), __il.end());
25550b57cec5SDimitry Andric    return *this;
25560b57cec5SDimitry Andric}
25570b57cec5SDimitry Andric
25580b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
25590b57cec5SDimitry Andric
25600b57cec5SDimitry Andric
25610b57cec5SDimitry Andric
25620b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25630b57cec5SDimitry Andrictemplate <class _InputIterator>
25640b57cec5SDimitry Andricinline
25650b57cec5SDimitry Andricvoid
25660b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
25670b57cec5SDimitry Andric                                                            _InputIterator __last)
25680b57cec5SDimitry Andric{
25690b57cec5SDimitry Andric    for (; __first != __last; ++__first)
25700b57cec5SDimitry Andric        __table_.__insert_multi(*__first);
25710b57cec5SDimitry Andric}
25720b57cec5SDimitry Andric
25730b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25740b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
25750b57cec5SDimitry Andricvoid
25760b57cec5SDimitry Andricswap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
25770b57cec5SDimitry Andric     unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
25780b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
25790b57cec5SDimitry Andric{
25800b57cec5SDimitry Andric    __x.swap(__y);
25810b57cec5SDimitry Andric}
25820b57cec5SDimitry Andric
25830b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
25845ffd83dbSDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
25855ffd83dbSDimitry Andric          class _Predicate>
25860b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
25875ffd83dbSDimitry Andric    typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
25885ffd83dbSDimitry Andric    erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c,
25895ffd83dbSDimitry Andric             _Predicate __pred) {
2590fe6060f1SDimitry Andric  return _VSTD::__libcpp_erase_if_container(__c, __pred);
25915ffd83dbSDimitry Andric}
25920b57cec5SDimitry Andric#endif
25930b57cec5SDimitry Andric
25940b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
25950b57cec5SDimitry Andricbool
25960b57cec5SDimitry Andricoperator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
25970b57cec5SDimitry Andric           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
25980b57cec5SDimitry Andric{
25990b57cec5SDimitry Andric    if (__x.size() != __y.size())
26000b57cec5SDimitry Andric        return false;
26010b57cec5SDimitry Andric    typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
26020b57cec5SDimitry Andric                                                                 const_iterator;
26030b57cec5SDimitry Andric    typedef pair<const_iterator, const_iterator> _EqRng;
26040b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
26050b57cec5SDimitry Andric    {
26060b57cec5SDimitry Andric        _EqRng __xeq = __x.equal_range(__i->first);
26070b57cec5SDimitry Andric        _EqRng __yeq = __y.equal_range(__i->first);
26080b57cec5SDimitry Andric        if (_VSTD::distance(__xeq.first, __xeq.second) !=
26090b57cec5SDimitry Andric            _VSTD::distance(__yeq.first, __yeq.second) ||
26100b57cec5SDimitry Andric                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
26110b57cec5SDimitry Andric            return false;
26120b57cec5SDimitry Andric        __i = __xeq.second;
26130b57cec5SDimitry Andric    }
26140b57cec5SDimitry Andric    return true;
26150b57cec5SDimitry Andric}
26160b57cec5SDimitry Andric
26170b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
26180b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
26190b57cec5SDimitry Andricbool
26200b57cec5SDimitry Andricoperator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
26210b57cec5SDimitry Andric           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
26220b57cec5SDimitry Andric{
26230b57cec5SDimitry Andric    return !(__x == __y);
26240b57cec5SDimitry Andric}
26250b57cec5SDimitry Andric
26260b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
26270b57cec5SDimitry Andric
26280b57cec5SDimitry Andric#endif // _LIBCPP_UNORDERED_MAP
2629