13e519524SHoward Hinnant// -*- C++ -*-
23e519524SHoward Hinnant//===-------------------------- unordered_map -----------------------------===//
33e519524SHoward Hinnant//
45b08a8a4SHoward Hinnant//                     The LLVM Compiler Infrastructure
53e519524SHoward Hinnant//
6412dbebeSHoward Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
7412dbebeSHoward Hinnant// Source Licenses. See LICENSE.TXT for details.
83e519524SHoward Hinnant//
93e519524SHoward Hinnant//===----------------------------------------------------------------------===//
103e519524SHoward Hinnant
113e519524SHoward Hinnant#ifndef _LIBCPP_UNORDERED_MAP
123e519524SHoward Hinnant#define _LIBCPP_UNORDERED_MAP
133e519524SHoward Hinnant
143e519524SHoward Hinnant/*
153e519524SHoward Hinnant
163e519524SHoward Hinnant    unordered_map synopsis
173e519524SHoward Hinnant
183e519524SHoward Hinnant#include <initializer_list>
193e519524SHoward Hinnant
203e519524SHoward Hinnantnamespace std
213e519524SHoward Hinnant{
223e519524SHoward Hinnant
233e519524SHoward Hinnanttemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
243e519524SHoward Hinnant          class Alloc = allocator<pair<const Key, T>>>
253e519524SHoward Hinnantclass unordered_map
263e519524SHoward Hinnant{
273e519524SHoward Hinnantpublic:
283e519524SHoward Hinnant    // types
293e519524SHoward Hinnant    typedef Key                                                        key_type;
303e519524SHoward Hinnant    typedef T                                                          mapped_type;
313e519524SHoward Hinnant    typedef Hash                                                       hasher;
323e519524SHoward Hinnant    typedef Pred                                                       key_equal;
333e519524SHoward Hinnant    typedef Alloc                                                      allocator_type;
343e519524SHoward Hinnant    typedef pair<const key_type, mapped_type>                          value_type;
353e519524SHoward Hinnant    typedef value_type&                                                reference;
363e519524SHoward Hinnant    typedef const value_type&                                          const_reference;
373e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::pointer         pointer;
383e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
393e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::size_type       size_type;
403e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
413e519524SHoward Hinnant
423e519524SHoward Hinnant    typedef /unspecified/ iterator;
433e519524SHoward Hinnant    typedef /unspecified/ const_iterator;
443e519524SHoward Hinnant    typedef /unspecified/ local_iterator;
453e519524SHoward Hinnant    typedef /unspecified/ const_local_iterator;
463e519524SHoward Hinnant
473714107eSHoward Hinnant    unordered_map()
483714107eSHoward Hinnant        noexcept(
493714107eSHoward Hinnant            is_nothrow_default_constructible<hasher>::value &&
503714107eSHoward Hinnant            is_nothrow_default_constructible<key_equal>::value &&
513714107eSHoward Hinnant            is_nothrow_default_constructible<allocator_type>::value);
523714107eSHoward Hinnant    explicit unordered_map(size_type n, const hasher& hf = hasher(),
533e519524SHoward Hinnant                           const key_equal& eql = key_equal(),
543e519524SHoward Hinnant                           const allocator_type& a = allocator_type());
553e519524SHoward Hinnant    template <class InputIterator>
563e519524SHoward Hinnant        unordered_map(InputIterator f, InputIterator l,
573e519524SHoward Hinnant                      size_type n = 0, const hasher& hf = hasher(),
583e519524SHoward Hinnant                      const key_equal& eql = key_equal(),
593e519524SHoward Hinnant                      const allocator_type& a = allocator_type());
603e519524SHoward Hinnant    explicit unordered_map(const allocator_type&);
613e519524SHoward Hinnant    unordered_map(const unordered_map&);
623e519524SHoward Hinnant    unordered_map(const unordered_map&, const Allocator&);
633714107eSHoward Hinnant    unordered_map(unordered_map&&)
643714107eSHoward Hinnant        noexcept(
653714107eSHoward Hinnant            is_nothrow_move_constructible<hasher>::value &&
663714107eSHoward Hinnant            is_nothrow_move_constructible<key_equal>::value &&
673714107eSHoward Hinnant            is_nothrow_move_constructible<allocator_type>::value);
683e519524SHoward Hinnant    unordered_map(unordered_map&&, const Allocator&);
693e519524SHoward Hinnant    unordered_map(initializer_list<value_type>, size_type n = 0,
703e519524SHoward Hinnant                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
713e519524SHoward Hinnant                  const allocator_type& a = allocator_type());
72*3cd37e64SMarshall Clow    unordered_map(size_type n, const allocator_type& a)
73*3cd37e64SMarshall Clow      : unordered_map(n, hasher(), key_equal(), a) {}  // C++14
74*3cd37e64SMarshall Clow    unordered_map(size_type n, const hasher& hf, const allocator_type& a)
75*3cd37e64SMarshall Clow      : unordered_map(n, hf, key_equal(), a) {}  // C++14
76*3cd37e64SMarshall Clow    template <class InputIterator>
77*3cd37e64SMarshall Clow      unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
78*3cd37e64SMarshall Clow      : unordered_map(f, l, n, hasher(), key_equal(), a) {}  // C++14
79*3cd37e64SMarshall Clow    template <class InputIterator>
80*3cd37e64SMarshall Clow      unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
81*3cd37e64SMarshall Clow        const allocator_type& a)
82*3cd37e64SMarshall Clow      : unordered_map(f, l, n, hf, key_equal(), a) {}  // C++14
83*3cd37e64SMarshall Clow    unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
84*3cd37e64SMarshall Clow      : unordered_map(il, n, hasher(), key_equal(), a) {}  // C++14
85*3cd37e64SMarshall Clow    unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
86*3cd37e64SMarshall Clow      const allocator_type& a)
87*3cd37e64SMarshall Clow      : unordered_map(il, n, hf, key_equal(), a) {}  // C++14
883e519524SHoward Hinnant    ~unordered_map();
893e519524SHoward Hinnant    unordered_map& operator=(const unordered_map&);
903714107eSHoward Hinnant    unordered_map& operator=(unordered_map&&)
913714107eSHoward Hinnant        noexcept(
923714107eSHoward Hinnant            allocator_type::propagate_on_container_move_assignment::value &&
933714107eSHoward Hinnant            is_nothrow_move_assignable<allocator_type>::value &&
943714107eSHoward Hinnant            is_nothrow_move_assignable<hasher>::value &&
953714107eSHoward Hinnant            is_nothrow_move_assignable<key_equal>::value);
963e519524SHoward Hinnant    unordered_map& operator=(initializer_list<value_type>);
973e519524SHoward Hinnant
983714107eSHoward Hinnant    allocator_type get_allocator() const noexcept;
993e519524SHoward Hinnant
1003714107eSHoward Hinnant    bool      empty() const noexcept;
1013714107eSHoward Hinnant    size_type size() const noexcept;
1023714107eSHoward Hinnant    size_type max_size() const noexcept;
1033e519524SHoward Hinnant
1043714107eSHoward Hinnant    iterator       begin() noexcept;
1053714107eSHoward Hinnant    iterator       end() noexcept;
1063714107eSHoward Hinnant    const_iterator begin()  const noexcept;
1073714107eSHoward Hinnant    const_iterator end()    const noexcept;
1083714107eSHoward Hinnant    const_iterator cbegin() const noexcept;
1093714107eSHoward Hinnant    const_iterator cend()   const noexcept;
1103e519524SHoward Hinnant
1113e519524SHoward Hinnant    template <class... Args>
1123e519524SHoward Hinnant        pair<iterator, bool> emplace(Args&&... args);
1133e519524SHoward Hinnant    template <class... Args>
1143e519524SHoward Hinnant        iterator emplace_hint(const_iterator position, Args&&... args);
1153e519524SHoward Hinnant    pair<iterator, bool> insert(const value_type& obj);
1163e519524SHoward Hinnant    template <class P>
1173e519524SHoward Hinnant        pair<iterator, bool> insert(P&& obj);
1183e519524SHoward Hinnant    iterator insert(const_iterator hint, const value_type& obj);
1193e519524SHoward Hinnant    template <class P>
1203e519524SHoward Hinnant        iterator insert(const_iterator hint, P&& obj);
1213e519524SHoward Hinnant    template <class InputIterator>
1223e519524SHoward Hinnant        void insert(InputIterator first, InputIterator last);
1233e519524SHoward Hinnant    void insert(initializer_list<value_type>);
1243e519524SHoward Hinnant
1253e519524SHoward Hinnant    iterator erase(const_iterator position);
1263e519524SHoward Hinnant    size_type erase(const key_type& k);
1273e519524SHoward Hinnant    iterator erase(const_iterator first, const_iterator last);
1283714107eSHoward Hinnant    void clear() noexcept;
1293e519524SHoward Hinnant
1303714107eSHoward Hinnant    void swap(unordered_map&)
1313714107eSHoward Hinnant        noexcept(
1323714107eSHoward Hinnant            (!allocator_type::propagate_on_container_swap::value ||
1333714107eSHoward Hinnant             __is_nothrow_swappable<allocator_type>::value) &&
1343714107eSHoward Hinnant            __is_nothrow_swappable<hasher>::value &&
1353714107eSHoward Hinnant            __is_nothrow_swappable<key_equal>::value);
1363e519524SHoward Hinnant
1373e519524SHoward Hinnant    hasher hash_function() const;
1383e519524SHoward Hinnant    key_equal key_eq() const;
1393e519524SHoward Hinnant
1403e519524SHoward Hinnant    iterator       find(const key_type& k);
1413e519524SHoward Hinnant    const_iterator find(const key_type& k) const;
1423e519524SHoward Hinnant    size_type count(const key_type& k) const;
1433e519524SHoward Hinnant    pair<iterator, iterator>             equal_range(const key_type& k);
1443e519524SHoward Hinnant    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
1453e519524SHoward Hinnant
1463e519524SHoward Hinnant    mapped_type& operator[](const key_type& k);
1473e519524SHoward Hinnant    mapped_type& operator[](key_type&& k);
1483e519524SHoward Hinnant
1493e519524SHoward Hinnant    mapped_type&       at(const key_type& k);
1503e519524SHoward Hinnant    const mapped_type& at(const key_type& k) const;
1513e519524SHoward Hinnant
1523714107eSHoward Hinnant    size_type bucket_count() const noexcept;
1533714107eSHoward Hinnant    size_type max_bucket_count() const noexcept;
1543e519524SHoward Hinnant
1553e519524SHoward Hinnant    size_type bucket_size(size_type n) const;
1563e519524SHoward Hinnant    size_type bucket(const key_type& k) const;
1573e519524SHoward Hinnant
1583e519524SHoward Hinnant    local_iterator       begin(size_type n);
1593e519524SHoward Hinnant    local_iterator       end(size_type n);
1603e519524SHoward Hinnant    const_local_iterator begin(size_type n) const;
1613e519524SHoward Hinnant    const_local_iterator end(size_type n) const;
1623e519524SHoward Hinnant    const_local_iterator cbegin(size_type n) const;
1633e519524SHoward Hinnant    const_local_iterator cend(size_type n) const;
1643e519524SHoward Hinnant
1653714107eSHoward Hinnant    float load_factor() const noexcept;
1663714107eSHoward Hinnant    float max_load_factor() const noexcept;
1673e519524SHoward Hinnant    void max_load_factor(float z);
1683e519524SHoward Hinnant    void rehash(size_type n);
1693e519524SHoward Hinnant    void reserve(size_type n);
1703e519524SHoward Hinnant};
1713e519524SHoward Hinnant
1723e519524SHoward Hinnanttemplate <class Key, class T, class Hash, class Pred, class Alloc>
1733e519524SHoward Hinnant    void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
1743714107eSHoward Hinnant              unordered_map<Key, T, Hash, Pred, Alloc>& y)
1753714107eSHoward Hinnant              noexcept(noexcept(x.swap(y)));
1763e519524SHoward Hinnant
1773e519524SHoward Hinnanttemplate <class Key, class T, class Hash, class Pred, class Alloc>
1783e519524SHoward Hinnant    bool
1793e519524SHoward Hinnant    operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
1803e519524SHoward Hinnant               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
1813e519524SHoward Hinnant
1823e519524SHoward Hinnanttemplate <class Key, class T, class Hash, class Pred, class Alloc>
1833e519524SHoward Hinnant    bool
1843e519524SHoward Hinnant    operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
1853e519524SHoward Hinnant               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
1863e519524SHoward Hinnant
1873e519524SHoward Hinnanttemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
1883e519524SHoward Hinnant          class Alloc = allocator<pair<const Key, T>>>
1893e519524SHoward Hinnantclass unordered_multimap
1903e519524SHoward Hinnant{
1913e519524SHoward Hinnantpublic:
1923e519524SHoward Hinnant    // types
1933e519524SHoward Hinnant    typedef Key                                                        key_type;
1943e519524SHoward Hinnant    typedef T                                                          mapped_type;
1953e519524SHoward Hinnant    typedef Hash                                                       hasher;
1963e519524SHoward Hinnant    typedef Pred                                                       key_equal;
1973e519524SHoward Hinnant    typedef Alloc                                                      allocator_type;
1983e519524SHoward Hinnant    typedef pair<const key_type, mapped_type>                          value_type;
1993e519524SHoward Hinnant    typedef value_type&                                                reference;
2003e519524SHoward Hinnant    typedef const value_type&                                          const_reference;
2013e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::pointer         pointer;
2023e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
2033e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::size_type       size_type;
2043e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
2053e519524SHoward Hinnant
2063e519524SHoward Hinnant    typedef /unspecified/ iterator;
2073e519524SHoward Hinnant    typedef /unspecified/ const_iterator;
2083e519524SHoward Hinnant    typedef /unspecified/ local_iterator;
2093e519524SHoward Hinnant    typedef /unspecified/ const_local_iterator;
2103e519524SHoward Hinnant
2113714107eSHoward Hinnant    unordered_multimap()
2123714107eSHoward Hinnant        noexcept(
2133714107eSHoward Hinnant            is_nothrow_default_constructible<hasher>::value &&
2143714107eSHoward Hinnant            is_nothrow_default_constructible<key_equal>::value &&
2153714107eSHoward Hinnant            is_nothrow_default_constructible<allocator_type>::value);
2163714107eSHoward Hinnant    explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
2173e519524SHoward Hinnant                           const key_equal& eql = key_equal(),
2183e519524SHoward Hinnant                           const allocator_type& a = allocator_type());
2193e519524SHoward Hinnant    template <class InputIterator>
2203e519524SHoward Hinnant        unordered_multimap(InputIterator f, InputIterator l,
2213e519524SHoward Hinnant                      size_type n = 0, const hasher& hf = hasher(),
2223e519524SHoward Hinnant                      const key_equal& eql = key_equal(),
2233e519524SHoward Hinnant                      const allocator_type& a = allocator_type());
2243e519524SHoward Hinnant    explicit unordered_multimap(const allocator_type&);
2253e519524SHoward Hinnant    unordered_multimap(const unordered_multimap&);
2263e519524SHoward Hinnant    unordered_multimap(const unordered_multimap&, const Allocator&);
2273714107eSHoward Hinnant    unordered_multimap(unordered_multimap&&)
2283714107eSHoward Hinnant        noexcept(
2293714107eSHoward Hinnant            is_nothrow_move_constructible<hasher>::value &&
2303714107eSHoward Hinnant            is_nothrow_move_constructible<key_equal>::value &&
2313714107eSHoward Hinnant            is_nothrow_move_constructible<allocator_type>::value);
2323e519524SHoward Hinnant    unordered_multimap(unordered_multimap&&, const Allocator&);
2333e519524SHoward Hinnant    unordered_multimap(initializer_list<value_type>, size_type n = 0,
2343e519524SHoward Hinnant                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
2353e519524SHoward Hinnant                  const allocator_type& a = allocator_type());
236*3cd37e64SMarshall Clow    unordered_multimap(size_type n, const allocator_type& a)
237*3cd37e64SMarshall Clow      : unordered_multimap(n, hasher(), key_equal(), a) {}  // C++14
238*3cd37e64SMarshall Clow    unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
239*3cd37e64SMarshall Clow      : unordered_multimap(n, hf, key_equal(), a) {}  // C++14
240*3cd37e64SMarshall Clow    template <class InputIterator>
241*3cd37e64SMarshall Clow      unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
242*3cd37e64SMarshall Clow      : unordered_multimap(f, l, n, hasher(), key_equal(), a) {}  // C++14
243*3cd37e64SMarshall Clow    template <class InputIterator>
244*3cd37e64SMarshall Clow      unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
245*3cd37e64SMarshall Clow        const allocator_type& a)
246*3cd37e64SMarshall Clow      : unordered_multimap(f, l, n, hf, key_equal(), a) {}  // C++14
247*3cd37e64SMarshall Clow    unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
248*3cd37e64SMarshall Clow      : unordered_multimap(il, n, hasher(), key_equal(), a) {}  // C++14
249*3cd37e64SMarshall Clow    unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
250*3cd37e64SMarshall Clow      const allocator_type& a)
251*3cd37e64SMarshall Clow      : unordered_multimap(il, n, hf, key_equal(), a) {}  // C++14
2523e519524SHoward Hinnant    ~unordered_multimap();
2533e519524SHoward Hinnant    unordered_multimap& operator=(const unordered_multimap&);
2543714107eSHoward Hinnant    unordered_multimap& operator=(unordered_multimap&&)
2553714107eSHoward Hinnant        noexcept(
2563714107eSHoward Hinnant            allocator_type::propagate_on_container_move_assignment::value &&
2573714107eSHoward Hinnant            is_nothrow_move_assignable<allocator_type>::value &&
2583714107eSHoward Hinnant            is_nothrow_move_assignable<hasher>::value &&
2593714107eSHoward Hinnant            is_nothrow_move_assignable<key_equal>::value);
2603e519524SHoward Hinnant    unordered_multimap& operator=(initializer_list<value_type>);
2613e519524SHoward Hinnant
2623714107eSHoward Hinnant    allocator_type get_allocator() const noexcept;
2633e519524SHoward Hinnant
2643714107eSHoward Hinnant    bool      empty() const noexcept;
2653714107eSHoward Hinnant    size_type size() const noexcept;
2663714107eSHoward Hinnant    size_type max_size() const noexcept;
2673e519524SHoward Hinnant
2683714107eSHoward Hinnant    iterator       begin() noexcept;
2693714107eSHoward Hinnant    iterator       end() noexcept;
2703714107eSHoward Hinnant    const_iterator begin()  const noexcept;
2713714107eSHoward Hinnant    const_iterator end()    const noexcept;
2723714107eSHoward Hinnant    const_iterator cbegin() const noexcept;
2733714107eSHoward Hinnant    const_iterator cend()   const noexcept;
2743e519524SHoward Hinnant
2753e519524SHoward Hinnant    template <class... Args>
2763e519524SHoward Hinnant        iterator emplace(Args&&... args);
2773e519524SHoward Hinnant    template <class... Args>
2783e519524SHoward Hinnant        iterator emplace_hint(const_iterator position, Args&&... args);
2793e519524SHoward Hinnant    iterator insert(const value_type& obj);
2803e519524SHoward Hinnant    template <class P>
2813e519524SHoward Hinnant        iterator insert(P&& obj);
2823e519524SHoward Hinnant    iterator insert(const_iterator hint, const value_type& obj);
2833e519524SHoward Hinnant    template <class P>
2843e519524SHoward Hinnant        iterator insert(const_iterator hint, P&& obj);
2853e519524SHoward Hinnant    template <class InputIterator>
2863e519524SHoward Hinnant        void insert(InputIterator first, InputIterator last);
2873e519524SHoward Hinnant    void insert(initializer_list<value_type>);
2883e519524SHoward Hinnant
2893e519524SHoward Hinnant    iterator erase(const_iterator position);
2903e519524SHoward Hinnant    size_type erase(const key_type& k);
2913e519524SHoward Hinnant    iterator erase(const_iterator first, const_iterator last);
2923714107eSHoward Hinnant    void clear() noexcept;
2933e519524SHoward Hinnant
2943714107eSHoward Hinnant    void swap(unordered_multimap&)
2953714107eSHoward Hinnant        noexcept(
2963714107eSHoward Hinnant            (!allocator_type::propagate_on_container_swap::value ||
2973714107eSHoward Hinnant             __is_nothrow_swappable<allocator_type>::value) &&
2983714107eSHoward Hinnant            __is_nothrow_swappable<hasher>::value &&
2993714107eSHoward Hinnant            __is_nothrow_swappable<key_equal>::value);
3003e519524SHoward Hinnant
3013e519524SHoward Hinnant    hasher hash_function() const;
3023e519524SHoward Hinnant    key_equal key_eq() const;
3033e519524SHoward Hinnant
3043e519524SHoward Hinnant    iterator       find(const key_type& k);
3053e519524SHoward Hinnant    const_iterator find(const key_type& k) const;
3063e519524SHoward Hinnant    size_type count(const key_type& k) const;
3073e519524SHoward Hinnant    pair<iterator, iterator>             equal_range(const key_type& k);
3083e519524SHoward Hinnant    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
3093e519524SHoward Hinnant
3103714107eSHoward Hinnant    size_type bucket_count() const noexcept;
3113714107eSHoward Hinnant    size_type max_bucket_count() const noexcept;
3123e519524SHoward Hinnant
3133e519524SHoward Hinnant    size_type bucket_size(size_type n) const;
3143e519524SHoward Hinnant    size_type bucket(const key_type& k) const;
3153e519524SHoward Hinnant
3163e519524SHoward Hinnant    local_iterator       begin(size_type n);
3173e519524SHoward Hinnant    local_iterator       end(size_type n);
3183e519524SHoward Hinnant    const_local_iterator begin(size_type n) const;
3193e519524SHoward Hinnant    const_local_iterator end(size_type n) const;
3203e519524SHoward Hinnant    const_local_iterator cbegin(size_type n) const;
3213e519524SHoward Hinnant    const_local_iterator cend(size_type n) const;
3223e519524SHoward Hinnant
3233714107eSHoward Hinnant    float load_factor() const noexcept;
3243714107eSHoward Hinnant    float max_load_factor() const noexcept;
3253e519524SHoward Hinnant    void max_load_factor(float z);
3263e519524SHoward Hinnant    void rehash(size_type n);
3273e519524SHoward Hinnant    void reserve(size_type n);
3283e519524SHoward Hinnant};
3293e519524SHoward Hinnant
3303e519524SHoward Hinnanttemplate <class Key, class T, class Hash, class Pred, class Alloc>
3313e519524SHoward Hinnant    void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
3323714107eSHoward Hinnant              unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
3333714107eSHoward Hinnant              noexcept(noexcept(x.swap(y)));
3343e519524SHoward Hinnant
3353e519524SHoward Hinnanttemplate <class Key, class T, class Hash, class Pred, class Alloc>
3363e519524SHoward Hinnant    bool
3373e519524SHoward Hinnant    operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
3383e519524SHoward Hinnant               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
3393e519524SHoward Hinnant
3403e519524SHoward Hinnanttemplate <class Key, class T, class Hash, class Pred, class Alloc>
3413e519524SHoward Hinnant    bool
3423e519524SHoward Hinnant    operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
3433e519524SHoward Hinnant               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
3443e519524SHoward Hinnant
3453e519524SHoward Hinnant}  // std
3463e519524SHoward Hinnant
3473e519524SHoward Hinnant*/
3483e519524SHoward Hinnant
3493e519524SHoward Hinnant#include <__config>
3503e519524SHoward Hinnant#include <__hash_table>
3513e519524SHoward Hinnant#include <functional>
3523e519524SHoward Hinnant#include <stdexcept>
3533e519524SHoward Hinnant
354073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3553e519524SHoward Hinnant#pragma GCC system_header
356073458b1SHoward Hinnant#endif
3573e519524SHoward Hinnant
3583e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD
3593e519524SHoward Hinnant
360abb160e6SHoward Hinnanttemplate <class _Key, class _Cp, class _Hash, bool = is_empty<_Hash>::value
36142b8bb50SHoward Hinnant#if __has_feature(is_final)
36242b8bb50SHoward Hinnant                                         && !__is_final(_Hash)
36342b8bb50SHoward Hinnant#endif
36442b8bb50SHoward Hinnant         >
3653e519524SHoward Hinnantclass __unordered_map_hasher
3663e519524SHoward Hinnant    : private _Hash
3673e519524SHoward Hinnant{
3683e519524SHoward Hinnantpublic:
369789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3703714107eSHoward Hinnant    __unordered_map_hasher()
3713714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
3723714107eSHoward Hinnant        : _Hash() {}
373789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3743714107eSHoward Hinnant    __unordered_map_hasher(const _Hash& __h)
3753714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
3763714107eSHoward Hinnant        : _Hash(__h) {}
377789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3783714107eSHoward Hinnant    const _Hash& hash_function() const _NOEXCEPT {return *this;}
379789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
380a1a9e771SHoward Hinnant    size_t operator()(const _Cp& __x) const
381abb160e6SHoward Hinnant        {return static_cast<const _Hash&>(*this)(__x.__cc.first);}
382a1a9e771SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
383a1a9e771SHoward Hinnant    size_t operator()(const _Key& __x) const
3843e519524SHoward Hinnant        {return static_cast<const _Hash&>(*this)(__x);}
3853e519524SHoward Hinnant};
3863e519524SHoward Hinnant
387abb160e6SHoward Hinnanttemplate <class _Key, class _Cp, class _Hash>
388abb160e6SHoward Hinnantclass __unordered_map_hasher<_Key, _Cp, _Hash, false>
3893e519524SHoward Hinnant{
3903e519524SHoward Hinnant    _Hash __hash_;
391a1a9e771SHoward Hinnant
3923e519524SHoward Hinnantpublic:
393789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3943714107eSHoward Hinnant    __unordered_map_hasher()
3953714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
3963714107eSHoward Hinnant        : __hash_() {}
397789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3983714107eSHoward Hinnant    __unordered_map_hasher(const _Hash& __h)
3993714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
4003714107eSHoward Hinnant        : __hash_(__h) {}
401789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4023714107eSHoward Hinnant    const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
403789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
404a1a9e771SHoward Hinnant    size_t operator()(const _Cp& __x) const
405abb160e6SHoward Hinnant        {return __hash_(__x.__cc.first);}
406a1a9e771SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
407a1a9e771SHoward Hinnant    size_t operator()(const _Key& __x) const
4083e519524SHoward Hinnant        {return __hash_(__x);}
4093e519524SHoward Hinnant};
4103e519524SHoward Hinnant
411abb160e6SHoward Hinnanttemplate <class _Key, class _Cp, class _Pred, bool = is_empty<_Pred>::value
41242b8bb50SHoward Hinnant#if __has_feature(is_final)
41342b8bb50SHoward Hinnant                                         && !__is_final(_Pred)
41442b8bb50SHoward Hinnant#endif
41542b8bb50SHoward Hinnant         >
4163e519524SHoward Hinnantclass __unordered_map_equal
4173e519524SHoward Hinnant    : private _Pred
4183e519524SHoward Hinnant{
4193e519524SHoward Hinnantpublic:
420789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4213714107eSHoward Hinnant    __unordered_map_equal()
4223714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
4233714107eSHoward Hinnant        : _Pred() {}
424789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4253714107eSHoward Hinnant    __unordered_map_equal(const _Pred& __p)
4263714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
4273714107eSHoward Hinnant        : _Pred(__p) {}
428789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4293714107eSHoward Hinnant    const _Pred& key_eq() const _NOEXCEPT {return *this;}
430789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
431a1a9e771SHoward Hinnant    bool operator()(const _Cp& __x, const _Cp& __y) const
432abb160e6SHoward Hinnant        {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y.__cc.first);}
433a1a9e771SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
434a1a9e771SHoward Hinnant    bool operator()(const _Cp& __x, const _Key& __y) const
435abb160e6SHoward Hinnant        {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y);}
436a1a9e771SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
437a1a9e771SHoward Hinnant    bool operator()(const _Key& __x, const _Cp& __y) const
438abb160e6SHoward Hinnant        {return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);}
4393e519524SHoward Hinnant};
4403e519524SHoward Hinnant
441abb160e6SHoward Hinnanttemplate <class _Key, class _Cp, class _Pred>
442abb160e6SHoward Hinnantclass __unordered_map_equal<_Key, _Cp, _Pred, false>
4433e519524SHoward Hinnant{
4443e519524SHoward Hinnant    _Pred __pred_;
445a1a9e771SHoward Hinnant
4463e519524SHoward Hinnantpublic:
447789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4483714107eSHoward Hinnant    __unordered_map_equal()
4493714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
4503714107eSHoward Hinnant        : __pred_() {}
451789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4523714107eSHoward Hinnant    __unordered_map_equal(const _Pred& __p)
4533714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
4543714107eSHoward Hinnant        : __pred_(__p) {}
455789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4563714107eSHoward Hinnant    const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
457789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
458a1a9e771SHoward Hinnant    bool operator()(const _Cp& __x, const _Cp& __y) const
459abb160e6SHoward Hinnant        {return __pred_(__x.__cc.first, __y.__cc.first);}
460a1a9e771SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
461a1a9e771SHoward Hinnant    bool operator()(const _Cp& __x, const _Key& __y) const
462abb160e6SHoward Hinnant        {return __pred_(__x.__cc.first, __y);}
463a1a9e771SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
464a1a9e771SHoward Hinnant    bool operator()(const _Key& __x, const _Cp& __y) const
465abb160e6SHoward Hinnant        {return __pred_(__x, __y.__cc.first);}
4663e519524SHoward Hinnant};
4673e519524SHoward Hinnant
4683e519524SHoward Hinnanttemplate <class _Alloc>
4693e519524SHoward Hinnantclass __hash_map_node_destructor
4703e519524SHoward Hinnant{
4713e519524SHoward Hinnant    typedef _Alloc                              allocator_type;
4723e519524SHoward Hinnant    typedef allocator_traits<allocator_type>    __alloc_traits;
4733e519524SHoward Hinnant    typedef typename __alloc_traits::value_type::value_type value_type;
4743e519524SHoward Hinnantpublic:
4753e519524SHoward Hinnant    typedef typename __alloc_traits::pointer    pointer;
4763e519524SHoward Hinnantprivate:
477307f8143SHoward Hinnant    typedef typename value_type::value_type::first_type     first_type;
478307f8143SHoward Hinnant    typedef typename value_type::value_type::second_type    second_type;
4793e519524SHoward Hinnant
4803e519524SHoward Hinnant    allocator_type& __na_;
4813e519524SHoward Hinnant
4823e519524SHoward Hinnant    __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
4833e519524SHoward Hinnant
4843e519524SHoward Hinnantpublic:
4853e519524SHoward Hinnant    bool __first_constructed;
4863e519524SHoward Hinnant    bool __second_constructed;
4873e519524SHoward Hinnant
488789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4893714107eSHoward Hinnant    explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
4903e519524SHoward Hinnant        : __na_(__na),
4913e519524SHoward Hinnant          __first_constructed(false),
4923e519524SHoward Hinnant          __second_constructed(false)
4933e519524SHoward Hinnant        {}
4943e519524SHoward Hinnant
4957609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
496789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4973e519524SHoward Hinnant    __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
4983714107eSHoward Hinnant        _NOEXCEPT
4993e519524SHoward Hinnant        : __na_(__x.__na_),
5003e519524SHoward Hinnant          __first_constructed(__x.__value_constructed),
5013e519524SHoward Hinnant          __second_constructed(__x.__value_constructed)
5023e519524SHoward Hinnant        {
5033e519524SHoward Hinnant            __x.__value_constructed = false;
5043e519524SHoward Hinnant        }
5057609c9b6SHoward Hinnant#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
506789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5073e519524SHoward Hinnant    __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
5083e519524SHoward Hinnant        : __na_(__x.__na_),
5093e519524SHoward Hinnant          __first_constructed(__x.__value_constructed),
5103e519524SHoward Hinnant          __second_constructed(__x.__value_constructed)
5113e519524SHoward Hinnant        {
5123e519524SHoward Hinnant            const_cast<bool&>(__x.__value_constructed) = false;
5133e519524SHoward Hinnant        }
5147609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
5153e519524SHoward Hinnant
516789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5173714107eSHoward Hinnant    void operator()(pointer __p) _NOEXCEPT
5183e519524SHoward Hinnant    {
5193e519524SHoward Hinnant        if (__second_constructed)
520307f8143SHoward Hinnant            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
5213e519524SHoward Hinnant        if (__first_constructed)
522307f8143SHoward Hinnant            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
5233e519524SHoward Hinnant        if (__p)
5243e519524SHoward Hinnant            __alloc_traits::deallocate(__na_, __p, 1);
5253e519524SHoward Hinnant    }
5263e519524SHoward Hinnant};
5273e519524SHoward Hinnant
5283e519524SHoward Hinnanttemplate <class _HashIterator>
529f0544c20SHoward Hinnantclass _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator
5303e519524SHoward Hinnant{
5313e519524SHoward Hinnant    _HashIterator __i_;
5323e519524SHoward Hinnant
5333e519524SHoward Hinnant    typedef pointer_traits<typename _HashIterator::pointer>      __pointer_traits;
534307f8143SHoward Hinnant    typedef const typename _HashIterator::value_type::value_type::first_type key_type;
535307f8143SHoward Hinnant    typedef typename _HashIterator::value_type::value_type::second_type      mapped_type;
5363e519524SHoward Hinnantpublic:
5373e519524SHoward Hinnant    typedef forward_iterator_tag                                 iterator_category;
5383e519524SHoward Hinnant    typedef pair<key_type, mapped_type>                          value_type;
5393e519524SHoward Hinnant    typedef typename _HashIterator::difference_type              difference_type;
5403e519524SHoward Hinnant    typedef value_type&                                          reference;
5413e519524SHoward Hinnant    typedef typename __pointer_traits::template
5423e519524SHoward Hinnant#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
5433e519524SHoward Hinnant            rebind<value_type>
5443e519524SHoward Hinnant#else
5453e519524SHoward Hinnant            rebind<value_type>::other
5463e519524SHoward Hinnant#endif
5473e519524SHoward Hinnant                                                                 pointer;
5483e519524SHoward Hinnant
549789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5503714107eSHoward Hinnant    __hash_map_iterator() _NOEXCEPT {}
5513e519524SHoward Hinnant
552789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5533714107eSHoward Hinnant    __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
5543e519524SHoward Hinnant
555789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
556307f8143SHoward Hinnant    reference operator*() const {return __i_->__cc;}
557789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
558307f8143SHoward Hinnant    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
5593e519524SHoward Hinnant
560789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5613e519524SHoward Hinnant    __hash_map_iterator& operator++() {++__i_; return *this;}
562789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5633e519524SHoward Hinnant    __hash_map_iterator operator++(int)
5643e519524SHoward Hinnant    {
5653e519524SHoward Hinnant        __hash_map_iterator __t(*this);
5663e519524SHoward Hinnant        ++(*this);
5673e519524SHoward Hinnant        return __t;
5683e519524SHoward Hinnant    }
5693e519524SHoward Hinnant
570789847ddSHoward Hinnant    friend _LIBCPP_INLINE_VISIBILITY
571789847ddSHoward Hinnant        bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
5723e519524SHoward Hinnant        {return __x.__i_ == __y.__i_;}
573789847ddSHoward Hinnant    friend _LIBCPP_INLINE_VISIBILITY
574789847ddSHoward Hinnant        bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
5753e519524SHoward Hinnant        {return __x.__i_ != __y.__i_;}
5763e519524SHoward Hinnant
577f0544c20SHoward Hinnant    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
578f0544c20SHoward Hinnant    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
579f0544c20SHoward Hinnant    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
580f0544c20SHoward Hinnant    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
581f0544c20SHoward Hinnant    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
5823e519524SHoward Hinnant};
5833e519524SHoward Hinnant
5843e519524SHoward Hinnanttemplate <class _HashIterator>
585f0544c20SHoward Hinnantclass _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator
5863e519524SHoward Hinnant{
5873e519524SHoward Hinnant    _HashIterator __i_;
5883e519524SHoward Hinnant
5893e519524SHoward Hinnant    typedef pointer_traits<typename _HashIterator::pointer>      __pointer_traits;
590307f8143SHoward Hinnant    typedef const typename _HashIterator::value_type::value_type::first_type key_type;
591307f8143SHoward Hinnant    typedef typename _HashIterator::value_type::value_type::second_type      mapped_type;
5923e519524SHoward Hinnantpublic:
5933e519524SHoward Hinnant    typedef forward_iterator_tag                                 iterator_category;
5943e519524SHoward Hinnant    typedef pair<key_type, mapped_type>                          value_type;
5953e519524SHoward Hinnant    typedef typename _HashIterator::difference_type              difference_type;
5963e519524SHoward Hinnant    typedef const value_type&                                    reference;
5973e519524SHoward Hinnant    typedef typename __pointer_traits::template
5983e519524SHoward Hinnant#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
5997e6ca972SHoward Hinnant            rebind<const value_type>
6003e519524SHoward Hinnant#else
6017e6ca972SHoward Hinnant            rebind<const value_type>::other
6023e519524SHoward Hinnant#endif
6033e519524SHoward Hinnant                                                                 pointer;
6043e519524SHoward Hinnant
605789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
6063714107eSHoward Hinnant    __hash_map_const_iterator() _NOEXCEPT {}
6073e519524SHoward Hinnant
608789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
6093714107eSHoward Hinnant    __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
610789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
6113e519524SHoward Hinnant    __hash_map_const_iterator(
6123e519524SHoward Hinnant            __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
6133714107eSHoward Hinnant                 _NOEXCEPT
6143e519524SHoward Hinnant                : __i_(__i.__i_) {}
6153e519524SHoward Hinnant
616789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
617307f8143SHoward Hinnant    reference operator*() const {return __i_->__cc;}
618789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
619307f8143SHoward Hinnant    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
6203e519524SHoward Hinnant
621789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
6223e519524SHoward Hinnant    __hash_map_const_iterator& operator++() {++__i_; return *this;}
623789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
6243e519524SHoward Hinnant    __hash_map_const_iterator operator++(int)
6253e519524SHoward Hinnant    {
6263e519524SHoward Hinnant        __hash_map_const_iterator __t(*this);
6273e519524SHoward Hinnant        ++(*this);
6283e519524SHoward Hinnant        return __t;
6293e519524SHoward Hinnant    }
6303e519524SHoward Hinnant
631789847ddSHoward Hinnant    friend _LIBCPP_INLINE_VISIBILITY
632789847ddSHoward Hinnant        bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
6333e519524SHoward Hinnant        {return __x.__i_ == __y.__i_;}
634789847ddSHoward Hinnant    friend _LIBCPP_INLINE_VISIBILITY
635789847ddSHoward Hinnant        bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
6363e519524SHoward Hinnant        {return __x.__i_ != __y.__i_;}
6373e519524SHoward Hinnant
638f0544c20SHoward Hinnant    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
639f0544c20SHoward Hinnant    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
640f0544c20SHoward Hinnant    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
641f0544c20SHoward Hinnant    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
6423e519524SHoward Hinnant};
6433e519524SHoward Hinnant
6443e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
6453e519524SHoward Hinnant          class _Alloc = allocator<pair<const _Key, _Tp> > >
646f0544c20SHoward Hinnantclass _LIBCPP_TYPE_VIS_ONLY unordered_map
6473e519524SHoward Hinnant{
6483e519524SHoward Hinnantpublic:
6493e519524SHoward Hinnant    // types
6503e519524SHoward Hinnant    typedef _Key                                           key_type;
6513e519524SHoward Hinnant    typedef _Tp                                            mapped_type;
6523e519524SHoward Hinnant    typedef _Hash                                          hasher;
6533e519524SHoward Hinnant    typedef _Pred                                          key_equal;
6543e519524SHoward Hinnant    typedef _Alloc                                         allocator_type;
6553e519524SHoward Hinnant    typedef pair<const key_type, mapped_type>              value_type;
656307f8143SHoward Hinnant    typedef pair<key_type, mapped_type>                    __nc_value_type;
6573e519524SHoward Hinnant    typedef value_type&                                    reference;
6583e519524SHoward Hinnant    typedef const value_type&                              const_reference;
659b24c8024SHoward Hinnant    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
660b24c8024SHoward Hinnant                  "Invalid allocator::value_type");
6613e519524SHoward Hinnant
6623e519524SHoward Hinnantprivate:
663307f8143SHoward Hinnant#if __cplusplus >= 201103L
664307f8143SHoward Hinnant    union __value_type
665307f8143SHoward Hinnant    {
666307f8143SHoward Hinnant        typedef typename unordered_map::value_type value_type;
667307f8143SHoward Hinnant        typedef typename unordered_map::__nc_value_type __nc_value_type;
668307f8143SHoward Hinnant        value_type __cc;
669307f8143SHoward Hinnant        __nc_value_type __nc;
670307f8143SHoward Hinnant
671307f8143SHoward Hinnant        template <class ..._Args>
672307f8143SHoward Hinnant        __value_type(_Args&& ...__args)
673307f8143SHoward Hinnant            : __cc(std::forward<_Args>(__args)...) {}
674307f8143SHoward Hinnant
675307f8143SHoward Hinnant        __value_type(const __value_type& __v)
676872ac4b5SHoward Hinnant            : __cc(__v.__cc) {}
677307f8143SHoward Hinnant
678307f8143SHoward Hinnant        __value_type(__value_type&& __v)
679307f8143SHoward Hinnant            : __nc(std::move(__v.__nc)) {}
680307f8143SHoward Hinnant
681307f8143SHoward Hinnant        __value_type& operator=(const __value_type& __v)
682307f8143SHoward Hinnant            {__nc = __v.__cc; return *this;}
683307f8143SHoward Hinnant
684307f8143SHoward Hinnant        __value_type& operator=(__value_type&& __v)
685307f8143SHoward Hinnant            {__nc = std::move(__v.__nc); return *this;}
686307f8143SHoward Hinnant
687307f8143SHoward Hinnant        ~__value_type() {__cc.~value_type();}
688307f8143SHoward Hinnant    };
689307f8143SHoward Hinnant#else
690307f8143SHoward Hinnant    struct __value_type
691307f8143SHoward Hinnant    {
692307f8143SHoward Hinnant        typedef typename unordered_map::value_type value_type;
693307f8143SHoward Hinnant        value_type __cc;
694307f8143SHoward Hinnant
695307f8143SHoward Hinnant        __value_type() {}
696307f8143SHoward Hinnant
697307f8143SHoward Hinnant        template <class _A0>
698307f8143SHoward Hinnant        __value_type(const _A0& __a0)
699307f8143SHoward Hinnant            : __cc(__a0) {}
700307f8143SHoward Hinnant
701307f8143SHoward Hinnant        template <class _A0, class _A1>
702307f8143SHoward Hinnant        __value_type(const _A0& __a0, const _A1& __a1)
703307f8143SHoward Hinnant            : __cc(__a0, __a1) {}
704307f8143SHoward Hinnant    };
705307f8143SHoward Hinnant#endif
706abb160e6SHoward Hinnant    typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
707abb160e6SHoward Hinnant    typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
7083e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::template
7093e519524SHoward Hinnant#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
7103e519524SHoward Hinnant            rebind_alloc<__value_type>
7113e519524SHoward Hinnant#else
7123e519524SHoward Hinnant            rebind_alloc<__value_type>::other
7133e519524SHoward Hinnant#endif
7143e519524SHoward Hinnant                                                           __allocator_type;
7153e519524SHoward Hinnant
7163e519524SHoward Hinnant    typedef __hash_table<__value_type, __hasher,
7173e519524SHoward Hinnant                         __key_equal,  __allocator_type>   __table;
7183e519524SHoward Hinnant
7193e519524SHoward Hinnant    __table __table_;
7203e519524SHoward Hinnant
7213e519524SHoward Hinnant    typedef typename __table::__node_pointer               __node_pointer;
7223e519524SHoward Hinnant    typedef typename __table::__node_const_pointer         __node_const_pointer;
7233e519524SHoward Hinnant    typedef typename __table::__node_traits                __node_traits;
7243e519524SHoward Hinnant    typedef typename __table::__node_allocator             __node_allocator;
7253e519524SHoward Hinnant    typedef typename __table::__node                       __node;
726c003db1fSHoward Hinnant    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
727c003db1fSHoward Hinnant    typedef unique_ptr<__node, _Dp>                         __node_holder;
7283e519524SHoward Hinnant    typedef allocator_traits<allocator_type>               __alloc_traits;
7293e519524SHoward Hinnantpublic:
7303e519524SHoward Hinnant    typedef typename __alloc_traits::pointer         pointer;
7313e519524SHoward Hinnant    typedef typename __alloc_traits::const_pointer   const_pointer;
7323e519524SHoward Hinnant    typedef typename __alloc_traits::size_type       size_type;
7333e519524SHoward Hinnant    typedef typename __alloc_traits::difference_type difference_type;
7343e519524SHoward Hinnant
7353e519524SHoward Hinnant    typedef __hash_map_iterator<typename __table::iterator>       iterator;
7363e519524SHoward Hinnant    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
7373e519524SHoward Hinnant    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
7383e519524SHoward Hinnant    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
7393e519524SHoward Hinnant
740789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
7413714107eSHoward Hinnant    unordered_map()
7423714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
743b24c8024SHoward Hinnant        {
744b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
745b24c8024SHoward Hinnant            __get_db()->__insert_c(this);
746b24c8024SHoward Hinnant#endif
747b24c8024SHoward Hinnant        }
7483e519524SHoward Hinnant    explicit unordered_map(size_type __n, const hasher& __hf = hasher(),
7493e519524SHoward Hinnant                           const key_equal& __eql = key_equal());
7503e519524SHoward Hinnant    unordered_map(size_type __n, const hasher& __hf,
7513e519524SHoward Hinnant                  const key_equal& __eql,
7523e519524SHoward Hinnant                  const allocator_type& __a);
7533e519524SHoward Hinnant    template <class _InputIterator>
7543e519524SHoward Hinnant        unordered_map(_InputIterator __first, _InputIterator __last);
7553e519524SHoward Hinnant    template <class _InputIterator>
7563e519524SHoward Hinnant        unordered_map(_InputIterator __first, _InputIterator __last,
7573e519524SHoward Hinnant                      size_type __n, const hasher& __hf = hasher(),
7583e519524SHoward Hinnant                      const key_equal& __eql = key_equal());
7593e519524SHoward Hinnant    template <class _InputIterator>
7603e519524SHoward Hinnant        unordered_map(_InputIterator __first, _InputIterator __last,
7613e519524SHoward Hinnant                      size_type __n, const hasher& __hf,
7623e519524SHoward Hinnant                      const key_equal& __eql,
7633e519524SHoward Hinnant                      const allocator_type& __a);
7643e519524SHoward Hinnant    explicit unordered_map(const allocator_type& __a);
7653e519524SHoward Hinnant    unordered_map(const unordered_map& __u);
7663e519524SHoward Hinnant    unordered_map(const unordered_map& __u, const allocator_type& __a);
7677609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
7683714107eSHoward Hinnant    unordered_map(unordered_map&& __u)
7693714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
7703e519524SHoward Hinnant    unordered_map(unordered_map&& __u, const allocator_type& __a);
7717609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
77254976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
7733e519524SHoward Hinnant    unordered_map(initializer_list<value_type> __il);
7743e519524SHoward Hinnant    unordered_map(initializer_list<value_type> __il, size_type __n,
7753e519524SHoward Hinnant                  const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
7763e519524SHoward Hinnant    unordered_map(initializer_list<value_type> __il, size_type __n,
7773e519524SHoward Hinnant                  const hasher& __hf, const key_equal& __eql,
7783e519524SHoward Hinnant                  const allocator_type& __a);
77954976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
780*3cd37e64SMarshall Clow#if _LIBCPP_STD_VER > 11
781*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
782*3cd37e64SMarshall Clow    unordered_map(size_type __n, const allocator_type& __a)
783*3cd37e64SMarshall Clow      : unordered_map(__n, hasher(), key_equal(), __a) {}
784*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
785*3cd37e64SMarshall Clow    unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
786*3cd37e64SMarshall Clow      : unordered_map(__n, __hf, key_equal(), __a) {}
787*3cd37e64SMarshall Clow    template <class _InputIterator>
788*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
789*3cd37e64SMarshall Clow      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
790*3cd37e64SMarshall Clow      : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
791*3cd37e64SMarshall Clow    template <class _InputIterator>
792*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
793*3cd37e64SMarshall Clow      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
794*3cd37e64SMarshall Clow        const allocator_type& __a)
795*3cd37e64SMarshall Clow      : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
796*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
797*3cd37e64SMarshall Clow    unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
798*3cd37e64SMarshall Clow      : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
799*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
800*3cd37e64SMarshall Clow    unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
801*3cd37e64SMarshall Clow      const allocator_type& __a)
802*3cd37e64SMarshall Clow      : unordered_map(__il, __n, __hf, key_equal(), __a) {}
803*3cd37e64SMarshall Clow#endif
8043e519524SHoward Hinnant    // ~unordered_map() = default;
8055a33687dSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8065a33687dSHoward Hinnant    unordered_map& operator=(const unordered_map& __u)
8075a33687dSHoward Hinnant    {
808307f8143SHoward Hinnant#if __cplusplus >= 201103L
8095a33687dSHoward Hinnant        __table_ = __u.__table_;
810307f8143SHoward Hinnant#else
811307f8143SHoward Hinnant        __table_.clear();
812307f8143SHoward Hinnant        __table_.hash_function() = __u.__table_.hash_function();
813307f8143SHoward Hinnant        __table_.key_eq() = __u.__table_.key_eq();
814307f8143SHoward Hinnant        __table_.max_load_factor() = __u.__table_.max_load_factor();
815307f8143SHoward Hinnant        __table_.__copy_assign_alloc(__u.__table_);
816307f8143SHoward Hinnant        insert(__u.begin(), __u.end());
817307f8143SHoward Hinnant#endif
8185a33687dSHoward Hinnant        return *this;
8195a33687dSHoward Hinnant    }
8207609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
8213714107eSHoward Hinnant    unordered_map& operator=(unordered_map&& __u)
8223714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
8233e519524SHoward Hinnant#endif
82454976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
8253e519524SHoward Hinnant    unordered_map& operator=(initializer_list<value_type> __il);
82654976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
8273e519524SHoward Hinnant
828789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8293714107eSHoward Hinnant    allocator_type get_allocator() const _NOEXCEPT
8303e519524SHoward Hinnant        {return allocator_type(__table_.__node_alloc());}
8313e519524SHoward Hinnant
832789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8333714107eSHoward Hinnant    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
834789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8353714107eSHoward Hinnant    size_type size() const _NOEXCEPT  {return __table_.size();}
836789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8373714107eSHoward Hinnant    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
8383e519524SHoward Hinnant
839789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8403714107eSHoward Hinnant    iterator       begin() _NOEXCEPT        {return __table_.begin();}
841789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8423714107eSHoward Hinnant    iterator       end() _NOEXCEPT          {return __table_.end();}
843789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8443714107eSHoward Hinnant    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
845789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8463714107eSHoward Hinnant    const_iterator end()    const _NOEXCEPT {return __table_.end();}
847789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8483714107eSHoward Hinnant    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
849789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8503714107eSHoward Hinnant    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
8513e519524SHoward Hinnant
8527609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
8537609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_VARIADICS
8547609c9b6SHoward Hinnant
8558b805c91SHoward Hinnant    template <class... _Args>
8568b805c91SHoward Hinnant        pair<iterator, bool> emplace(_Args&&... __args);
8573e519524SHoward Hinnant
8588b805c91SHoward Hinnant    template <class... _Args>
859789847ddSHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
8604c80bfbdSHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
8614c80bfbdSHoward Hinnant        iterator emplace_hint(const_iterator __p, _Args&&... __args)
8624c80bfbdSHoward Hinnant        {
8634c80bfbdSHoward Hinnant            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
8644c80bfbdSHoward Hinnant                "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
8654c80bfbdSHoward Hinnant                " referring to this unordered_map");
8664c80bfbdSHoward Hinnant            return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
8674c80bfbdSHoward Hinnant        }
8684c80bfbdSHoward Hinnant#else
8698b805c91SHoward Hinnant        iterator emplace_hint(const_iterator, _Args&&... __args)
8708b805c91SHoward Hinnant            {return emplace(_VSTD::forward<_Args>(__args)...).first;}
8714c80bfbdSHoward Hinnant#endif
8727609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_VARIADICS
8737609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
874789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8753e519524SHoward Hinnant    pair<iterator, bool> insert(const value_type& __x)
8763e519524SHoward Hinnant        {return __table_.__insert_unique(__x);}
8777609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
878c003db1fSHoward Hinnant    template <class _Pp,
879c003db1fSHoward Hinnant              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
880789847ddSHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
881c003db1fSHoward Hinnant        pair<iterator, bool> insert(_Pp&& __x)
882c003db1fSHoward Hinnant            {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
8837609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
884789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
8854c80bfbdSHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
8864c80bfbdSHoward Hinnant    iterator insert(const_iterator __p, const value_type& __x)
8874c80bfbdSHoward Hinnant        {
8884c80bfbdSHoward Hinnant            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
8894c80bfbdSHoward Hinnant                "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
8904c80bfbdSHoward Hinnant                " referring to this unordered_map");
8914c80bfbdSHoward Hinnant            return insert(__x).first;
8924c80bfbdSHoward Hinnant        }
8934c80bfbdSHoward Hinnant#else
8943e519524SHoward Hinnant    iterator insert(const_iterator, const value_type& __x)
8953e519524SHoward Hinnant        {return insert(__x).first;}
8964c80bfbdSHoward Hinnant#endif
8977609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
898c003db1fSHoward Hinnant    template <class _Pp,
899c003db1fSHoward Hinnant              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
900789847ddSHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
9014c80bfbdSHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
9024c80bfbdSHoward Hinnant        iterator insert(const_iterator __p, _Pp&& __x)
9034c80bfbdSHoward Hinnant        {
9044c80bfbdSHoward Hinnant            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
9054c80bfbdSHoward Hinnant                "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
9064c80bfbdSHoward Hinnant                " referring to this unordered_map");
9074c80bfbdSHoward Hinnant            return insert(_VSTD::forward<_Pp>(__x)).first;
9084c80bfbdSHoward Hinnant        }
9094c80bfbdSHoward Hinnant#else
910c003db1fSHoward Hinnant        iterator insert(const_iterator, _Pp&& __x)
911c003db1fSHoward Hinnant            {return insert(_VSTD::forward<_Pp>(__x)).first;}
9124c80bfbdSHoward Hinnant#endif
9137609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
9143e519524SHoward Hinnant    template <class _InputIterator>
9153e519524SHoward Hinnant        void insert(_InputIterator __first, _InputIterator __last);
91654976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
917789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9183e519524SHoward Hinnant    void insert(initializer_list<value_type> __il)
9193e519524SHoward Hinnant        {insert(__il.begin(), __il.end());}
92054976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
9213e519524SHoward Hinnant
922789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9233e519524SHoward Hinnant    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
924789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9253e519524SHoward Hinnant    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
926789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9273e519524SHoward Hinnant    iterator erase(const_iterator __first, const_iterator __last)
9283e519524SHoward Hinnant        {return __table_.erase(__first.__i_, __last.__i_);}
929789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9303714107eSHoward Hinnant    void clear() _NOEXCEPT {__table_.clear();}
9313e519524SHoward Hinnant
932789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9333714107eSHoward Hinnant    void swap(unordered_map& __u)
9343714107eSHoward Hinnant        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
9353714107eSHoward Hinnant        {__table_.swap(__u.__table_);}
9363e519524SHoward Hinnant
937789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9383e519524SHoward Hinnant    hasher hash_function() const
9393e519524SHoward Hinnant        {return __table_.hash_function().hash_function();}
940789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9413e519524SHoward Hinnant    key_equal key_eq() const
9423e519524SHoward Hinnant        {return __table_.key_eq().key_eq();}
9433e519524SHoward Hinnant
944789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9453e519524SHoward Hinnant    iterator       find(const key_type& __k)       {return __table_.find(__k);}
946789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9473e519524SHoward Hinnant    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
948789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9493e519524SHoward Hinnant    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
950789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9513e519524SHoward Hinnant    pair<iterator, iterator>             equal_range(const key_type& __k)
9523e519524SHoward Hinnant        {return __table_.__equal_range_unique(__k);}
953789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9543e519524SHoward Hinnant    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
9553e519524SHoward Hinnant        {return __table_.__equal_range_unique(__k);}
9563e519524SHoward Hinnant
9573e519524SHoward Hinnant    mapped_type& operator[](const key_type& __k);
9587609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
9593e519524SHoward Hinnant    mapped_type& operator[](key_type&& __k);
9603e519524SHoward Hinnant#endif
9613e519524SHoward Hinnant
9623e519524SHoward Hinnant    mapped_type&       at(const key_type& __k);
9633e519524SHoward Hinnant    const mapped_type& at(const key_type& __k) const;
9643e519524SHoward Hinnant
965789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9663714107eSHoward Hinnant    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
967789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9683714107eSHoward Hinnant    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
9693e519524SHoward Hinnant
970789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9713e519524SHoward Hinnant    size_type bucket_size(size_type __n) const
9723e519524SHoward Hinnant        {return __table_.bucket_size(__n);}
973789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9743e519524SHoward Hinnant    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
9753e519524SHoward Hinnant
976789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9773e519524SHoward Hinnant    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
978789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9793e519524SHoward Hinnant    local_iterator       end(size_type __n)          {return __table_.end(__n);}
980789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9813e519524SHoward Hinnant    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
982789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9833e519524SHoward Hinnant    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
984789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9853e519524SHoward Hinnant    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
986789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9873e519524SHoward Hinnant    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
9883e519524SHoward Hinnant
989789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9903714107eSHoward Hinnant    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
991789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9923714107eSHoward Hinnant    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
993789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9943e519524SHoward Hinnant    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
995789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9963e519524SHoward Hinnant    void rehash(size_type __n) {__table_.rehash(__n);}
997789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
9983e519524SHoward Hinnant    void reserve(size_type __n) {__table_.reserve(__n);}
9993e519524SHoward Hinnant
1000b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1001b24c8024SHoward Hinnant
1002b24c8024SHoward Hinnant    bool __dereferenceable(const const_iterator* __i) const
1003b24c8024SHoward Hinnant        {return __table_.__dereferenceable(&__i->__i_);}
1004b24c8024SHoward Hinnant    bool __decrementable(const const_iterator* __i) const
1005b24c8024SHoward Hinnant        {return __table_.__decrementable(&__i->__i_);}
1006b24c8024SHoward Hinnant    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1007b24c8024SHoward Hinnant        {return __table_.__addable(&__i->__i_, __n);}
1008b24c8024SHoward Hinnant    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1009b24c8024SHoward Hinnant        {return __table_.__addable(&__i->__i_, __n);}
1010b24c8024SHoward Hinnant
1011b24c8024SHoward Hinnant#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1012b24c8024SHoward Hinnant
10133e519524SHoward Hinnantprivate:
10147609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
10158b805c91SHoward Hinnant    __node_holder __construct_node();
10168b805c91SHoward Hinnant    template <class _A0>
10178b805c91SHoward Hinnant        __node_holder
10188b805c91SHoward Hinnant         __construct_node(_A0&& __a0);
10194a95f9ebSHoward Hinnant    __node_holder __construct_node_with_key(key_type&& __k);
10207609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_VARIADICS
10218b805c91SHoward Hinnant    template <class _A0, class _A1, class ..._Args>
10228b805c91SHoward Hinnant        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
10237609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_VARIADICS
10244a95f9ebSHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
10254a95f9ebSHoward Hinnant    __node_holder __construct_node_with_key(const key_type& __k);
10263e519524SHoward Hinnant};
10273e519524SHoward Hinnant
10283e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
10293e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
10303e519524SHoward Hinnant        size_type __n, const hasher& __hf, const key_equal& __eql)
10313e519524SHoward Hinnant    : __table_(__hf, __eql)
10323e519524SHoward Hinnant{
1033b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1034b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1035b24c8024SHoward Hinnant#endif
10363e519524SHoward Hinnant    __table_.rehash(__n);
10373e519524SHoward Hinnant}
10383e519524SHoward Hinnant
10393e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
10403e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
10413e519524SHoward Hinnant        size_type __n, const hasher& __hf, const key_equal& __eql,
10423e519524SHoward Hinnant        const allocator_type& __a)
10433e519524SHoward Hinnant    : __table_(__hf, __eql, __a)
10443e519524SHoward Hinnant{
1045b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1046b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1047b24c8024SHoward Hinnant#endif
10483e519524SHoward Hinnant    __table_.rehash(__n);
10493e519524SHoward Hinnant}
10503e519524SHoward Hinnant
10513e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1052789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
10533e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
10543e519524SHoward Hinnant        const allocator_type& __a)
10553e519524SHoward Hinnant    : __table_(__a)
10563e519524SHoward Hinnant{
1057b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1058b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1059b24c8024SHoward Hinnant#endif
10603e519524SHoward Hinnant}
10613e519524SHoward Hinnant
10623e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
10633e519524SHoward Hinnanttemplate <class _InputIterator>
10643e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
10653e519524SHoward Hinnant        _InputIterator __first, _InputIterator __last)
10663e519524SHoward Hinnant{
1067b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1068b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1069b24c8024SHoward Hinnant#endif
10703e519524SHoward Hinnant    insert(__first, __last);
10713e519524SHoward Hinnant}
10723e519524SHoward Hinnant
10733e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
10743e519524SHoward Hinnanttemplate <class _InputIterator>
10753e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
10763e519524SHoward Hinnant        _InputIterator __first, _InputIterator __last, size_type __n,
10773e519524SHoward Hinnant        const hasher& __hf, const key_equal& __eql)
10783e519524SHoward Hinnant    : __table_(__hf, __eql)
10793e519524SHoward Hinnant{
1080b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1081b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1082b24c8024SHoward Hinnant#endif
10833e519524SHoward Hinnant    __table_.rehash(__n);
10843e519524SHoward Hinnant    insert(__first, __last);
10853e519524SHoward Hinnant}
10863e519524SHoward Hinnant
10873e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
10883e519524SHoward Hinnanttemplate <class _InputIterator>
10893e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
10903e519524SHoward Hinnant        _InputIterator __first, _InputIterator __last, size_type __n,
10913e519524SHoward Hinnant        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
10923e519524SHoward Hinnant    : __table_(__hf, __eql, __a)
10933e519524SHoward Hinnant{
1094b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1095b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1096b24c8024SHoward Hinnant#endif
10973e519524SHoward Hinnant    __table_.rehash(__n);
10983e519524SHoward Hinnant    insert(__first, __last);
10993e519524SHoward Hinnant}
11003e519524SHoward Hinnant
11013e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
11023e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
11033e519524SHoward Hinnant        const unordered_map& __u)
11043e519524SHoward Hinnant    : __table_(__u.__table_)
11053e519524SHoward Hinnant{
1106b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1107b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1108b24c8024SHoward Hinnant#endif
11093e519524SHoward Hinnant    __table_.rehash(__u.bucket_count());
11103e519524SHoward Hinnant    insert(__u.begin(), __u.end());
11113e519524SHoward Hinnant}
11123e519524SHoward Hinnant
11133e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
11143e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
11153e519524SHoward Hinnant        const unordered_map& __u, const allocator_type& __a)
11163e519524SHoward Hinnant    : __table_(__u.__table_, __a)
11173e519524SHoward Hinnant{
1118b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1119b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1120b24c8024SHoward Hinnant#endif
11213e519524SHoward Hinnant    __table_.rehash(__u.bucket_count());
11223e519524SHoward Hinnant    insert(__u.begin(), __u.end());
11233e519524SHoward Hinnant}
11243e519524SHoward Hinnant
11257609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
11263e519524SHoward Hinnant
11273e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1128789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
11293e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
11303e519524SHoward Hinnant        unordered_map&& __u)
11313714107eSHoward Hinnant    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1132ce48a113SHoward Hinnant    : __table_(_VSTD::move(__u.__table_))
11333e519524SHoward Hinnant{
1134b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1135b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
11364c80bfbdSHoward Hinnant    __get_db()->swap(this, &__u);
1137b24c8024SHoward Hinnant#endif
11383e519524SHoward Hinnant}
11393e519524SHoward Hinnant
11403e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
11413e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
11423e519524SHoward Hinnant        unordered_map&& __u, const allocator_type& __a)
1143ce48a113SHoward Hinnant    : __table_(_VSTD::move(__u.__table_), __a)
11443e519524SHoward Hinnant{
1145b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1146b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1147b24c8024SHoward Hinnant#endif
11483e519524SHoward Hinnant    if (__a != __u.get_allocator())
11493e519524SHoward Hinnant    {
11503e519524SHoward Hinnant        iterator __i = __u.begin();
11513e519524SHoward Hinnant        while (__u.size() != 0)
11523e519524SHoward Hinnant            __table_.__insert_unique(
1153ce48a113SHoward Hinnant                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
11543e519524SHoward Hinnant                                    );
11553e519524SHoward Hinnant    }
11564c80bfbdSHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
11574c80bfbdSHoward Hinnant    else
11584c80bfbdSHoward Hinnant        __get_db()->swap(this, &__u);
11594c80bfbdSHoward Hinnant#endif
11603e519524SHoward Hinnant}
11613e519524SHoward Hinnant
11627609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
11633e519524SHoward Hinnant
116454976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
116554976f26SHoward Hinnant
11663e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
11673e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
11683e519524SHoward Hinnant        initializer_list<value_type> __il)
11693e519524SHoward Hinnant{
1170b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1171b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1172b24c8024SHoward Hinnant#endif
11733e519524SHoward Hinnant    insert(__il.begin(), __il.end());
11743e519524SHoward Hinnant}
11753e519524SHoward Hinnant
11763e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
11773e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
11783e519524SHoward Hinnant        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
11793e519524SHoward Hinnant        const key_equal& __eql)
11803e519524SHoward Hinnant    : __table_(__hf, __eql)
11813e519524SHoward Hinnant{
1182b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1183b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1184b24c8024SHoward Hinnant#endif
11853e519524SHoward Hinnant    __table_.rehash(__n);
11863e519524SHoward Hinnant    insert(__il.begin(), __il.end());
11873e519524SHoward Hinnant}
11883e519524SHoward Hinnant
11893e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
11903e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
11913e519524SHoward Hinnant        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
11923e519524SHoward Hinnant        const key_equal& __eql, const allocator_type& __a)
11933e519524SHoward Hinnant    : __table_(__hf, __eql, __a)
11943e519524SHoward Hinnant{
1195b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1196b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1197b24c8024SHoward Hinnant#endif
11983e519524SHoward Hinnant    __table_.rehash(__n);
11993e519524SHoward Hinnant    insert(__il.begin(), __il.end());
12003e519524SHoward Hinnant}
12013e519524SHoward Hinnant
120254976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
120354976f26SHoward Hinnant
12047609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
12053e519524SHoward Hinnant
12063e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1207789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
12083e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
12093e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
12103714107eSHoward Hinnant    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
12113e519524SHoward Hinnant{
1212ce48a113SHoward Hinnant    __table_ = _VSTD::move(__u.__table_);
12133e519524SHoward Hinnant    return *this;
12143e519524SHoward Hinnant}
12153e519524SHoward Hinnant
12167609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
12173e519524SHoward Hinnant
121854976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
121954976f26SHoward Hinnant
12203e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1221789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
12223e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
12233e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
12243e519524SHoward Hinnant        initializer_list<value_type> __il)
12253e519524SHoward Hinnant{
12263e519524SHoward Hinnant    __table_.__assign_unique(__il.begin(), __il.end());
12273e519524SHoward Hinnant    return *this;
12283e519524SHoward Hinnant}
12293e519524SHoward Hinnant
123054976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
123154976f26SHoward Hinnant
12327609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
12333e519524SHoward Hinnant
12343e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
12353e519524SHoward Hinnanttypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
12368b805c91SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
12373e519524SHoward Hinnant{
12383e519524SHoward Hinnant    __node_allocator& __na = __table_.__node_alloc();
1239c003db1fSHoward Hinnant    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
12408b805c91SHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_));
12413e519524SHoward Hinnant    __h.get_deleter().__first_constructed = true;
12423e519524SHoward Hinnant    __h.get_deleter().__second_constructed = true;
12433e519524SHoward Hinnant    return __h;
12443e519524SHoward Hinnant}
12453e519524SHoward Hinnant
12463e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
12478b805c91SHoward Hinnanttemplate <class _A0>
12483e519524SHoward Hinnanttypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
12493e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
12503e519524SHoward Hinnant{
12513e519524SHoward Hinnant    __node_allocator& __na = __table_.__node_alloc();
1252c003db1fSHoward Hinnant    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1253ce48a113SHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
1254ce48a113SHoward Hinnant                             _VSTD::forward<_A0>(__a0));
12553e519524SHoward Hinnant    __h.get_deleter().__first_constructed = true;
12563e519524SHoward Hinnant    __h.get_deleter().__second_constructed = true;
12573e519524SHoward Hinnant    return __h;
12583e519524SHoward Hinnant}
12593e519524SHoward Hinnant
12608b805c91SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
12618b805c91SHoward Hinnanttypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
12624a95f9ebSHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_type&& __k)
12638b805c91SHoward Hinnant{
12648b805c91SHoward Hinnant    __node_allocator& __na = __table_.__node_alloc();
12658b805c91SHoward Hinnant    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
12664a95f9ebSHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
12678b805c91SHoward Hinnant    __h.get_deleter().__first_constructed = true;
1268307f8143SHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
12698b805c91SHoward Hinnant    __h.get_deleter().__second_constructed = true;
1270179b1f8cSHoward Hinnant    return __h;
12718b805c91SHoward Hinnant}
12728b805c91SHoward Hinnant
12737609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_VARIADICS
12747609c9b6SHoward Hinnant
12753e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
12768b805c91SHoward Hinnanttemplate <class _A0, class _A1, class ..._Args>
12778b805c91SHoward Hinnanttypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
12788b805c91SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0,
12798b805c91SHoward Hinnant                                                                 _A1&& __a1,
12808b805c91SHoward Hinnant                                                                 _Args&&... __args)
12813e519524SHoward Hinnant{
12828b805c91SHoward Hinnant    __node_allocator& __na = __table_.__node_alloc();
12838b805c91SHoward Hinnant    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
12848b805c91SHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
12858b805c91SHoward Hinnant                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
1286ce48a113SHoward Hinnant                             _VSTD::forward<_Args>(__args)...);
12878b805c91SHoward Hinnant    __h.get_deleter().__first_constructed = true;
12888b805c91SHoward Hinnant    __h.get_deleter().__second_constructed = true;
12898b805c91SHoward Hinnant    return __h;
12908b805c91SHoward Hinnant}
12918b805c91SHoward Hinnant
12928b805c91SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
12938b805c91SHoward Hinnanttemplate <class... _Args>
12948b805c91SHoward Hinnantpair<typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator, bool>
12958b805c91SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
12968b805c91SHoward Hinnant{
12978b805c91SHoward Hinnant    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
12983e519524SHoward Hinnant    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
12993e519524SHoward Hinnant    if (__r.second)
13003e519524SHoward Hinnant        __h.release();
13013e519524SHoward Hinnant    return __r;
13023e519524SHoward Hinnant}
13033e519524SHoward Hinnant
13047609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_VARIADICS
13054a95f9ebSHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
13063e519524SHoward Hinnant
13073e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
13083e519524SHoward Hinnanttypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
13094a95f9ebSHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
13103e519524SHoward Hinnant{
13113e519524SHoward Hinnant    __node_allocator& __na = __table_.__node_alloc();
1312c003db1fSHoward Hinnant    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1313307f8143SHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k);
13143e519524SHoward Hinnant    __h.get_deleter().__first_constructed = true;
1315307f8143SHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
13163e519524SHoward Hinnant    __h.get_deleter().__second_constructed = true;
1317179b1f8cSHoward Hinnant    return _VSTD::move(__h);  // explicitly moved for C++03
13183e519524SHoward Hinnant}
13193e519524SHoward Hinnant
13203e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
13213e519524SHoward Hinnanttemplate <class _InputIterator>
1322789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
13233e519524SHoward Hinnantvoid
13243e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
13253e519524SHoward Hinnant                                                       _InputIterator __last)
13263e519524SHoward Hinnant{
13273e519524SHoward Hinnant    for (; __first != __last; ++__first)
13283e519524SHoward Hinnant        __table_.__insert_unique(*__first);
13293e519524SHoward Hinnant}
13303e519524SHoward Hinnant
13313e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
13323e519524SHoward Hinnant_Tp&
13333e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
13343e519524SHoward Hinnant{
13353e519524SHoward Hinnant    iterator __i = find(__k);
13363e519524SHoward Hinnant    if (__i != end())
13373e519524SHoward Hinnant        return __i->second;
13384a95f9ebSHoward Hinnant    __node_holder __h = __construct_node_with_key(__k);
13393e519524SHoward Hinnant    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
13403e519524SHoward Hinnant    __h.release();
13413e519524SHoward Hinnant    return __r.first->second;
13423e519524SHoward Hinnant}
13433e519524SHoward Hinnant
13447609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
13453e519524SHoward Hinnant
13463e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
13473e519524SHoward Hinnant_Tp&
13483e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
13493e519524SHoward Hinnant{
13503e519524SHoward Hinnant    iterator __i = find(__k);
13513e519524SHoward Hinnant    if (__i != end())
13523e519524SHoward Hinnant        return __i->second;
13534a95f9ebSHoward Hinnant    __node_holder __h = __construct_node_with_key(_VSTD::move(__k));
13543e519524SHoward Hinnant    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
13553e519524SHoward Hinnant    __h.release();
13563e519524SHoward Hinnant    return __r.first->second;
13573e519524SHoward Hinnant}
13583e519524SHoward Hinnant
13597609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
13603e519524SHoward Hinnant
13613e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
13623e519524SHoward Hinnant_Tp&
13633e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k)
13643e519524SHoward Hinnant{
13653e519524SHoward Hinnant    iterator __i = find(__k);
13663e519524SHoward Hinnant#ifndef _LIBCPP_NO_EXCEPTIONS
13673e519524SHoward Hinnant    if (__i == end())
13683e519524SHoward Hinnant        throw out_of_range("unordered_map::at: key not found");
1369b3371f6fSHoward Hinnant#endif  // _LIBCPP_NO_EXCEPTIONS
13703e519524SHoward Hinnant    return __i->second;
13713e519524SHoward Hinnant}
13723e519524SHoward Hinnant
13733e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
13743e519524SHoward Hinnantconst _Tp&
13753e519524SHoward Hinnantunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const
13763e519524SHoward Hinnant{
13773e519524SHoward Hinnant    const_iterator __i = find(__k);
13783e519524SHoward Hinnant#ifndef _LIBCPP_NO_EXCEPTIONS
13793e519524SHoward Hinnant    if (__i == end())
13803e519524SHoward Hinnant        throw out_of_range("unordered_map::at: key not found");
1381b3371f6fSHoward Hinnant#endif  // _LIBCPP_NO_EXCEPTIONS
13823e519524SHoward Hinnant    return __i->second;
13833e519524SHoward Hinnant}
13843e519524SHoward Hinnant
13853e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1386789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
13873e519524SHoward Hinnantvoid
13883e519524SHoward Hinnantswap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
13893e519524SHoward Hinnant     unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
13903714107eSHoward Hinnant    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
13913e519524SHoward Hinnant{
13923e519524SHoward Hinnant    __x.swap(__y);
13933e519524SHoward Hinnant}
13943e519524SHoward Hinnant
13953e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
13963e519524SHoward Hinnantbool
13973e519524SHoward Hinnantoperator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
13983e519524SHoward Hinnant           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
13993e519524SHoward Hinnant{
14003e519524SHoward Hinnant    if (__x.size() != __y.size())
14013e519524SHoward Hinnant        return false;
14023e519524SHoward Hinnant    typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
14033e519524SHoward Hinnant                                                                 const_iterator;
14043e519524SHoward Hinnant    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
14053e519524SHoward Hinnant            __i != __ex; ++__i)
14063e519524SHoward Hinnant    {
14073e519524SHoward Hinnant        const_iterator __j = __y.find(__i->first);
14083e519524SHoward Hinnant        if (__j == __ey || !(*__i == *__j))
14093e519524SHoward Hinnant            return false;
14103e519524SHoward Hinnant    }
14113e519524SHoward Hinnant    return true;
14123e519524SHoward Hinnant}
14133e519524SHoward Hinnant
14143e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1415789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
14163e519524SHoward Hinnantbool
14173e519524SHoward Hinnantoperator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
14183e519524SHoward Hinnant           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
14193e519524SHoward Hinnant{
14203e519524SHoward Hinnant    return !(__x == __y);
14213e519524SHoward Hinnant}
14223e519524SHoward Hinnant
14233e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
14243e519524SHoward Hinnant          class _Alloc = allocator<pair<const _Key, _Tp> > >
1425f0544c20SHoward Hinnantclass _LIBCPP_TYPE_VIS_ONLY unordered_multimap
14263e519524SHoward Hinnant{
14273e519524SHoward Hinnantpublic:
14283e519524SHoward Hinnant    // types
14293e519524SHoward Hinnant    typedef _Key                                           key_type;
14303e519524SHoward Hinnant    typedef _Tp                                            mapped_type;
14313e519524SHoward Hinnant    typedef _Hash                                          hasher;
14323e519524SHoward Hinnant    typedef _Pred                                          key_equal;
14333e519524SHoward Hinnant    typedef _Alloc                                         allocator_type;
14343e519524SHoward Hinnant    typedef pair<const key_type, mapped_type>              value_type;
1435307f8143SHoward Hinnant    typedef pair<key_type, mapped_type>                    __nc_value_type;
14363e519524SHoward Hinnant    typedef value_type&                                    reference;
14373e519524SHoward Hinnant    typedef const value_type&                              const_reference;
1438b24c8024SHoward Hinnant    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1439b24c8024SHoward Hinnant                  "Invalid allocator::value_type");
14403e519524SHoward Hinnant
14413e519524SHoward Hinnantprivate:
1442307f8143SHoward Hinnant#if __cplusplus >= 201103L
1443307f8143SHoward Hinnant    union __value_type
1444307f8143SHoward Hinnant    {
1445307f8143SHoward Hinnant        typedef typename unordered_multimap::value_type value_type;
1446307f8143SHoward Hinnant        typedef typename unordered_multimap::__nc_value_type __nc_value_type;
1447307f8143SHoward Hinnant        value_type __cc;
1448307f8143SHoward Hinnant        __nc_value_type __nc;
1449307f8143SHoward Hinnant
1450307f8143SHoward Hinnant        template <class ..._Args>
1451307f8143SHoward Hinnant        __value_type(_Args&& ...__args)
1452307f8143SHoward Hinnant            : __cc(std::forward<_Args>(__args)...) {}
1453307f8143SHoward Hinnant
1454307f8143SHoward Hinnant        __value_type(const __value_type& __v)
1455307f8143SHoward Hinnant            : __cc(std::move(__v.__cc)) {}
1456307f8143SHoward Hinnant
1457307f8143SHoward Hinnant        __value_type(__value_type&& __v)
1458307f8143SHoward Hinnant            : __nc(std::move(__v.__nc)) {}
1459307f8143SHoward Hinnant
1460307f8143SHoward Hinnant        __value_type& operator=(const __value_type& __v)
1461307f8143SHoward Hinnant            {__nc = __v.__cc; return *this;}
1462307f8143SHoward Hinnant
1463307f8143SHoward Hinnant        __value_type& operator=(__value_type&& __v)
1464307f8143SHoward Hinnant            {__nc = std::move(__v.__nc); return *this;}
1465307f8143SHoward Hinnant
1466307f8143SHoward Hinnant        ~__value_type() {__cc.~value_type();}
1467307f8143SHoward Hinnant    };
1468307f8143SHoward Hinnant#else
1469307f8143SHoward Hinnant    struct __value_type
1470307f8143SHoward Hinnant    {
1471307f8143SHoward Hinnant        typedef typename unordered_multimap::value_type value_type;
1472307f8143SHoward Hinnant        value_type __cc;
1473307f8143SHoward Hinnant
1474307f8143SHoward Hinnant        __value_type() {}
1475307f8143SHoward Hinnant
1476307f8143SHoward Hinnant        template <class _A0>
1477307f8143SHoward Hinnant        __value_type(const _A0& __a0)
1478307f8143SHoward Hinnant            : __cc(__a0) {}
1479307f8143SHoward Hinnant
1480307f8143SHoward Hinnant        template <class _A0, class _A1>
1481307f8143SHoward Hinnant        __value_type(const _A0& __a0, const _A1& __a1)
1482307f8143SHoward Hinnant            : __cc(__a0, __a1) {}
1483307f8143SHoward Hinnant    };
1484307f8143SHoward Hinnant#endif
1485abb160e6SHoward Hinnant    typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
1486abb160e6SHoward Hinnant    typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
14873e519524SHoward Hinnant    typedef typename allocator_traits<allocator_type>::template
14883e519524SHoward Hinnant#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
14893e519524SHoward Hinnant            rebind_alloc<__value_type>
14903e519524SHoward Hinnant#else
14913e519524SHoward Hinnant            rebind_alloc<__value_type>::other
14923e519524SHoward Hinnant#endif
14933e519524SHoward Hinnant                                                           __allocator_type;
14943e519524SHoward Hinnant
14953e519524SHoward Hinnant    typedef __hash_table<__value_type, __hasher,
14963e519524SHoward Hinnant                         __key_equal,  __allocator_type>   __table;
14973e519524SHoward Hinnant
14983e519524SHoward Hinnant    __table __table_;
14993e519524SHoward Hinnant
15003e519524SHoward Hinnant    typedef typename __table::__node_traits                __node_traits;
15013e519524SHoward Hinnant    typedef typename __table::__node_allocator             __node_allocator;
15023e519524SHoward Hinnant    typedef typename __table::__node                       __node;
1503c003db1fSHoward Hinnant    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
1504c003db1fSHoward Hinnant    typedef unique_ptr<__node, _Dp>                         __node_holder;
15053e519524SHoward Hinnant    typedef allocator_traits<allocator_type>               __alloc_traits;
15063e519524SHoward Hinnantpublic:
15073e519524SHoward Hinnant    typedef typename __alloc_traits::pointer         pointer;
15083e519524SHoward Hinnant    typedef typename __alloc_traits::const_pointer   const_pointer;
15093e519524SHoward Hinnant    typedef typename __alloc_traits::size_type       size_type;
15103e519524SHoward Hinnant    typedef typename __alloc_traits::difference_type difference_type;
15113e519524SHoward Hinnant
15123e519524SHoward Hinnant    typedef __hash_map_iterator<typename __table::iterator>       iterator;
15133e519524SHoward Hinnant    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
15143e519524SHoward Hinnant    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
15153e519524SHoward Hinnant    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
15163e519524SHoward Hinnant
1517789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
15183714107eSHoward Hinnant    unordered_multimap()
15193714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
1520b24c8024SHoward Hinnant        {
1521b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1522b24c8024SHoward Hinnant            __get_db()->__insert_c(this);
1523b24c8024SHoward Hinnant#endif
1524b24c8024SHoward Hinnant        }
15253e519524SHoward Hinnant    explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(),
15263e519524SHoward Hinnant                                const key_equal& __eql = key_equal());
15273e519524SHoward Hinnant    unordered_multimap(size_type __n, const hasher& __hf,
15283e519524SHoward Hinnant                                const key_equal& __eql,
15293e519524SHoward Hinnant                                const allocator_type& __a);
15303e519524SHoward Hinnant    template <class _InputIterator>
15313e519524SHoward Hinnant        unordered_multimap(_InputIterator __first, _InputIterator __last);
15323e519524SHoward Hinnant    template <class _InputIterator>
15333e519524SHoward Hinnant        unordered_multimap(_InputIterator __first, _InputIterator __last,
15343e519524SHoward Hinnant                      size_type __n, const hasher& __hf = hasher(),
15353e519524SHoward Hinnant                      const key_equal& __eql = key_equal());
15363e519524SHoward Hinnant    template <class _InputIterator>
15373e519524SHoward Hinnant        unordered_multimap(_InputIterator __first, _InputIterator __last,
15383e519524SHoward Hinnant                      size_type __n, const hasher& __hf,
15393e519524SHoward Hinnant                      const key_equal& __eql,
15403e519524SHoward Hinnant                      const allocator_type& __a);
15413e519524SHoward Hinnant    explicit unordered_multimap(const allocator_type& __a);
15423e519524SHoward Hinnant    unordered_multimap(const unordered_multimap& __u);
15433e519524SHoward Hinnant    unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
15447609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
15453714107eSHoward Hinnant    unordered_multimap(unordered_multimap&& __u)
15463714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
15473e519524SHoward Hinnant    unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
15487609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
154954976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
15503e519524SHoward Hinnant    unordered_multimap(initializer_list<value_type> __il);
15513e519524SHoward Hinnant    unordered_multimap(initializer_list<value_type> __il, size_type __n,
15523e519524SHoward Hinnant                       const hasher& __hf = hasher(),
15533e519524SHoward Hinnant                       const key_equal& __eql = key_equal());
15543e519524SHoward Hinnant    unordered_multimap(initializer_list<value_type> __il, size_type __n,
15553e519524SHoward Hinnant                       const hasher& __hf, const key_equal& __eql,
15563e519524SHoward Hinnant                       const allocator_type& __a);
155754976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1558*3cd37e64SMarshall Clow#if _LIBCPP_STD_VER > 11
1559*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
1560*3cd37e64SMarshall Clow    unordered_multimap(size_type __n, const allocator_type& __a)
1561*3cd37e64SMarshall Clow      : unordered_multimap(__n, hasher(), key_equal(), __a) {}
1562*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
1563*3cd37e64SMarshall Clow    unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
1564*3cd37e64SMarshall Clow      : unordered_multimap(__n, __hf, key_equal(), __a) {}
1565*3cd37e64SMarshall Clow    template <class _InputIterator>
1566*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
1567*3cd37e64SMarshall Clow      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
1568*3cd37e64SMarshall Clow      : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
1569*3cd37e64SMarshall Clow    template <class _InputIterator>
1570*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
1571*3cd37e64SMarshall Clow      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
1572*3cd37e64SMarshall Clow        const allocator_type& __a)
1573*3cd37e64SMarshall Clow      : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
1574*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
1575*3cd37e64SMarshall Clow    unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1576*3cd37e64SMarshall Clow      : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
1577*3cd37e64SMarshall Clow    _LIBCPP_INLINE_VISIBILITY
1578*3cd37e64SMarshall Clow    unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1579*3cd37e64SMarshall Clow      const allocator_type& __a)
1580*3cd37e64SMarshall Clow      : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
1581*3cd37e64SMarshall Clow#endif
15823e519524SHoward Hinnant    // ~unordered_multimap() = default;
15835a33687dSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
15845a33687dSHoward Hinnant    unordered_multimap& operator=(const unordered_multimap& __u)
15855a33687dSHoward Hinnant    {
1586307f8143SHoward Hinnant#if __cplusplus >= 201103L
15875a33687dSHoward Hinnant        __table_ = __u.__table_;
1588307f8143SHoward Hinnant#else
1589307f8143SHoward Hinnant        __table_.clear();
1590307f8143SHoward Hinnant        __table_.hash_function() = __u.__table_.hash_function();
1591307f8143SHoward Hinnant        __table_.key_eq() = __u.__table_.key_eq();
1592307f8143SHoward Hinnant        __table_.max_load_factor() = __u.__table_.max_load_factor();
1593307f8143SHoward Hinnant        __table_.__copy_assign_alloc(__u.__table_);
1594307f8143SHoward Hinnant        insert(__u.begin(), __u.end());
1595307f8143SHoward Hinnant#endif
15965a33687dSHoward Hinnant        return *this;
15975a33687dSHoward Hinnant    }
15987609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
15993714107eSHoward Hinnant    unordered_multimap& operator=(unordered_multimap&& __u)
16003714107eSHoward Hinnant        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
16013e519524SHoward Hinnant#endif
160254976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
16033e519524SHoward Hinnant    unordered_multimap& operator=(initializer_list<value_type> __il);
160454976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
16053e519524SHoward Hinnant
1606789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16073714107eSHoward Hinnant    allocator_type get_allocator() const _NOEXCEPT
16083e519524SHoward Hinnant        {return allocator_type(__table_.__node_alloc());}
16093e519524SHoward Hinnant
1610789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16113714107eSHoward Hinnant    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
1612789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16133714107eSHoward Hinnant    size_type size() const _NOEXCEPT  {return __table_.size();}
1614789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16153714107eSHoward Hinnant    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
16163e519524SHoward Hinnant
1617789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16183714107eSHoward Hinnant    iterator       begin() _NOEXCEPT        {return __table_.begin();}
1619789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16203714107eSHoward Hinnant    iterator       end() _NOEXCEPT          {return __table_.end();}
1621789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16223714107eSHoward Hinnant    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
1623789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16243714107eSHoward Hinnant    const_iterator end()    const _NOEXCEPT {return __table_.end();}
1625789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16263714107eSHoward Hinnant    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
1627789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16283714107eSHoward Hinnant    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
16293e519524SHoward Hinnant
16307609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
16317609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_VARIADICS
16327609c9b6SHoward Hinnant
16338b805c91SHoward Hinnant    template <class... _Args>
16348b805c91SHoward Hinnant        iterator emplace(_Args&&... __args);
16353e519524SHoward Hinnant
16368b805c91SHoward Hinnant    template <class... _Args>
16378b805c91SHoward Hinnant        iterator emplace_hint(const_iterator __p, _Args&&... __args);
16387609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_VARIADICS
16397609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1640789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16413e519524SHoward Hinnant    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
16427609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1643c003db1fSHoward Hinnant    template <class _Pp,
1644c003db1fSHoward Hinnant              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1645789847ddSHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
1646c003db1fSHoward Hinnant        iterator insert(_Pp&& __x)
1647c003db1fSHoward Hinnant            {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
16487609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1649789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16503e519524SHoward Hinnant    iterator insert(const_iterator __p, const value_type& __x)
16513e519524SHoward Hinnant        {return __table_.__insert_multi(__p.__i_, __x);}
16527609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1653c003db1fSHoward Hinnant    template <class _Pp,
1654c003db1fSHoward Hinnant              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1655789847ddSHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
1656c003db1fSHoward Hinnant        iterator insert(const_iterator __p, _Pp&& __x)
1657c003db1fSHoward Hinnant            {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
16587609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
16593e519524SHoward Hinnant    template <class _InputIterator>
16603e519524SHoward Hinnant        void insert(_InputIterator __first, _InputIterator __last);
166154976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1662789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16633e519524SHoward Hinnant    void insert(initializer_list<value_type> __il)
16643e519524SHoward Hinnant        {insert(__il.begin(), __il.end());}
166554976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
16663e519524SHoward Hinnant
1667789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16683e519524SHoward Hinnant    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
1669789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16703e519524SHoward Hinnant    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
1671789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16723e519524SHoward Hinnant    iterator erase(const_iterator __first, const_iterator __last)
16733e519524SHoward Hinnant        {return __table_.erase(__first.__i_, __last.__i_);}
1674789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16753714107eSHoward Hinnant    void clear() _NOEXCEPT {__table_.clear();}
16763e519524SHoward Hinnant
1677789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16783714107eSHoward Hinnant    void swap(unordered_multimap& __u)
16793714107eSHoward Hinnant        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
16803714107eSHoward Hinnant        {__table_.swap(__u.__table_);}
16813e519524SHoward Hinnant
1682789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16833e519524SHoward Hinnant    hasher hash_function() const
16843e519524SHoward Hinnant        {return __table_.hash_function().hash_function();}
1685789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16863e519524SHoward Hinnant    key_equal key_eq() const
16873e519524SHoward Hinnant        {return __table_.key_eq().key_eq();}
16883e519524SHoward Hinnant
1689789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16903e519524SHoward Hinnant    iterator       find(const key_type& __k)       {return __table_.find(__k);}
1691789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16923e519524SHoward Hinnant    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1693789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16943e519524SHoward Hinnant    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
1695789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16963e519524SHoward Hinnant    pair<iterator, iterator>             equal_range(const key_type& __k)
16973e519524SHoward Hinnant        {return __table_.__equal_range_multi(__k);}
1698789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
16993e519524SHoward Hinnant    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
17003e519524SHoward Hinnant        {return __table_.__equal_range_multi(__k);}
17013e519524SHoward Hinnant
1702789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17033714107eSHoward Hinnant    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
1704789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17053714107eSHoward Hinnant    size_type max_bucket_count() const _NOEXCEPT
17063714107eSHoward Hinnant        {return __table_.max_bucket_count();}
17073e519524SHoward Hinnant
1708789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17093e519524SHoward Hinnant    size_type bucket_size(size_type __n) const
17103e519524SHoward Hinnant        {return __table_.bucket_size(__n);}
1711789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17123e519524SHoward Hinnant    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
17133e519524SHoward Hinnant
1714789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17153e519524SHoward Hinnant    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
1716789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17173e519524SHoward Hinnant    local_iterator       end(size_type __n)          {return __table_.end(__n);}
1718789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17193e519524SHoward Hinnant    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
1720789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17213e519524SHoward Hinnant    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
1722789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17233e519524SHoward Hinnant    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
1724789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17253e519524SHoward Hinnant    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
17263e519524SHoward Hinnant
1727789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17283714107eSHoward Hinnant    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
1729789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17303714107eSHoward Hinnant    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
1731789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17323e519524SHoward Hinnant    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
1733789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17343e519524SHoward Hinnant    void rehash(size_type __n) {__table_.rehash(__n);}
1735789847ddSHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
17363e519524SHoward Hinnant    void reserve(size_type __n) {__table_.reserve(__n);}
17373e519524SHoward Hinnant
1738b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1739b24c8024SHoward Hinnant
1740b24c8024SHoward Hinnant    bool __dereferenceable(const const_iterator* __i) const
1741b24c8024SHoward Hinnant        {return __table_.__dereferenceable(&__i->__i_);}
1742b24c8024SHoward Hinnant    bool __decrementable(const const_iterator* __i) const
1743b24c8024SHoward Hinnant        {return __table_.__decrementable(&__i->__i_);}
1744b24c8024SHoward Hinnant    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1745b24c8024SHoward Hinnant        {return __table_.__addable(&__i->__i_, __n);}
1746b24c8024SHoward Hinnant    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1747b24c8024SHoward Hinnant        {return __table_.__addable(&__i->__i_, __n);}
1748b24c8024SHoward Hinnant
1749b24c8024SHoward Hinnant#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1750b24c8024SHoward Hinnant
17513e519524SHoward Hinnantprivate:
17528b805c91SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
17538b805c91SHoward Hinnant    __node_holder __construct_node();
17548b805c91SHoward Hinnant    template <class _A0>
17558b805c91SHoward Hinnant        __node_holder
17568b805c91SHoward Hinnant         __construct_node(_A0&& __a0);
17578b805c91SHoward Hinnant#ifndef _LIBCPP_HAS_NO_VARIADICS
17588b805c91SHoward Hinnant    template <class _A0, class _A1, class ..._Args>
17598b805c91SHoward Hinnant        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
17608b805c91SHoward Hinnant#endif  // _LIBCPP_HAS_NO_VARIADICS
17618b805c91SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
17623e519524SHoward Hinnant};
17633e519524SHoward Hinnant
17643e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17653e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
17663e519524SHoward Hinnant        size_type __n, const hasher& __hf, const key_equal& __eql)
17673e519524SHoward Hinnant    : __table_(__hf, __eql)
17683e519524SHoward Hinnant{
1769b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1770b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1771b24c8024SHoward Hinnant#endif
17723e519524SHoward Hinnant    __table_.rehash(__n);
17733e519524SHoward Hinnant}
17743e519524SHoward Hinnant
17753e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17763e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
17773e519524SHoward Hinnant        size_type __n, const hasher& __hf, const key_equal& __eql,
17783e519524SHoward Hinnant        const allocator_type& __a)
17793e519524SHoward Hinnant    : __table_(__hf, __eql, __a)
17803e519524SHoward Hinnant{
1781b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1782b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1783b24c8024SHoward Hinnant#endif
17843e519524SHoward Hinnant    __table_.rehash(__n);
17853e519524SHoward Hinnant}
17863e519524SHoward Hinnant
17873e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17883e519524SHoward Hinnanttemplate <class _InputIterator>
17893e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
17903e519524SHoward Hinnant        _InputIterator __first, _InputIterator __last)
17913e519524SHoward Hinnant{
1792b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1793b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1794b24c8024SHoward Hinnant#endif
17953e519524SHoward Hinnant    insert(__first, __last);
17963e519524SHoward Hinnant}
17973e519524SHoward Hinnant
17983e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
17993e519524SHoward Hinnanttemplate <class _InputIterator>
18003e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
18013e519524SHoward Hinnant        _InputIterator __first, _InputIterator __last, size_type __n,
18023e519524SHoward Hinnant        const hasher& __hf, const key_equal& __eql)
18033e519524SHoward Hinnant    : __table_(__hf, __eql)
18043e519524SHoward Hinnant{
1805b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1806b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1807b24c8024SHoward Hinnant#endif
18083e519524SHoward Hinnant    __table_.rehash(__n);
18093e519524SHoward Hinnant    insert(__first, __last);
18103e519524SHoward Hinnant}
18113e519524SHoward Hinnant
18123e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18133e519524SHoward Hinnanttemplate <class _InputIterator>
18143e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
18153e519524SHoward Hinnant        _InputIterator __first, _InputIterator __last, size_type __n,
18163e519524SHoward Hinnant        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
18173e519524SHoward Hinnant    : __table_(__hf, __eql, __a)
18183e519524SHoward Hinnant{
1819b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1820b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1821b24c8024SHoward Hinnant#endif
18223e519524SHoward Hinnant    __table_.rehash(__n);
18233e519524SHoward Hinnant    insert(__first, __last);
18243e519524SHoward Hinnant}
18253e519524SHoward Hinnant
18263e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1827789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
18283e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
18293e519524SHoward Hinnant        const allocator_type& __a)
18303e519524SHoward Hinnant    : __table_(__a)
18313e519524SHoward Hinnant{
1832b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1833b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1834b24c8024SHoward Hinnant#endif
18353e519524SHoward Hinnant}
18363e519524SHoward Hinnant
18373e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18383e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
18393e519524SHoward Hinnant        const unordered_multimap& __u)
18403e519524SHoward Hinnant    : __table_(__u.__table_)
18413e519524SHoward Hinnant{
1842b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1843b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1844b24c8024SHoward Hinnant#endif
18453e519524SHoward Hinnant    __table_.rehash(__u.bucket_count());
18463e519524SHoward Hinnant    insert(__u.begin(), __u.end());
18473e519524SHoward Hinnant}
18483e519524SHoward Hinnant
18493e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18503e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
18513e519524SHoward Hinnant        const unordered_multimap& __u, const allocator_type& __a)
18523e519524SHoward Hinnant    : __table_(__u.__table_, __a)
18533e519524SHoward Hinnant{
1854b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1855b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1856b24c8024SHoward Hinnant#endif
18573e519524SHoward Hinnant    __table_.rehash(__u.bucket_count());
18583e519524SHoward Hinnant    insert(__u.begin(), __u.end());
18593e519524SHoward Hinnant}
18603e519524SHoward Hinnant
18617609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
18623e519524SHoward Hinnant
18633e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1864789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
18653e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
18663e519524SHoward Hinnant        unordered_multimap&& __u)
18673714107eSHoward Hinnant    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1868ce48a113SHoward Hinnant    : __table_(_VSTD::move(__u.__table_))
18693e519524SHoward Hinnant{
1870b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1871b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
18724c80bfbdSHoward Hinnant    __get_db()->swap(this, &__u);
1873b24c8024SHoward Hinnant#endif
18743e519524SHoward Hinnant}
18753e519524SHoward Hinnant
18763e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
18773e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
18783e519524SHoward Hinnant        unordered_multimap&& __u, const allocator_type& __a)
1879ce48a113SHoward Hinnant    : __table_(_VSTD::move(__u.__table_), __a)
18803e519524SHoward Hinnant{
1881b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1882b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1883b24c8024SHoward Hinnant#endif
18843e519524SHoward Hinnant    if (__a != __u.get_allocator())
18853e519524SHoward Hinnant    {
18863e519524SHoward Hinnant        iterator __i = __u.begin();
18873e519524SHoward Hinnant        while (__u.size() != 0)
18883e519524SHoward Hinnant        {
18893e519524SHoward Hinnant            __table_.__insert_multi(
1890ce48a113SHoward Hinnant                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
18913e519524SHoward Hinnant                                   );
18923e519524SHoward Hinnant        }
18933e519524SHoward Hinnant    }
18944c80bfbdSHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
18954c80bfbdSHoward Hinnant    else
18964c80bfbdSHoward Hinnant        __get_db()->swap(this, &__u);
18974c80bfbdSHoward Hinnant#endif
18983e519524SHoward Hinnant}
18993e519524SHoward Hinnant
19007609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
19013e519524SHoward Hinnant
190254976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
190354976f26SHoward Hinnant
19043e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19053e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
19063e519524SHoward Hinnant        initializer_list<value_type> __il)
19073e519524SHoward Hinnant{
1908b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1909b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1910b24c8024SHoward Hinnant#endif
19113e519524SHoward Hinnant    insert(__il.begin(), __il.end());
19123e519524SHoward Hinnant}
19133e519524SHoward Hinnant
19143e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19153e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
19163e519524SHoward Hinnant        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
19173e519524SHoward Hinnant        const key_equal& __eql)
19183e519524SHoward Hinnant    : __table_(__hf, __eql)
19193e519524SHoward Hinnant{
1920b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1921b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1922b24c8024SHoward Hinnant#endif
19233e519524SHoward Hinnant    __table_.rehash(__n);
19243e519524SHoward Hinnant    insert(__il.begin(), __il.end());
19253e519524SHoward Hinnant}
19263e519524SHoward Hinnant
19273e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19283e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
19293e519524SHoward Hinnant        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
19303e519524SHoward Hinnant        const key_equal& __eql, const allocator_type& __a)
19313e519524SHoward Hinnant    : __table_(__hf, __eql, __a)
19323e519524SHoward Hinnant{
1933b24c8024SHoward Hinnant#if _LIBCPP_DEBUG_LEVEL >= 2
1934b24c8024SHoward Hinnant    __get_db()->__insert_c(this);
1935b24c8024SHoward Hinnant#endif
19363e519524SHoward Hinnant    __table_.rehash(__n);
19373e519524SHoward Hinnant    insert(__il.begin(), __il.end());
19383e519524SHoward Hinnant}
19393e519524SHoward Hinnant
194054976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
194154976f26SHoward Hinnant
19427609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
19433e519524SHoward Hinnant
19443e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1945789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
19463e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
19473e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
19483714107eSHoward Hinnant    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
19493e519524SHoward Hinnant{
1950ce48a113SHoward Hinnant    __table_ = _VSTD::move(__u.__table_);
19513e519524SHoward Hinnant    return *this;
19523e519524SHoward Hinnant}
19533e519524SHoward Hinnant
19547609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
19553e519524SHoward Hinnant
195654976f26SHoward Hinnant#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
195754976f26SHoward Hinnant
19583e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1959789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
19603e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
19613e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
19623e519524SHoward Hinnant        initializer_list<value_type> __il)
19633e519524SHoward Hinnant{
19643e519524SHoward Hinnant    __table_.__assign_multi(__il.begin(), __il.end());
19653e519524SHoward Hinnant    return *this;
19663e519524SHoward Hinnant}
19673e519524SHoward Hinnant
196854976f26SHoward Hinnant#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
196954976f26SHoward Hinnant
19707609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
19713e519524SHoward Hinnant
19723e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19733e519524SHoward Hinnanttypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
19748b805c91SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
19753e519524SHoward Hinnant{
19763e519524SHoward Hinnant    __node_allocator& __na = __table_.__node_alloc();
1977c003db1fSHoward Hinnant    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
19788b805c91SHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_));
19793e519524SHoward Hinnant    __h.get_deleter().__first_constructed = true;
19803e519524SHoward Hinnant    __h.get_deleter().__second_constructed = true;
19813e519524SHoward Hinnant    return __h;
19823e519524SHoward Hinnant}
19833e519524SHoward Hinnant
19843e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
19858b805c91SHoward Hinnanttemplate <class _A0>
19863e519524SHoward Hinnanttypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
19873e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
19883e519524SHoward Hinnant{
19893e519524SHoward Hinnant    __node_allocator& __na = __table_.__node_alloc();
1990c003db1fSHoward Hinnant    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1991ce48a113SHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
1992ce48a113SHoward Hinnant                             _VSTD::forward<_A0>(__a0));
19933e519524SHoward Hinnant    __h.get_deleter().__first_constructed = true;
19943e519524SHoward Hinnant    __h.get_deleter().__second_constructed = true;
19953e519524SHoward Hinnant    return __h;
19963e519524SHoward Hinnant}
19973e519524SHoward Hinnant
19987609c9b6SHoward Hinnant#ifndef _LIBCPP_HAS_NO_VARIADICS
19997609c9b6SHoward Hinnant
20003e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
20018b805c91SHoward Hinnanttemplate <class _A0, class _A1, class ..._Args>
20028b805c91SHoward Hinnanttypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
20038b805c91SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(
20048b805c91SHoward Hinnant        _A0&& __a0, _A1&& __a1, _Args&&... __args)
20053e519524SHoward Hinnant{
20068b805c91SHoward Hinnant    __node_allocator& __na = __table_.__node_alloc();
20078b805c91SHoward Hinnant    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
20088b805c91SHoward Hinnant    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
20098b805c91SHoward Hinnant                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
2010ce48a113SHoward Hinnant                             _VSTD::forward<_Args>(__args)...);
20118b805c91SHoward Hinnant    __h.get_deleter().__first_constructed = true;
20128b805c91SHoward Hinnant    __h.get_deleter().__second_constructed = true;
20138b805c91SHoward Hinnant    return __h;
20148b805c91SHoward Hinnant}
20158b805c91SHoward Hinnant
20168b805c91SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
20178b805c91SHoward Hinnanttemplate <class... _Args>
20188b805c91SHoward Hinnanttypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator
20198b805c91SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
20208b805c91SHoward Hinnant{
20218b805c91SHoward Hinnant    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
20223e519524SHoward Hinnant    iterator __r = __table_.__node_insert_multi(__h.get());
20233e519524SHoward Hinnant    __h.release();
20243e519524SHoward Hinnant    return __r;
20253e519524SHoward Hinnant}
20263e519524SHoward Hinnant
20273e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
20288b805c91SHoward Hinnanttemplate <class... _Args>
20293e519524SHoward Hinnanttypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator
20303e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace_hint(
20318b805c91SHoward Hinnant        const_iterator __p, _Args&&... __args)
20323e519524SHoward Hinnant{
20338b805c91SHoward Hinnant    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
20343e519524SHoward Hinnant    iterator __r = __table_.__node_insert_multi(__p.__i_, __h.get());
20353e519524SHoward Hinnant    __h.release();
20363e519524SHoward Hinnant    return __r;
20373e519524SHoward Hinnant}
20383e519524SHoward Hinnant
20397609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_VARIADICS
20407609c9b6SHoward Hinnant#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
20413e519524SHoward Hinnant
20423e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
20433e519524SHoward Hinnanttemplate <class _InputIterator>
2044789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
20453e519524SHoward Hinnantvoid
20463e519524SHoward Hinnantunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
20473e519524SHoward Hinnant                                                            _InputIterator __last)
20483e519524SHoward Hinnant{
20493e519524SHoward Hinnant    for (; __first != __last; ++__first)
20503e519524SHoward Hinnant        __table_.__insert_multi(*__first);
20513e519524SHoward Hinnant}
20523e519524SHoward Hinnant
20533e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2054789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
20553e519524SHoward Hinnantvoid
20563e519524SHoward Hinnantswap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
20573e519524SHoward Hinnant     unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
20583714107eSHoward Hinnant    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
20593e519524SHoward Hinnant{
20603e519524SHoward Hinnant    __x.swap(__y);
20613e519524SHoward Hinnant}
20623e519524SHoward Hinnant
20633e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
20643e519524SHoward Hinnantbool
20653e519524SHoward Hinnantoperator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
20663e519524SHoward Hinnant           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
20673e519524SHoward Hinnant{
20683e519524SHoward Hinnant    if (__x.size() != __y.size())
20693e519524SHoward Hinnant        return false;
20703e519524SHoward Hinnant    typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
20713e519524SHoward Hinnant                                                                 const_iterator;
20723e519524SHoward Hinnant    typedef pair<const_iterator, const_iterator> _EqRng;
20733e519524SHoward Hinnant    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
20743e519524SHoward Hinnant    {
20753e519524SHoward Hinnant        _EqRng __xeq = __x.equal_range(__i->first);
20763e519524SHoward Hinnant        _EqRng __yeq = __y.equal_range(__i->first);
2077ce48a113SHoward Hinnant        if (_VSTD::distance(__xeq.first, __xeq.second) !=
2078ce48a113SHoward Hinnant            _VSTD::distance(__yeq.first, __yeq.second) ||
2079ce48a113SHoward Hinnant                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
20803e519524SHoward Hinnant            return false;
20813e519524SHoward Hinnant        __i = __xeq.second;
20823e519524SHoward Hinnant    }
20833e519524SHoward Hinnant    return true;
20843e519524SHoward Hinnant}
20853e519524SHoward Hinnant
20863e519524SHoward Hinnanttemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2087789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
20883e519524SHoward Hinnantbool
20893e519524SHoward Hinnantoperator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
20903e519524SHoward Hinnant           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
20913e519524SHoward Hinnant{
20923e519524SHoward Hinnant    return !(__x == __y);
20933e519524SHoward Hinnant}
20943e519524SHoward Hinnant
20953e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD
20963e519524SHoward Hinnant
20973e519524SHoward Hinnant#endif  // _LIBCPP_UNORDERED_MAP
2098