xref: /freebsd/contrib/llvm-project/libcxx/include/unordered_map (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric// -*- C++ -*-
2*0b57cec5SDimitry Andric//===-------------------------- unordered_map -----------------------------===//
3*0b57cec5SDimitry Andric//
4*0b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*0b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
6*0b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*0b57cec5SDimitry Andric//
8*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9*0b57cec5SDimitry Andric
10*0b57cec5SDimitry Andric#ifndef _LIBCPP_UNORDERED_MAP
11*0b57cec5SDimitry Andric#define _LIBCPP_UNORDERED_MAP
12*0b57cec5SDimitry Andric
13*0b57cec5SDimitry Andric/*
14*0b57cec5SDimitry Andric
15*0b57cec5SDimitry Andric    unordered_map synopsis
16*0b57cec5SDimitry Andric
17*0b57cec5SDimitry Andric#include <initializer_list>
18*0b57cec5SDimitry Andric
19*0b57cec5SDimitry Andricnamespace std
20*0b57cec5SDimitry Andric{
21*0b57cec5SDimitry Andric
22*0b57cec5SDimitry Andrictemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
23*0b57cec5SDimitry Andric          class Alloc = allocator<pair<const Key, T>>>
24*0b57cec5SDimitry Andricclass unordered_map
25*0b57cec5SDimitry Andric{
26*0b57cec5SDimitry Andricpublic:
27*0b57cec5SDimitry Andric    // types
28*0b57cec5SDimitry Andric    typedef Key                                                        key_type;
29*0b57cec5SDimitry Andric    typedef T                                                          mapped_type;
30*0b57cec5SDimitry Andric    typedef Hash                                                       hasher;
31*0b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
32*0b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
33*0b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>                          value_type;
34*0b57cec5SDimitry Andric    typedef value_type&                                                reference;
35*0b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
36*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
37*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
38*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
39*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
40*0b57cec5SDimitry Andric
41*0b57cec5SDimitry Andric    typedef /unspecified/ iterator;
42*0b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
43*0b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
44*0b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
45*0b57cec5SDimitry Andric
46*0b57cec5SDimitry Andric    typedef unspecified                             node_type;            // C++17
47*0b57cec5SDimitry Andric    typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type;   // C++17
48*0b57cec5SDimitry Andric
49*0b57cec5SDimitry Andric    unordered_map()
50*0b57cec5SDimitry Andric        noexcept(
51*0b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
52*0b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
53*0b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
54*0b57cec5SDimitry Andric    explicit unordered_map(size_type n, const hasher& hf = hasher(),
55*0b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
56*0b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
57*0b57cec5SDimitry Andric    template <class InputIterator>
58*0b57cec5SDimitry Andric        unordered_map(InputIterator f, InputIterator l,
59*0b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
60*0b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
61*0b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
62*0b57cec5SDimitry Andric    explicit unordered_map(const allocator_type&);
63*0b57cec5SDimitry Andric    unordered_map(const unordered_map&);
64*0b57cec5SDimitry Andric    unordered_map(const unordered_map&, const Allocator&);
65*0b57cec5SDimitry Andric    unordered_map(unordered_map&&)
66*0b57cec5SDimitry Andric        noexcept(
67*0b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
68*0b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
69*0b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
70*0b57cec5SDimitry Andric    unordered_map(unordered_map&&, const Allocator&);
71*0b57cec5SDimitry Andric    unordered_map(initializer_list<value_type>, size_type n = 0,
72*0b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
73*0b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
74*0b57cec5SDimitry Andric    unordered_map(size_type n, const allocator_type& a)
75*0b57cec5SDimitry Andric      : unordered_map(n, hasher(), key_equal(), a) {}  // C++14
76*0b57cec5SDimitry Andric    unordered_map(size_type n, const hasher& hf, const allocator_type& a)
77*0b57cec5SDimitry Andric      : unordered_map(n, hf, key_equal(), a) {}  // C++14
78*0b57cec5SDimitry Andric    template <class InputIterator>
79*0b57cec5SDimitry Andric      unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
80*0b57cec5SDimitry Andric      : unordered_map(f, l, n, hasher(), key_equal(), a) {}  // C++14
81*0b57cec5SDimitry Andric    template <class InputIterator>
82*0b57cec5SDimitry Andric      unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
83*0b57cec5SDimitry Andric        const allocator_type& a)
84*0b57cec5SDimitry Andric      : unordered_map(f, l, n, hf, key_equal(), a) {}  // C++14
85*0b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
86*0b57cec5SDimitry Andric      : unordered_map(il, n, hasher(), key_equal(), a) {}  // C++14
87*0b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
88*0b57cec5SDimitry Andric      const allocator_type& a)
89*0b57cec5SDimitry Andric      : unordered_map(il, n, hf, key_equal(), a) {}  // C++14
90*0b57cec5SDimitry Andric    ~unordered_map();
91*0b57cec5SDimitry Andric    unordered_map& operator=(const unordered_map&);
92*0b57cec5SDimitry Andric    unordered_map& operator=(unordered_map&&)
93*0b57cec5SDimitry Andric        noexcept(
94*0b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
95*0b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
96*0b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
97*0b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
98*0b57cec5SDimitry Andric    unordered_map& operator=(initializer_list<value_type>);
99*0b57cec5SDimitry Andric
100*0b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
101*0b57cec5SDimitry Andric
102*0b57cec5SDimitry Andric    bool      empty() const noexcept;
103*0b57cec5SDimitry Andric    size_type size() const noexcept;
104*0b57cec5SDimitry Andric    size_type max_size() const noexcept;
105*0b57cec5SDimitry Andric
106*0b57cec5SDimitry Andric    iterator       begin() noexcept;
107*0b57cec5SDimitry Andric    iterator       end() noexcept;
108*0b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
109*0b57cec5SDimitry Andric    const_iterator end()    const noexcept;
110*0b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
111*0b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
112*0b57cec5SDimitry Andric
113*0b57cec5SDimitry Andric    template <class... Args>
114*0b57cec5SDimitry Andric        pair<iterator, bool> emplace(Args&&... args);
115*0b57cec5SDimitry Andric    template <class... Args>
116*0b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
117*0b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& obj);
118*0b57cec5SDimitry Andric    template <class P>
119*0b57cec5SDimitry Andric        pair<iterator, bool> insert(P&& obj);
120*0b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
121*0b57cec5SDimitry Andric    template <class P>
122*0b57cec5SDimitry Andric        iterator insert(const_iterator hint, P&& obj);
123*0b57cec5SDimitry Andric    template <class InputIterator>
124*0b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
125*0b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
126*0b57cec5SDimitry Andric
127*0b57cec5SDimitry Andric    node_type extract(const_iterator position);                                       // C++17
128*0b57cec5SDimitry Andric    node_type extract(const key_type& x);                                             // C++17
129*0b57cec5SDimitry Andric    insert_return_type insert(node_type&& nh);                                        // C++17
130*0b57cec5SDimitry Andric    iterator           insert(const_iterator hint, node_type&& nh);                   // C++17
131*0b57cec5SDimitry Andric
132*0b57cec5SDimitry Andric    template <class... Args>
133*0b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);          // C++17
134*0b57cec5SDimitry Andric    template <class... Args>
135*0b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);               // C++17
136*0b57cec5SDimitry Andric    template <class... Args>
137*0b57cec5SDimitry Andric        iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
138*0b57cec5SDimitry Andric    template <class... Args>
139*0b57cec5SDimitry Andric        iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);      // C++17
140*0b57cec5SDimitry Andric    template <class M>
141*0b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);            // C++17
142*0b57cec5SDimitry Andric    template <class M>
143*0b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);                 // C++17
144*0b57cec5SDimitry Andric    template <class M>
145*0b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);   // C++17
146*0b57cec5SDimitry Andric    template <class M>
147*0b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);        // C++17
148*0b57cec5SDimitry Andric
149*0b57cec5SDimitry Andric    iterator erase(const_iterator position);
150*0b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
151*0b57cec5SDimitry Andric    size_type erase(const key_type& k);
152*0b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
153*0b57cec5SDimitry Andric    void clear() noexcept;
154*0b57cec5SDimitry Andric
155*0b57cec5SDimitry Andric    template<class H2, class P2>
156*0b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>& source);         // C++17
157*0b57cec5SDimitry Andric    template<class H2, class P2>
158*0b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>&& source);        // C++17
159*0b57cec5SDimitry Andric    template<class H2, class P2>
160*0b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source);    // C++17
161*0b57cec5SDimitry Andric    template<class H2, class P2>
162*0b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source);   // C++17
163*0b57cec5SDimitry Andric
164*0b57cec5SDimitry Andric    void swap(unordered_map&)
165*0b57cec5SDimitry Andric        noexcept(
166*0b57cec5SDimitry Andric            (!allocator_type::propagate_on_container_swap::value ||
167*0b57cec5SDimitry Andric             __is_nothrow_swappable<allocator_type>::value) &&
168*0b57cec5SDimitry Andric            __is_nothrow_swappable<hasher>::value &&
169*0b57cec5SDimitry Andric            __is_nothrow_swappable<key_equal>::value);
170*0b57cec5SDimitry Andric
171*0b57cec5SDimitry Andric    hasher hash_function() const;
172*0b57cec5SDimitry Andric    key_equal key_eq() const;
173*0b57cec5SDimitry Andric
174*0b57cec5SDimitry Andric    iterator       find(const key_type& k);
175*0b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
176*0b57cec5SDimitry Andric    size_type count(const key_type& k) const;
177*0b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
178*0b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
179*0b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
180*0b57cec5SDimitry Andric
181*0b57cec5SDimitry Andric    mapped_type& operator[](const key_type& k);
182*0b57cec5SDimitry Andric    mapped_type& operator[](key_type&& k);
183*0b57cec5SDimitry Andric
184*0b57cec5SDimitry Andric    mapped_type&       at(const key_type& k);
185*0b57cec5SDimitry Andric    const mapped_type& at(const key_type& k) const;
186*0b57cec5SDimitry Andric
187*0b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
188*0b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
189*0b57cec5SDimitry Andric
190*0b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
191*0b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
192*0b57cec5SDimitry Andric
193*0b57cec5SDimitry Andric    local_iterator       begin(size_type n);
194*0b57cec5SDimitry Andric    local_iterator       end(size_type n);
195*0b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
196*0b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
197*0b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
198*0b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
199*0b57cec5SDimitry Andric
200*0b57cec5SDimitry Andric    float load_factor() const noexcept;
201*0b57cec5SDimitry Andric    float max_load_factor() const noexcept;
202*0b57cec5SDimitry Andric    void max_load_factor(float z);
203*0b57cec5SDimitry Andric    void rehash(size_type n);
204*0b57cec5SDimitry Andric    void reserve(size_type n);
205*0b57cec5SDimitry Andric};
206*0b57cec5SDimitry Andric
207*0b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
208*0b57cec5SDimitry Andric    void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
209*0b57cec5SDimitry Andric              unordered_map<Key, T, Hash, Pred, Alloc>& y)
210*0b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
211*0b57cec5SDimitry Andric
212*0b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
213*0b57cec5SDimitry Andric    bool
214*0b57cec5SDimitry Andric    operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
215*0b57cec5SDimitry Andric               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
216*0b57cec5SDimitry Andric
217*0b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
218*0b57cec5SDimitry Andric    bool
219*0b57cec5SDimitry Andric    operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
220*0b57cec5SDimitry Andric               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
221*0b57cec5SDimitry Andric
222*0b57cec5SDimitry Andrictemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
223*0b57cec5SDimitry Andric          class Alloc = allocator<pair<const Key, T>>>
224*0b57cec5SDimitry Andricclass unordered_multimap
225*0b57cec5SDimitry Andric{
226*0b57cec5SDimitry Andricpublic:
227*0b57cec5SDimitry Andric    // types
228*0b57cec5SDimitry Andric    typedef Key                                                        key_type;
229*0b57cec5SDimitry Andric    typedef T                                                          mapped_type;
230*0b57cec5SDimitry Andric    typedef Hash                                                       hasher;
231*0b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
232*0b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
233*0b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>                          value_type;
234*0b57cec5SDimitry Andric    typedef value_type&                                                reference;
235*0b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
236*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
237*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
238*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
239*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
240*0b57cec5SDimitry Andric
241*0b57cec5SDimitry Andric    typedef /unspecified/ iterator;
242*0b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
243*0b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
244*0b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
245*0b57cec5SDimitry Andric
246*0b57cec5SDimitry Andric    typedef unspecified node_type;    // C++17
247*0b57cec5SDimitry Andric
248*0b57cec5SDimitry Andric    unordered_multimap()
249*0b57cec5SDimitry Andric        noexcept(
250*0b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
251*0b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
252*0b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
253*0b57cec5SDimitry Andric    explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
254*0b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
255*0b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
256*0b57cec5SDimitry Andric    template <class InputIterator>
257*0b57cec5SDimitry Andric        unordered_multimap(InputIterator f, InputIterator l,
258*0b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
259*0b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
260*0b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
261*0b57cec5SDimitry Andric    explicit unordered_multimap(const allocator_type&);
262*0b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap&);
263*0b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap&, const Allocator&);
264*0b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&&)
265*0b57cec5SDimitry Andric        noexcept(
266*0b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
267*0b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
268*0b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
269*0b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&&, const Allocator&);
270*0b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type>, size_type n = 0,
271*0b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
272*0b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
273*0b57cec5SDimitry Andric    unordered_multimap(size_type n, const allocator_type& a)
274*0b57cec5SDimitry Andric      : unordered_multimap(n, hasher(), key_equal(), a) {}  // C++14
275*0b57cec5SDimitry Andric    unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
276*0b57cec5SDimitry Andric      : unordered_multimap(n, hf, key_equal(), a) {}  // C++14
277*0b57cec5SDimitry Andric    template <class InputIterator>
278*0b57cec5SDimitry Andric      unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
279*0b57cec5SDimitry Andric      : unordered_multimap(f, l, n, hasher(), key_equal(), a) {}  // C++14
280*0b57cec5SDimitry Andric    template <class InputIterator>
281*0b57cec5SDimitry Andric      unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
282*0b57cec5SDimitry Andric        const allocator_type& a)
283*0b57cec5SDimitry Andric      : unordered_multimap(f, l, n, hf, key_equal(), a) {}  // C++14
284*0b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
285*0b57cec5SDimitry Andric      : unordered_multimap(il, n, hasher(), key_equal(), a) {}  // C++14
286*0b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
287*0b57cec5SDimitry Andric      const allocator_type& a)
288*0b57cec5SDimitry Andric      : unordered_multimap(il, n, hf, key_equal(), a) {}  // C++14
289*0b57cec5SDimitry Andric    ~unordered_multimap();
290*0b57cec5SDimitry Andric    unordered_multimap& operator=(const unordered_multimap&);
291*0b57cec5SDimitry Andric    unordered_multimap& operator=(unordered_multimap&&)
292*0b57cec5SDimitry Andric        noexcept(
293*0b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
294*0b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
295*0b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
296*0b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
297*0b57cec5SDimitry Andric    unordered_multimap& operator=(initializer_list<value_type>);
298*0b57cec5SDimitry Andric
299*0b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
300*0b57cec5SDimitry Andric
301*0b57cec5SDimitry Andric    bool      empty() const noexcept;
302*0b57cec5SDimitry Andric    size_type size() const noexcept;
303*0b57cec5SDimitry Andric    size_type max_size() const noexcept;
304*0b57cec5SDimitry Andric
305*0b57cec5SDimitry Andric    iterator       begin() noexcept;
306*0b57cec5SDimitry Andric    iterator       end() noexcept;
307*0b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
308*0b57cec5SDimitry Andric    const_iterator end()    const noexcept;
309*0b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
310*0b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
311*0b57cec5SDimitry Andric
312*0b57cec5SDimitry Andric    template <class... Args>
313*0b57cec5SDimitry Andric        iterator emplace(Args&&... args);
314*0b57cec5SDimitry Andric    template <class... Args>
315*0b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
316*0b57cec5SDimitry Andric    iterator insert(const value_type& obj);
317*0b57cec5SDimitry Andric    template <class P>
318*0b57cec5SDimitry Andric        iterator insert(P&& obj);
319*0b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
320*0b57cec5SDimitry Andric    template <class P>
321*0b57cec5SDimitry Andric        iterator insert(const_iterator hint, P&& obj);
322*0b57cec5SDimitry Andric    template <class InputIterator>
323*0b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
324*0b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
325*0b57cec5SDimitry Andric
326*0b57cec5SDimitry Andric    node_type extract(const_iterator position);                // C++17
327*0b57cec5SDimitry Andric    node_type extract(const key_type& x);                      // C++17
328*0b57cec5SDimitry Andric    iterator insert(node_type&& nh);                           // C++17
329*0b57cec5SDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);      // C++17
330*0b57cec5SDimitry Andric
331*0b57cec5SDimitry Andric    iterator erase(const_iterator position);
332*0b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
333*0b57cec5SDimitry Andric    size_type erase(const key_type& k);
334*0b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
335*0b57cec5SDimitry Andric    void clear() noexcept;
336*0b57cec5SDimitry Andric
337*0b57cec5SDimitry Andric    template<class H2, class P2>
338*0b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source);    // C++17
339*0b57cec5SDimitry Andric    template<class H2, class P2>
340*0b57cec5SDimitry Andric      void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source);   // C++17
341*0b57cec5SDimitry Andric    template<class H2, class P2>
342*0b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>& source);         // C++17
343*0b57cec5SDimitry Andric    template<class H2, class P2>
344*0b57cec5SDimitry Andric      void merge(unordered_map<Key, T, H2, P2, Allocator>&& source);        // C++17
345*0b57cec5SDimitry Andric
346*0b57cec5SDimitry Andric    void swap(unordered_multimap&)
347*0b57cec5SDimitry Andric        noexcept(
348*0b57cec5SDimitry Andric            (!allocator_type::propagate_on_container_swap::value ||
349*0b57cec5SDimitry Andric             __is_nothrow_swappable<allocator_type>::value) &&
350*0b57cec5SDimitry Andric            __is_nothrow_swappable<hasher>::value &&
351*0b57cec5SDimitry Andric            __is_nothrow_swappable<key_equal>::value);
352*0b57cec5SDimitry Andric
353*0b57cec5SDimitry Andric    hasher hash_function() const;
354*0b57cec5SDimitry Andric    key_equal key_eq() const;
355*0b57cec5SDimitry Andric
356*0b57cec5SDimitry Andric    iterator       find(const key_type& k);
357*0b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
358*0b57cec5SDimitry Andric    size_type count(const key_type& k) const;
359*0b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
360*0b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
361*0b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
362*0b57cec5SDimitry Andric
363*0b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
364*0b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
365*0b57cec5SDimitry Andric
366*0b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
367*0b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
368*0b57cec5SDimitry Andric
369*0b57cec5SDimitry Andric    local_iterator       begin(size_type n);
370*0b57cec5SDimitry Andric    local_iterator       end(size_type n);
371*0b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
372*0b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
373*0b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
374*0b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
375*0b57cec5SDimitry Andric
376*0b57cec5SDimitry Andric    float load_factor() const noexcept;
377*0b57cec5SDimitry Andric    float max_load_factor() const noexcept;
378*0b57cec5SDimitry Andric    void max_load_factor(float z);
379*0b57cec5SDimitry Andric    void rehash(size_type n);
380*0b57cec5SDimitry Andric    void reserve(size_type n);
381*0b57cec5SDimitry Andric};
382*0b57cec5SDimitry Andric
383*0b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
384*0b57cec5SDimitry Andric    void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
385*0b57cec5SDimitry Andric              unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
386*0b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
387*0b57cec5SDimitry Andric
388*0b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
389*0b57cec5SDimitry Andric    void erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred);       // C++20
390*0b57cec5SDimitry Andric
391*0b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
392*0b57cec5SDimitry Andric    void erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred);  // C++20
393*0b57cec5SDimitry Andric
394*0b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
395*0b57cec5SDimitry Andric    bool
396*0b57cec5SDimitry Andric    operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
397*0b57cec5SDimitry Andric               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
398*0b57cec5SDimitry Andric
399*0b57cec5SDimitry Andrictemplate <class Key, class T, class Hash, class Pred, class Alloc>
400*0b57cec5SDimitry Andric    bool
401*0b57cec5SDimitry Andric    operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
402*0b57cec5SDimitry Andric               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
403*0b57cec5SDimitry Andric
404*0b57cec5SDimitry Andric}  // std
405*0b57cec5SDimitry Andric
406*0b57cec5SDimitry Andric*/
407*0b57cec5SDimitry Andric
408*0b57cec5SDimitry Andric#include <__config>
409*0b57cec5SDimitry Andric#include <__hash_table>
410*0b57cec5SDimitry Andric#include <__node_handle>
411*0b57cec5SDimitry Andric#include <functional>
412*0b57cec5SDimitry Andric#include <stdexcept>
413*0b57cec5SDimitry Andric#include <tuple>
414*0b57cec5SDimitry Andric#include <version>
415*0b57cec5SDimitry Andric
416*0b57cec5SDimitry Andric#include <__debug>
417*0b57cec5SDimitry Andric
418*0b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
419*0b57cec5SDimitry Andric#pragma GCC system_header
420*0b57cec5SDimitry Andric#endif
421*0b57cec5SDimitry Andric
422*0b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
423*0b57cec5SDimitry Andric
424*0b57cec5SDimitry Andrictemplate <class _Key, class _Cp, class _Hash,
425*0b57cec5SDimitry Andric          bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
426*0b57cec5SDimitry Andricclass __unordered_map_hasher
427*0b57cec5SDimitry Andric    : private _Hash
428*0b57cec5SDimitry Andric{
429*0b57cec5SDimitry Andricpublic:
430*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
431*0b57cec5SDimitry Andric    __unordered_map_hasher()
432*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
433*0b57cec5SDimitry Andric        : _Hash() {}
434*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
435*0b57cec5SDimitry Andric    __unordered_map_hasher(const _Hash& __h)
436*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
437*0b57cec5SDimitry Andric        : _Hash(__h) {}
438*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
439*0b57cec5SDimitry Andric    const _Hash& hash_function() const _NOEXCEPT {return *this;}
440*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
441*0b57cec5SDimitry Andric    size_t operator()(const _Cp& __x) const
442*0b57cec5SDimitry Andric        {return static_cast<const _Hash&>(*this)(__x.__get_value().first);}
443*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
444*0b57cec5SDimitry Andric    size_t operator()(const _Key& __x) const
445*0b57cec5SDimitry Andric        {return static_cast<const _Hash&>(*this)(__x);}
446*0b57cec5SDimitry Andric    void swap(__unordered_map_hasher&__y)
447*0b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
448*0b57cec5SDimitry Andric    {
449*0b57cec5SDimitry Andric        using _VSTD::swap;
450*0b57cec5SDimitry Andric        swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y));
451*0b57cec5SDimitry Andric    }
452*0b57cec5SDimitry Andric};
453*0b57cec5SDimitry Andric
454*0b57cec5SDimitry Andrictemplate <class _Key, class _Cp, class _Hash>
455*0b57cec5SDimitry Andricclass __unordered_map_hasher<_Key, _Cp, _Hash, false>
456*0b57cec5SDimitry Andric{
457*0b57cec5SDimitry Andric    _Hash __hash_;
458*0b57cec5SDimitry Andricpublic:
459*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
460*0b57cec5SDimitry Andric    __unordered_map_hasher()
461*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
462*0b57cec5SDimitry Andric        : __hash_() {}
463*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
464*0b57cec5SDimitry Andric    __unordered_map_hasher(const _Hash& __h)
465*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
466*0b57cec5SDimitry Andric        : __hash_(__h) {}
467*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
468*0b57cec5SDimitry Andric    const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
469*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
470*0b57cec5SDimitry Andric    size_t operator()(const _Cp& __x) const
471*0b57cec5SDimitry Andric        {return __hash_(__x.__get_value().first);}
472*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
473*0b57cec5SDimitry Andric    size_t operator()(const _Key& __x) const
474*0b57cec5SDimitry Andric        {return __hash_(__x);}
475*0b57cec5SDimitry Andric    void swap(__unordered_map_hasher&__y)
476*0b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
477*0b57cec5SDimitry Andric    {
478*0b57cec5SDimitry Andric        using _VSTD::swap;
479*0b57cec5SDimitry Andric        swap(__hash_, __y.__hash_);
480*0b57cec5SDimitry Andric    }
481*0b57cec5SDimitry Andric};
482*0b57cec5SDimitry Andric
483*0b57cec5SDimitry Andrictemplate <class _Key, class _Cp, class _Hash, bool __b>
484*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
485*0b57cec5SDimitry Andricvoid
486*0b57cec5SDimitry Andricswap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x,
487*0b57cec5SDimitry Andric     __unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y)
488*0b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
489*0b57cec5SDimitry Andric{
490*0b57cec5SDimitry Andric    __x.swap(__y);
491*0b57cec5SDimitry Andric}
492*0b57cec5SDimitry Andric
493*0b57cec5SDimitry Andrictemplate <class _Key, class _Cp, class _Pred,
494*0b57cec5SDimitry Andric          bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
495*0b57cec5SDimitry Andricclass __unordered_map_equal
496*0b57cec5SDimitry Andric    : private _Pred
497*0b57cec5SDimitry Andric{
498*0b57cec5SDimitry Andricpublic:
499*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
500*0b57cec5SDimitry Andric    __unordered_map_equal()
501*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
502*0b57cec5SDimitry Andric        : _Pred() {}
503*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
504*0b57cec5SDimitry Andric    __unordered_map_equal(const _Pred& __p)
505*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
506*0b57cec5SDimitry Andric        : _Pred(__p) {}
507*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
508*0b57cec5SDimitry Andric    const _Pred& key_eq() const _NOEXCEPT {return *this;}
509*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
510*0b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Cp& __y) const
511*0b57cec5SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first);}
512*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
513*0b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Key& __y) const
514*0b57cec5SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);}
515*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
516*0b57cec5SDimitry Andric    bool operator()(const _Key& __x, const _Cp& __y) const
517*0b57cec5SDimitry Andric        {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);}
518*0b57cec5SDimitry Andric    void swap(__unordered_map_equal&__y)
519*0b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
520*0b57cec5SDimitry Andric    {
521*0b57cec5SDimitry Andric        using _VSTD::swap;
522*0b57cec5SDimitry Andric        swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y));
523*0b57cec5SDimitry Andric    }
524*0b57cec5SDimitry Andric};
525*0b57cec5SDimitry Andric
526*0b57cec5SDimitry Andrictemplate <class _Key, class _Cp, class _Pred>
527*0b57cec5SDimitry Andricclass __unordered_map_equal<_Key, _Cp, _Pred, false>
528*0b57cec5SDimitry Andric{
529*0b57cec5SDimitry Andric    _Pred __pred_;
530*0b57cec5SDimitry Andricpublic:
531*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
532*0b57cec5SDimitry Andric    __unordered_map_equal()
533*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
534*0b57cec5SDimitry Andric        : __pred_() {}
535*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
536*0b57cec5SDimitry Andric    __unordered_map_equal(const _Pred& __p)
537*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
538*0b57cec5SDimitry Andric        : __pred_(__p) {}
539*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
540*0b57cec5SDimitry Andric    const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
541*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
542*0b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Cp& __y) const
543*0b57cec5SDimitry Andric        {return __pred_(__x.__get_value().first, __y.__get_value().first);}
544*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
545*0b57cec5SDimitry Andric    bool operator()(const _Cp& __x, const _Key& __y) const
546*0b57cec5SDimitry Andric        {return __pred_(__x.__get_value().first, __y);}
547*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
548*0b57cec5SDimitry Andric    bool operator()(const _Key& __x, const _Cp& __y) const
549*0b57cec5SDimitry Andric        {return __pred_(__x, __y.__get_value().first);}
550*0b57cec5SDimitry Andric    void swap(__unordered_map_equal&__y)
551*0b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
552*0b57cec5SDimitry Andric    {
553*0b57cec5SDimitry Andric        using _VSTD::swap;
554*0b57cec5SDimitry Andric        swap(__pred_, __y.__pred_);
555*0b57cec5SDimitry Andric    }
556*0b57cec5SDimitry Andric};
557*0b57cec5SDimitry Andric
558*0b57cec5SDimitry Andrictemplate <class _Key, class _Cp, class _Pred, bool __b>
559*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
560*0b57cec5SDimitry Andricvoid
561*0b57cec5SDimitry Andricswap(__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x,
562*0b57cec5SDimitry Andric     __unordered_map_equal<_Key, _Cp, _Pred, __b>& __y)
563*0b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
564*0b57cec5SDimitry Andric{
565*0b57cec5SDimitry Andric    __x.swap(__y);
566*0b57cec5SDimitry Andric}
567*0b57cec5SDimitry Andric
568*0b57cec5SDimitry Andrictemplate <class _Alloc>
569*0b57cec5SDimitry Andricclass __hash_map_node_destructor
570*0b57cec5SDimitry Andric{
571*0b57cec5SDimitry Andric    typedef _Alloc                              allocator_type;
572*0b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>    __alloc_traits;
573*0b57cec5SDimitry Andric
574*0b57cec5SDimitry Andricpublic:
575*0b57cec5SDimitry Andric
576*0b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer       pointer;
577*0b57cec5SDimitry Andricprivate:
578*0b57cec5SDimitry Andric
579*0b57cec5SDimitry Andric    allocator_type& __na_;
580*0b57cec5SDimitry Andric
581*0b57cec5SDimitry Andric    __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
582*0b57cec5SDimitry Andric
583*0b57cec5SDimitry Andricpublic:
584*0b57cec5SDimitry Andric    bool __first_constructed;
585*0b57cec5SDimitry Andric    bool __second_constructed;
586*0b57cec5SDimitry Andric
587*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
588*0b57cec5SDimitry Andric    explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
589*0b57cec5SDimitry Andric        : __na_(__na),
590*0b57cec5SDimitry Andric          __first_constructed(false),
591*0b57cec5SDimitry Andric          __second_constructed(false)
592*0b57cec5SDimitry Andric        {}
593*0b57cec5SDimitry Andric
594*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
595*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
596*0b57cec5SDimitry Andric    __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
597*0b57cec5SDimitry Andric        _NOEXCEPT
598*0b57cec5SDimitry Andric        : __na_(__x.__na_),
599*0b57cec5SDimitry Andric          __first_constructed(__x.__value_constructed),
600*0b57cec5SDimitry Andric          __second_constructed(__x.__value_constructed)
601*0b57cec5SDimitry Andric        {
602*0b57cec5SDimitry Andric            __x.__value_constructed = false;
603*0b57cec5SDimitry Andric        }
604*0b57cec5SDimitry Andric#else  // _LIBCPP_CXX03_LANG
605*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
606*0b57cec5SDimitry Andric    __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
607*0b57cec5SDimitry Andric        : __na_(__x.__na_),
608*0b57cec5SDimitry Andric          __first_constructed(__x.__value_constructed),
609*0b57cec5SDimitry Andric          __second_constructed(__x.__value_constructed)
610*0b57cec5SDimitry Andric        {
611*0b57cec5SDimitry Andric            const_cast<bool&>(__x.__value_constructed) = false;
612*0b57cec5SDimitry Andric        }
613*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
614*0b57cec5SDimitry Andric
615*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
616*0b57cec5SDimitry Andric    void operator()(pointer __p) _NOEXCEPT
617*0b57cec5SDimitry Andric    {
618*0b57cec5SDimitry Andric        if (__second_constructed)
619*0b57cec5SDimitry Andric            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
620*0b57cec5SDimitry Andric        if (__first_constructed)
621*0b57cec5SDimitry Andric            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
622*0b57cec5SDimitry Andric        if (__p)
623*0b57cec5SDimitry Andric            __alloc_traits::deallocate(__na_, __p, 1);
624*0b57cec5SDimitry Andric    }
625*0b57cec5SDimitry Andric};
626*0b57cec5SDimitry Andric
627*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
628*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
629*0b57cec5SDimitry Andricstruct __hash_value_type
630*0b57cec5SDimitry Andric{
631*0b57cec5SDimitry Andric    typedef _Key                                     key_type;
632*0b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
633*0b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
634*0b57cec5SDimitry Andric    typedef pair<key_type&, mapped_type&>            __nc_ref_pair_type;
635*0b57cec5SDimitry Andric    typedef pair<key_type&&, mapped_type&&>          __nc_rref_pair_type;
636*0b57cec5SDimitry Andric
637*0b57cec5SDimitry Andricprivate:
638*0b57cec5SDimitry Andric    value_type __cc;
639*0b57cec5SDimitry Andric
640*0b57cec5SDimitry Andricpublic:
641*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
642*0b57cec5SDimitry Andric    value_type& __get_value()
643*0b57cec5SDimitry Andric    {
644*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
645*0b57cec5SDimitry Andric        return *_VSTD::launder(_VSTD::addressof(__cc));
646*0b57cec5SDimitry Andric#else
647*0b57cec5SDimitry Andric        return __cc;
648*0b57cec5SDimitry Andric#endif
649*0b57cec5SDimitry Andric    }
650*0b57cec5SDimitry Andric
651*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
652*0b57cec5SDimitry Andric    const value_type& __get_value() const
653*0b57cec5SDimitry Andric    {
654*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
655*0b57cec5SDimitry Andric        return *_VSTD::launder(_VSTD::addressof(__cc));
656*0b57cec5SDimitry Andric#else
657*0b57cec5SDimitry Andric        return __cc;
658*0b57cec5SDimitry Andric#endif
659*0b57cec5SDimitry Andric    }
660*0b57cec5SDimitry Andric
661*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
662*0b57cec5SDimitry Andric    __nc_ref_pair_type __ref()
663*0b57cec5SDimitry Andric    {
664*0b57cec5SDimitry Andric        value_type& __v = __get_value();
665*0b57cec5SDimitry Andric        return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
666*0b57cec5SDimitry Andric    }
667*0b57cec5SDimitry Andric
668*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
669*0b57cec5SDimitry Andric    __nc_rref_pair_type __move()
670*0b57cec5SDimitry Andric    {
671*0b57cec5SDimitry Andric        value_type& __v = __get_value();
672*0b57cec5SDimitry Andric        return __nc_rref_pair_type(
673*0b57cec5SDimitry Andric            _VSTD::move(const_cast<key_type&>(__v.first)),
674*0b57cec5SDimitry Andric            _VSTD::move(__v.second));
675*0b57cec5SDimitry Andric    }
676*0b57cec5SDimitry Andric
677*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
678*0b57cec5SDimitry Andric    __hash_value_type& operator=(const __hash_value_type& __v)
679*0b57cec5SDimitry Andric    {
680*0b57cec5SDimitry Andric        __ref() = __v.__get_value();
681*0b57cec5SDimitry Andric        return *this;
682*0b57cec5SDimitry Andric    }
683*0b57cec5SDimitry Andric
684*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
685*0b57cec5SDimitry Andric    __hash_value_type& operator=(__hash_value_type&& __v)
686*0b57cec5SDimitry Andric    {
687*0b57cec5SDimitry Andric        __ref() = __v.__move();
688*0b57cec5SDimitry Andric        return *this;
689*0b57cec5SDimitry Andric    }
690*0b57cec5SDimitry Andric
691*0b57cec5SDimitry Andric    template <class _ValueTp,
692*0b57cec5SDimitry Andric              class = typename enable_if<
693*0b57cec5SDimitry Andric                    __is_same_uncvref<_ValueTp, value_type>::value
694*0b57cec5SDimitry Andric                 >::type
695*0b57cec5SDimitry Andric             >
696*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
697*0b57cec5SDimitry Andric    __hash_value_type& operator=(_ValueTp&& __v)
698*0b57cec5SDimitry Andric    {
699*0b57cec5SDimitry Andric        __ref() = _VSTD::forward<_ValueTp>(__v);
700*0b57cec5SDimitry Andric        return *this;
701*0b57cec5SDimitry Andric    }
702*0b57cec5SDimitry Andric
703*0b57cec5SDimitry Andricprivate:
704*0b57cec5SDimitry Andric    __hash_value_type(const __hash_value_type& __v) = delete;
705*0b57cec5SDimitry Andric    __hash_value_type(__hash_value_type&& __v) = delete;
706*0b57cec5SDimitry Andric    template <class ..._Args>
707*0b57cec5SDimitry Andric    explicit __hash_value_type(_Args&& ...__args) = delete;
708*0b57cec5SDimitry Andric
709*0b57cec5SDimitry Andric    ~__hash_value_type() = delete;
710*0b57cec5SDimitry Andric};
711*0b57cec5SDimitry Andric
712*0b57cec5SDimitry Andric#else
713*0b57cec5SDimitry Andric
714*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp>
715*0b57cec5SDimitry Andricstruct __hash_value_type
716*0b57cec5SDimitry Andric{
717*0b57cec5SDimitry Andric    typedef _Key                                     key_type;
718*0b57cec5SDimitry Andric    typedef _Tp                                      mapped_type;
719*0b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>        value_type;
720*0b57cec5SDimitry Andric
721*0b57cec5SDimitry Andricprivate:
722*0b57cec5SDimitry Andric    value_type __cc;
723*0b57cec5SDimitry Andric
724*0b57cec5SDimitry Andricpublic:
725*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
726*0b57cec5SDimitry Andric    value_type& __get_value() { return __cc; }
727*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
728*0b57cec5SDimitry Andric    const value_type& __get_value() const { return __cc; }
729*0b57cec5SDimitry Andric
730*0b57cec5SDimitry Andricprivate:
731*0b57cec5SDimitry Andric   ~__hash_value_type();
732*0b57cec5SDimitry Andric};
733*0b57cec5SDimitry Andric
734*0b57cec5SDimitry Andric#endif
735*0b57cec5SDimitry Andric
736*0b57cec5SDimitry Andrictemplate <class _HashIterator>
737*0b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_iterator
738*0b57cec5SDimitry Andric{
739*0b57cec5SDimitry Andric    _HashIterator __i_;
740*0b57cec5SDimitry Andric
741*0b57cec5SDimitry Andric    typedef  __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
742*0b57cec5SDimitry Andric
743*0b57cec5SDimitry Andricpublic:
744*0b57cec5SDimitry Andric    typedef forward_iterator_tag                                 iterator_category;
745*0b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type                value_type;
746*0b57cec5SDimitry Andric    typedef typename _NodeTypes::difference_type                 difference_type;
747*0b57cec5SDimitry Andric    typedef value_type&                                          reference;
748*0b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type_pointer       pointer;
749*0b57cec5SDimitry Andric
750*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
751*0b57cec5SDimitry Andric    __hash_map_iterator() _NOEXCEPT {}
752*0b57cec5SDimitry Andric
753*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
754*0b57cec5SDimitry Andric    __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
755*0b57cec5SDimitry Andric
756*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
757*0b57cec5SDimitry Andric    reference operator*() const {return __i_->__get_value();}
758*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
759*0b57cec5SDimitry Andric    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
760*0b57cec5SDimitry Andric
761*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
762*0b57cec5SDimitry Andric    __hash_map_iterator& operator++() {++__i_; return *this;}
763*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
764*0b57cec5SDimitry Andric    __hash_map_iterator operator++(int)
765*0b57cec5SDimitry Andric    {
766*0b57cec5SDimitry Andric        __hash_map_iterator __t(*this);
767*0b57cec5SDimitry Andric        ++(*this);
768*0b57cec5SDimitry Andric        return __t;
769*0b57cec5SDimitry Andric    }
770*0b57cec5SDimitry Andric
771*0b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
772*0b57cec5SDimitry Andric        bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
773*0b57cec5SDimitry Andric        {return __x.__i_ == __y.__i_;}
774*0b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
775*0b57cec5SDimitry Andric        bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
776*0b57cec5SDimitry Andric        {return __x.__i_ != __y.__i_;}
777*0b57cec5SDimitry Andric
778*0b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
779*0b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
780*0b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
781*0b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
782*0b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
783*0b57cec5SDimitry Andric};
784*0b57cec5SDimitry Andric
785*0b57cec5SDimitry Andrictemplate <class _HashIterator>
786*0b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator
787*0b57cec5SDimitry Andric{
788*0b57cec5SDimitry Andric    _HashIterator __i_;
789*0b57cec5SDimitry Andric
790*0b57cec5SDimitry Andric    typedef  __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
791*0b57cec5SDimitry Andric
792*0b57cec5SDimitry Andricpublic:
793*0b57cec5SDimitry Andric    typedef forward_iterator_tag                                 iterator_category;
794*0b57cec5SDimitry Andric    typedef typename _NodeTypes::__map_value_type                value_type;
795*0b57cec5SDimitry Andric    typedef typename _NodeTypes::difference_type                 difference_type;
796*0b57cec5SDimitry Andric    typedef const value_type&                                    reference;
797*0b57cec5SDimitry Andric    typedef typename _NodeTypes::__const_map_value_type_pointer  pointer;
798*0b57cec5SDimitry Andric
799*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
800*0b57cec5SDimitry Andric    __hash_map_const_iterator() _NOEXCEPT {}
801*0b57cec5SDimitry Andric
802*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
803*0b57cec5SDimitry Andric    __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
804*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
805*0b57cec5SDimitry Andric    __hash_map_const_iterator(
806*0b57cec5SDimitry Andric            __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
807*0b57cec5SDimitry Andric                 _NOEXCEPT
808*0b57cec5SDimitry Andric                : __i_(__i.__i_) {}
809*0b57cec5SDimitry Andric
810*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
811*0b57cec5SDimitry Andric    reference operator*() const {return __i_->__get_value();}
812*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
813*0b57cec5SDimitry Andric    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());}
814*0b57cec5SDimitry Andric
815*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
816*0b57cec5SDimitry Andric    __hash_map_const_iterator& operator++() {++__i_; return *this;}
817*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
818*0b57cec5SDimitry Andric    __hash_map_const_iterator operator++(int)
819*0b57cec5SDimitry Andric    {
820*0b57cec5SDimitry Andric        __hash_map_const_iterator __t(*this);
821*0b57cec5SDimitry Andric        ++(*this);
822*0b57cec5SDimitry Andric        return __t;
823*0b57cec5SDimitry Andric    }
824*0b57cec5SDimitry Andric
825*0b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
826*0b57cec5SDimitry Andric        bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
827*0b57cec5SDimitry Andric        {return __x.__i_ == __y.__i_;}
828*0b57cec5SDimitry Andric    friend _LIBCPP_INLINE_VISIBILITY
829*0b57cec5SDimitry Andric        bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
830*0b57cec5SDimitry Andric        {return __x.__i_ != __y.__i_;}
831*0b57cec5SDimitry Andric
832*0b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
833*0b57cec5SDimitry Andric    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
834*0b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
835*0b57cec5SDimitry Andric    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
836*0b57cec5SDimitry Andric};
837*0b57cec5SDimitry Andric
838*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
839*0b57cec5SDimitry Andricclass unordered_multimap;
840*0b57cec5SDimitry Andric
841*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
842*0b57cec5SDimitry Andric          class _Alloc = allocator<pair<const _Key, _Tp> > >
843*0b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_map
844*0b57cec5SDimitry Andric{
845*0b57cec5SDimitry Andricpublic:
846*0b57cec5SDimitry Andric    // types
847*0b57cec5SDimitry Andric    typedef _Key                                           key_type;
848*0b57cec5SDimitry Andric    typedef _Tp                                            mapped_type;
849*0b57cec5SDimitry Andric    typedef typename __identity<_Hash>::type               hasher;
850*0b57cec5SDimitry Andric    typedef typename __identity<_Pred>::type               key_equal;
851*0b57cec5SDimitry Andric    typedef typename __identity<_Alloc>::type              allocator_type;
852*0b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>              value_type;
853*0b57cec5SDimitry Andric    typedef value_type&                                    reference;
854*0b57cec5SDimitry Andric    typedef const value_type&                              const_reference;
855*0b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
856*0b57cec5SDimitry Andric                  "Invalid allocator::value_type");
857*0b57cec5SDimitry Andric
858*0b57cec5SDimitry Andricprivate:
859*0b57cec5SDimitry Andric    typedef __hash_value_type<key_type, mapped_type>                 __value_type;
860*0b57cec5SDimitry Andric    typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
861*0b57cec5SDimitry Andric    typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
862*0b57cec5SDimitry Andric    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
863*0b57cec5SDimitry Andric                                                 __value_type>::type __allocator_type;
864*0b57cec5SDimitry Andric
865*0b57cec5SDimitry Andric    typedef __hash_table<__value_type, __hasher,
866*0b57cec5SDimitry Andric                         __key_equal,  __allocator_type>   __table;
867*0b57cec5SDimitry Andric
868*0b57cec5SDimitry Andric    __table __table_;
869*0b57cec5SDimitry Andric
870*0b57cec5SDimitry Andric    typedef typename __table::_NodeTypes                   _NodeTypes;
871*0b57cec5SDimitry Andric    typedef typename __table::__node_pointer               __node_pointer;
872*0b57cec5SDimitry Andric    typedef typename __table::__node_const_pointer         __node_const_pointer;
873*0b57cec5SDimitry Andric    typedef typename __table::__node_traits                __node_traits;
874*0b57cec5SDimitry Andric    typedef typename __table::__node_allocator             __node_allocator;
875*0b57cec5SDimitry Andric    typedef typename __table::__node                       __node;
876*0b57cec5SDimitry Andric    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
877*0b57cec5SDimitry Andric    typedef unique_ptr<__node, _Dp>                         __node_holder;
878*0b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>               __alloc_traits;
879*0b57cec5SDimitry Andric
880*0b57cec5SDimitry Andric    static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");
881*0b57cec5SDimitry Andric    static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");
882*0b57cec5SDimitry Andricpublic:
883*0b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer         pointer;
884*0b57cec5SDimitry Andric    typedef typename __alloc_traits::const_pointer   const_pointer;
885*0b57cec5SDimitry Andric    typedef typename __table::size_type              size_type;
886*0b57cec5SDimitry Andric    typedef typename __table::difference_type        difference_type;
887*0b57cec5SDimitry Andric
888*0b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::iterator>       iterator;
889*0b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
890*0b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
891*0b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
892*0b57cec5SDimitry Andric
893*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
894*0b57cec5SDimitry Andric    typedef __map_node_handle<__node, allocator_type> node_type;
895*0b57cec5SDimitry Andric    typedef __insert_return_type<iterator, node_type> insert_return_type;
896*0b57cec5SDimitry Andric#endif
897*0b57cec5SDimitry Andric
898*0b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
899*0b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_map;
900*0b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
901*0b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
902*0b57cec5SDimitry Andric
903*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
904*0b57cec5SDimitry Andric    unordered_map()
905*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
906*0b57cec5SDimitry Andric        {
907*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
908*0b57cec5SDimitry Andric            __get_db()->__insert_c(this);
909*0b57cec5SDimitry Andric#endif
910*0b57cec5SDimitry Andric        }
911*0b57cec5SDimitry Andric    explicit unordered_map(size_type __n, const hasher& __hf = hasher(),
912*0b57cec5SDimitry Andric                           const key_equal& __eql = key_equal());
913*0b57cec5SDimitry Andric    unordered_map(size_type __n, const hasher& __hf,
914*0b57cec5SDimitry Andric                  const key_equal& __eql,
915*0b57cec5SDimitry Andric                  const allocator_type& __a);
916*0b57cec5SDimitry Andric    template <class _InputIterator>
917*0b57cec5SDimitry Andric        unordered_map(_InputIterator __first, _InputIterator __last);
918*0b57cec5SDimitry Andric    template <class _InputIterator>
919*0b57cec5SDimitry Andric        unordered_map(_InputIterator __first, _InputIterator __last,
920*0b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
921*0b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
922*0b57cec5SDimitry Andric    template <class _InputIterator>
923*0b57cec5SDimitry Andric        unordered_map(_InputIterator __first, _InputIterator __last,
924*0b57cec5SDimitry Andric                      size_type __n, const hasher& __hf,
925*0b57cec5SDimitry Andric                      const key_equal& __eql,
926*0b57cec5SDimitry Andric                      const allocator_type& __a);
927*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
928*0b57cec5SDimitry Andric    explicit unordered_map(const allocator_type& __a);
929*0b57cec5SDimitry Andric    unordered_map(const unordered_map& __u);
930*0b57cec5SDimitry Andric    unordered_map(const unordered_map& __u, const allocator_type& __a);
931*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
932*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
933*0b57cec5SDimitry Andric    unordered_map(unordered_map&& __u)
934*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
935*0b57cec5SDimitry Andric    unordered_map(unordered_map&& __u, const allocator_type& __a);
936*0b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il);
937*0b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n,
938*0b57cec5SDimitry Andric                  const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
939*0b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n,
940*0b57cec5SDimitry Andric                  const hasher& __hf, const key_equal& __eql,
941*0b57cec5SDimitry Andric                  const allocator_type& __a);
942*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
943*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
944*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
945*0b57cec5SDimitry Andric    unordered_map(size_type __n, const allocator_type& __a)
946*0b57cec5SDimitry Andric      : unordered_map(__n, hasher(), key_equal(), __a) {}
947*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
948*0b57cec5SDimitry Andric    unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
949*0b57cec5SDimitry Andric      : unordered_map(__n, __hf, key_equal(), __a) {}
950*0b57cec5SDimitry Andric    template <class _InputIterator>
951*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
952*0b57cec5SDimitry Andric      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
953*0b57cec5SDimitry Andric      : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
954*0b57cec5SDimitry Andric    template <class _InputIterator>
955*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
956*0b57cec5SDimitry Andric      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
957*0b57cec5SDimitry Andric        const allocator_type& __a)
958*0b57cec5SDimitry Andric      : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
959*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
960*0b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
961*0b57cec5SDimitry Andric      : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
962*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
963*0b57cec5SDimitry Andric    unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
964*0b57cec5SDimitry Andric      const allocator_type& __a)
965*0b57cec5SDimitry Andric      : unordered_map(__il, __n, __hf, key_equal(), __a) {}
966*0b57cec5SDimitry Andric#endif
967*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
968*0b57cec5SDimitry Andric    ~unordered_map() {
969*0b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
970*0b57cec5SDimitry Andric    }
971*0b57cec5SDimitry Andric
972*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
973*0b57cec5SDimitry Andric    unordered_map& operator=(const unordered_map& __u)
974*0b57cec5SDimitry Andric    {
975*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
976*0b57cec5SDimitry Andric        __table_ = __u.__table_;
977*0b57cec5SDimitry Andric#else
978*0b57cec5SDimitry Andric        if (this != &__u) {
979*0b57cec5SDimitry Andric            __table_.clear();
980*0b57cec5SDimitry Andric            __table_.hash_function() = __u.__table_.hash_function();
981*0b57cec5SDimitry Andric            __table_.key_eq() = __u.__table_.key_eq();
982*0b57cec5SDimitry Andric            __table_.max_load_factor() = __u.__table_.max_load_factor();
983*0b57cec5SDimitry Andric            __table_.__copy_assign_alloc(__u.__table_);
984*0b57cec5SDimitry Andric            insert(__u.begin(), __u.end());
985*0b57cec5SDimitry Andric        }
986*0b57cec5SDimitry Andric#endif
987*0b57cec5SDimitry Andric        return *this;
988*0b57cec5SDimitry Andric    }
989*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
990*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
991*0b57cec5SDimitry Andric    unordered_map& operator=(unordered_map&& __u)
992*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
993*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
994*0b57cec5SDimitry Andric    unordered_map& operator=(initializer_list<value_type> __il);
995*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
996*0b57cec5SDimitry Andric
997*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
998*0b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
999*0b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
1000*0b57cec5SDimitry Andric
1001*0b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
1002*0b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
1003*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1004*0b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
1005*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1006*0b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
1007*0b57cec5SDimitry Andric
1008*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1009*0b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
1010*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1011*0b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
1012*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1013*0b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
1014*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1015*0b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
1016*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1017*0b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
1018*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1019*0b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
1020*0b57cec5SDimitry Andric
1021*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1022*0b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& __x)
1023*0b57cec5SDimitry Andric        {return __table_.__insert_unique(__x);}
1024*0b57cec5SDimitry Andric
1025*0b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __x) {
1026*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1027*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1028*0b57cec5SDimitry Andric            "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
1029*0b57cec5SDimitry Andric            " referring to this unordered_map");
1030*0b57cec5SDimitry Andric#else
1031*0b57cec5SDimitry Andric        ((void)__p);
1032*0b57cec5SDimitry Andric#endif
1033*0b57cec5SDimitry Andric        return insert(__x).first;
1034*0b57cec5SDimitry Andric    }
1035*0b57cec5SDimitry Andric
1036*0b57cec5SDimitry Andric    template <class _InputIterator>
1037*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1038*0b57cec5SDimitry Andric        void insert(_InputIterator __first, _InputIterator __last);
1039*0b57cec5SDimitry Andric
1040*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1041*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1042*0b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
1043*0b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
1044*0b57cec5SDimitry Andric
1045*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1046*0b57cec5SDimitry Andric    pair<iterator, bool> insert(value_type&& __x)
1047*0b57cec5SDimitry Andric        {return __table_.__insert_unique(_VSTD::move(__x));}
1048*0b57cec5SDimitry Andric
1049*0b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __x) {
1050*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1051*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1052*0b57cec5SDimitry Andric            "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
1053*0b57cec5SDimitry Andric            " referring to this unordered_map");
1054*0b57cec5SDimitry Andric#else
1055*0b57cec5SDimitry Andric        ((void)__p);
1056*0b57cec5SDimitry Andric#endif
1057*0b57cec5SDimitry Andric        return __table_.__insert_unique(_VSTD::move(__x)).first;
1058*0b57cec5SDimitry Andric    }
1059*0b57cec5SDimitry Andric
1060*0b57cec5SDimitry Andric    template <class _Pp,
1061*0b57cec5SDimitry Andric              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1062*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1063*0b57cec5SDimitry Andric        pair<iterator, bool> insert(_Pp&& __x)
1064*0b57cec5SDimitry Andric            {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
1065*0b57cec5SDimitry Andric
1066*0b57cec5SDimitry Andric    template <class _Pp,
1067*0b57cec5SDimitry Andric              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1068*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1069*0b57cec5SDimitry Andric        iterator insert(const_iterator __p, _Pp&& __x)
1070*0b57cec5SDimitry Andric        {
1071*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1072*0b57cec5SDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1073*0b57cec5SDimitry Andric                "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
1074*0b57cec5SDimitry Andric                " referring to this unordered_map");
1075*0b57cec5SDimitry Andric#else
1076*0b57cec5SDimitry Andric          ((void)__p);
1077*0b57cec5SDimitry Andric#endif
1078*0b57cec5SDimitry Andric            return insert(_VSTD::forward<_Pp>(__x)).first;
1079*0b57cec5SDimitry Andric        }
1080*0b57cec5SDimitry Andric
1081*0b57cec5SDimitry Andric    template <class... _Args>
1082*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1083*0b57cec5SDimitry Andric    pair<iterator, bool> emplace(_Args&&... __args) {
1084*0b57cec5SDimitry Andric        return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);
1085*0b57cec5SDimitry Andric    }
1086*0b57cec5SDimitry Andric
1087*0b57cec5SDimitry Andric    template <class... _Args>
1088*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1089*0b57cec5SDimitry Andric    iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1090*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1091*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1092*0b57cec5SDimitry Andric            "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
1093*0b57cec5SDimitry Andric            " referring to this unordered_map");
1094*0b57cec5SDimitry Andric#else
1095*0b57cec5SDimitry Andric          ((void)__p);
1096*0b57cec5SDimitry Andric#endif
1097*0b57cec5SDimitry Andric        return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
1098*0b57cec5SDimitry Andric    }
1099*0b57cec5SDimitry Andric
1100*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1101*0b57cec5SDimitry Andric
1102*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
1103*0b57cec5SDimitry Andric    template <class... _Args>
1104*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1105*0b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
1106*0b57cec5SDimitry Andric    {
1107*0b57cec5SDimitry Andric        return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
1108*0b57cec5SDimitry Andric            _VSTD::forward_as_tuple(__k),
1109*0b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
1110*0b57cec5SDimitry Andric    }
1111*0b57cec5SDimitry Andric
1112*0b57cec5SDimitry Andric    template <class... _Args>
1113*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1114*0b57cec5SDimitry Andric        pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
1115*0b57cec5SDimitry Andric    {
1116*0b57cec5SDimitry Andric        return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
1117*0b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::move(__k)),
1118*0b57cec5SDimitry Andric            _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
1119*0b57cec5SDimitry Andric    }
1120*0b57cec5SDimitry Andric
1121*0b57cec5SDimitry Andric    template <class... _Args>
1122*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1123*0b57cec5SDimitry Andric        iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
1124*0b57cec5SDimitry Andric    {
1125*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1126*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
1127*0b57cec5SDimitry Andric            "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
1128*0b57cec5SDimitry Andric            " referring to this unordered_map");
1129*0b57cec5SDimitry Andric#else
1130*0b57cec5SDimitry Andric        ((void)__h);
1131*0b57cec5SDimitry Andric#endif
1132*0b57cec5SDimitry Andric        return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
1133*0b57cec5SDimitry Andric    }
1134*0b57cec5SDimitry Andric
1135*0b57cec5SDimitry Andric    template <class... _Args>
1136*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1137*0b57cec5SDimitry Andric        iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
1138*0b57cec5SDimitry Andric    {
1139*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1140*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
1141*0b57cec5SDimitry Andric            "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
1142*0b57cec5SDimitry Andric            " referring to this unordered_map");
1143*0b57cec5SDimitry Andric#else
1144*0b57cec5SDimitry Andric        ((void)__h);
1145*0b57cec5SDimitry Andric#endif
1146*0b57cec5SDimitry Andric        return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first;
1147*0b57cec5SDimitry Andric    }
1148*0b57cec5SDimitry Andric
1149*0b57cec5SDimitry Andric    template <class _Vp>
1150*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1151*0b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
1152*0b57cec5SDimitry Andric    {
1153*0b57cec5SDimitry Andric        pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
1154*0b57cec5SDimitry Andric            __k, _VSTD::forward<_Vp>(__v));
1155*0b57cec5SDimitry Andric        if (!__res.second) {
1156*0b57cec5SDimitry Andric            __res.first->second = _VSTD::forward<_Vp>(__v);
1157*0b57cec5SDimitry Andric        }
1158*0b57cec5SDimitry Andric        return __res;
1159*0b57cec5SDimitry Andric    }
1160*0b57cec5SDimitry Andric
1161*0b57cec5SDimitry Andric    template <class _Vp>
1162*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1163*0b57cec5SDimitry Andric        pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
1164*0b57cec5SDimitry Andric    {
1165*0b57cec5SDimitry Andric        pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
1166*0b57cec5SDimitry Andric            _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
1167*0b57cec5SDimitry Andric        if (!__res.second) {
1168*0b57cec5SDimitry Andric            __res.first->second = _VSTD::forward<_Vp>(__v);
1169*0b57cec5SDimitry Andric        }
1170*0b57cec5SDimitry Andric        return __res;
1171*0b57cec5SDimitry Andric    }
1172*0b57cec5SDimitry Andric
1173*0b57cec5SDimitry Andric    template <class _Vp>
1174*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1175*0b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator, const key_type& __k, _Vp&& __v)
1176*0b57cec5SDimitry Andric     {
1177*0b57cec5SDimitry Andric          // FIXME: Add debug mode checking for the iterator input
1178*0b57cec5SDimitry Andric          return insert_or_assign(__k, _VSTD::forward<_Vp>(__v)).first;
1179*0b57cec5SDimitry Andric     }
1180*0b57cec5SDimitry Andric
1181*0b57cec5SDimitry Andric    template <class _Vp>
1182*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1183*0b57cec5SDimitry Andric        iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v)
1184*0b57cec5SDimitry Andric     {
1185*0b57cec5SDimitry Andric        // FIXME: Add debug mode checking for the iterator input
1186*0b57cec5SDimitry Andric        return insert_or_assign(_VSTD::move(__k), _VSTD::forward<_Vp>(__v)).first;
1187*0b57cec5SDimitry Andric     }
1188*0b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 14
1189*0b57cec5SDimitry Andric
1190*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1191*0b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
1192*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1193*0b57cec5SDimitry Andric    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
1194*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1195*0b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
1196*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1197*0b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
1198*0b57cec5SDimitry Andric        {return __table_.erase(__first.__i_, __last.__i_);}
1199*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1200*0b57cec5SDimitry Andric        void clear() _NOEXCEPT {__table_.clear();}
1201*0b57cec5SDimitry Andric
1202*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
1203*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1204*0b57cec5SDimitry Andric    insert_return_type insert(node_type&& __nh)
1205*0b57cec5SDimitry Andric    {
1206*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1207*0b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_map::insert()");
1208*0b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<
1209*0b57cec5SDimitry Andric            node_type, insert_return_type>(_VSTD::move(__nh));
1210*0b57cec5SDimitry Andric    }
1211*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1212*0b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
1213*0b57cec5SDimitry Andric    {
1214*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1215*0b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_map::insert()");
1216*0b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<node_type>(
1217*0b57cec5SDimitry Andric            __hint.__i_, _VSTD::move(__nh));
1218*0b57cec5SDimitry Andric    }
1219*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1220*0b57cec5SDimitry Andric    node_type extract(key_type const& __key)
1221*0b57cec5SDimitry Andric    {
1222*0b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
1223*0b57cec5SDimitry Andric    }
1224*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1225*0b57cec5SDimitry Andric    node_type extract(const_iterator __it)
1226*0b57cec5SDimitry Andric    {
1227*0b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(
1228*0b57cec5SDimitry Andric            __it.__i_);
1229*0b57cec5SDimitry Andric    }
1230*0b57cec5SDimitry Andric
1231*0b57cec5SDimitry Andric    template <class _H2, class _P2>
1232*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1233*0b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
1234*0b57cec5SDimitry Andric    {
1235*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1236*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
1237*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
1238*0b57cec5SDimitry Andric    }
1239*0b57cec5SDimitry Andric    template <class _H2, class _P2>
1240*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1241*0b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
1242*0b57cec5SDimitry Andric    {
1243*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1244*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
1245*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
1246*0b57cec5SDimitry Andric    }
1247*0b57cec5SDimitry Andric    template <class _H2, class _P2>
1248*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1249*0b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
1250*0b57cec5SDimitry Andric    {
1251*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1252*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
1253*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
1254*0b57cec5SDimitry Andric    }
1255*0b57cec5SDimitry Andric    template <class _H2, class _P2>
1256*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1257*0b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
1258*0b57cec5SDimitry Andric    {
1259*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1260*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
1261*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_unique(__source.__table_);
1262*0b57cec5SDimitry Andric    }
1263*0b57cec5SDimitry Andric#endif
1264*0b57cec5SDimitry Andric
1265*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1266*0b57cec5SDimitry Andric    void swap(unordered_map& __u)
1267*0b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
1268*0b57cec5SDimitry Andric        { __table_.swap(__u.__table_);}
1269*0b57cec5SDimitry Andric
1270*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1271*0b57cec5SDimitry Andric    hasher hash_function() const
1272*0b57cec5SDimitry Andric        {return __table_.hash_function().hash_function();}
1273*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1274*0b57cec5SDimitry Andric    key_equal key_eq() const
1275*0b57cec5SDimitry Andric        {return __table_.key_eq().key_eq();}
1276*0b57cec5SDimitry Andric
1277*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1278*0b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
1279*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1280*0b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1281*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1282*0b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
1283*0b57cec5SDimitry Andric    #if _LIBCPP_STD_VER > 17
1284*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1285*0b57cec5SDimitry Andric        bool contains(const key_type& __k) const {return find(__k) != end();}
1286*0b57cec5SDimitry Andric    #endif // _LIBCPP_STD_VER > 17
1287*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1288*0b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
1289*0b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
1290*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1291*0b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
1292*0b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
1293*0b57cec5SDimitry Andric
1294*0b57cec5SDimitry Andric    mapped_type& operator[](const key_type& __k);
1295*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1296*0b57cec5SDimitry Andric    mapped_type& operator[](key_type&& __k);
1297*0b57cec5SDimitry Andric#endif
1298*0b57cec5SDimitry Andric
1299*0b57cec5SDimitry Andric    mapped_type&       at(const key_type& __k);
1300*0b57cec5SDimitry Andric    const mapped_type& at(const key_type& __k) const;
1301*0b57cec5SDimitry Andric
1302*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1303*0b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
1304*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1305*0b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
1306*0b57cec5SDimitry Andric
1307*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1308*0b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const
1309*0b57cec5SDimitry Andric        {return __table_.bucket_size(__n);}
1310*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1311*0b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
1312*0b57cec5SDimitry Andric
1313*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1314*0b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
1315*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1316*0b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
1317*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1318*0b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
1319*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1320*0b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
1321*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1322*0b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
1323*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1324*0b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
1325*0b57cec5SDimitry Andric
1326*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1327*0b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
1328*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1329*0b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
1330*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1331*0b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
1332*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1333*0b57cec5SDimitry Andric    void rehash(size_type __n) {__table_.rehash(__n);}
1334*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1335*0b57cec5SDimitry Andric    void reserve(size_type __n) {__table_.reserve(__n);}
1336*0b57cec5SDimitry Andric
1337*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1338*0b57cec5SDimitry Andric
1339*0b57cec5SDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
1340*0b57cec5SDimitry Andric        {return __table_.__dereferenceable(&__i->__i_);}
1341*0b57cec5SDimitry Andric    bool __decrementable(const const_iterator* __i) const
1342*0b57cec5SDimitry Andric        {return __table_.__decrementable(&__i->__i_);}
1343*0b57cec5SDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1344*0b57cec5SDimitry Andric        {return __table_.__addable(&__i->__i_, __n);}
1345*0b57cec5SDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1346*0b57cec5SDimitry Andric        {return __table_.__addable(&__i->__i_, __n);}
1347*0b57cec5SDimitry Andric
1348*0b57cec5SDimitry Andric#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1349*0b57cec5SDimitry Andric
1350*0b57cec5SDimitry Andricprivate:
1351*0b57cec5SDimitry Andric
1352*0b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG
1353*0b57cec5SDimitry Andric    __node_holder __construct_node_with_key(const key_type& __k);
1354*0b57cec5SDimitry Andric#endif
1355*0b57cec5SDimitry Andric};
1356*0b57cec5SDimitry Andric
1357*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1358*0b57cec5SDimitry Andrictemplate<class _InputIterator,
1359*0b57cec5SDimitry Andric         class _Hash = hash<__iter_key_type<_InputIterator>>,
1360*0b57cec5SDimitry Andric         class _Pred = equal_to<__iter_key_type<_InputIterator>>,
1361*0b57cec5SDimitry Andric         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
1362*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
1363*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
1364*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
1365*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1366*0b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
1367*0b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1368*0b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
1369*0b57cec5SDimitry Andric
1370*0b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>,
1371*0b57cec5SDimitry Andric         class _Pred = equal_to<remove_const_t<_Key>>,
1372*0b57cec5SDimitry Andric         class _Allocator = allocator<pair<const _Key, _Tp>>,
1373*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
1374*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
1375*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
1376*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1377*0b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0,
1378*0b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1379*0b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
1380*0b57cec5SDimitry Andric
1381*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
1382*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1383*0b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
1384*0b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
1385*0b57cec5SDimitry Andric                   hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
1386*0b57cec5SDimitry Andric
1387*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
1388*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1389*0b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, _Allocator)
1390*0b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
1391*0b57cec5SDimitry Andric                   hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
1392*0b57cec5SDimitry Andric
1393*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
1394*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
1395*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
1396*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1397*0b57cec5SDimitry Andricunordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1398*0b57cec5SDimitry Andric  -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
1399*0b57cec5SDimitry Andric                   _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
1400*0b57cec5SDimitry Andric
1401*0b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
1402*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1403*0b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
1404*0b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp,
1405*0b57cec5SDimitry Andric                   hash<remove_const_t<_Key>>,
1406*0b57cec5SDimitry Andric                   equal_to<remove_const_t<_Key>>, _Allocator>;
1407*0b57cec5SDimitry Andric
1408*0b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
1409*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1410*0b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator)
1411*0b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp,
1412*0b57cec5SDimitry Andric                   hash<remove_const_t<_Key>>,
1413*0b57cec5SDimitry Andric                   equal_to<remove_const_t<_Key>>, _Allocator>;
1414*0b57cec5SDimitry Andric
1415*0b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash, class _Allocator,
1416*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
1417*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
1418*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1419*0b57cec5SDimitry Andricunordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1420*0b57cec5SDimitry Andric  -> unordered_map<remove_const_t<_Key>, _Tp, _Hash,
1421*0b57cec5SDimitry Andric                   equal_to<remove_const_t<_Key>>, _Allocator>;
1422*0b57cec5SDimitry Andric#endif
1423*0b57cec5SDimitry Andric
1424*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1425*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1426*0b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql)
1427*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
1428*0b57cec5SDimitry Andric{
1429*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1430*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1431*0b57cec5SDimitry Andric#endif
1432*0b57cec5SDimitry Andric    __table_.rehash(__n);
1433*0b57cec5SDimitry Andric}
1434*0b57cec5SDimitry Andric
1435*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1436*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1437*0b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql,
1438*0b57cec5SDimitry Andric        const allocator_type& __a)
1439*0b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
1440*0b57cec5SDimitry Andric{
1441*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1442*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1443*0b57cec5SDimitry Andric#endif
1444*0b57cec5SDimitry Andric    __table_.rehash(__n);
1445*0b57cec5SDimitry Andric}
1446*0b57cec5SDimitry Andric
1447*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1448*0b57cec5SDimitry Andricinline
1449*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1450*0b57cec5SDimitry Andric        const allocator_type& __a)
1451*0b57cec5SDimitry Andric    : __table_(typename __table::allocator_type(__a))
1452*0b57cec5SDimitry Andric{
1453*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1454*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1455*0b57cec5SDimitry Andric#endif
1456*0b57cec5SDimitry Andric}
1457*0b57cec5SDimitry Andric
1458*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1459*0b57cec5SDimitry Andrictemplate <class _InputIterator>
1460*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1461*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
1462*0b57cec5SDimitry Andric{
1463*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1464*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1465*0b57cec5SDimitry Andric#endif
1466*0b57cec5SDimitry Andric    insert(__first, __last);
1467*0b57cec5SDimitry Andric}
1468*0b57cec5SDimitry Andric
1469*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1470*0b57cec5SDimitry Andrictemplate <class _InputIterator>
1471*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1472*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
1473*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
1474*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
1475*0b57cec5SDimitry Andric{
1476*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1477*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1478*0b57cec5SDimitry Andric#endif
1479*0b57cec5SDimitry Andric    __table_.rehash(__n);
1480*0b57cec5SDimitry Andric    insert(__first, __last);
1481*0b57cec5SDimitry Andric}
1482*0b57cec5SDimitry Andric
1483*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1484*0b57cec5SDimitry Andrictemplate <class _InputIterator>
1485*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1486*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
1487*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1488*0b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
1489*0b57cec5SDimitry Andric{
1490*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1491*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1492*0b57cec5SDimitry Andric#endif
1493*0b57cec5SDimitry Andric    __table_.rehash(__n);
1494*0b57cec5SDimitry Andric    insert(__first, __last);
1495*0b57cec5SDimitry Andric}
1496*0b57cec5SDimitry Andric
1497*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1498*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1499*0b57cec5SDimitry Andric        const unordered_map& __u)
1500*0b57cec5SDimitry Andric    : __table_(__u.__table_)
1501*0b57cec5SDimitry Andric{
1502*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1503*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1504*0b57cec5SDimitry Andric#endif
1505*0b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
1506*0b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
1507*0b57cec5SDimitry Andric}
1508*0b57cec5SDimitry Andric
1509*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1510*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1511*0b57cec5SDimitry Andric        const unordered_map& __u, const allocator_type& __a)
1512*0b57cec5SDimitry Andric    : __table_(__u.__table_, typename __table::allocator_type(__a))
1513*0b57cec5SDimitry Andric{
1514*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1515*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1516*0b57cec5SDimitry Andric#endif
1517*0b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
1518*0b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
1519*0b57cec5SDimitry Andric}
1520*0b57cec5SDimitry Andric
1521*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1522*0b57cec5SDimitry Andric
1523*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1524*0b57cec5SDimitry Andricinline
1525*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1526*0b57cec5SDimitry Andric        unordered_map&& __u)
1527*0b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1528*0b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
1529*0b57cec5SDimitry Andric{
1530*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1531*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1532*0b57cec5SDimitry Andric    __get_db()->swap(this, &__u);
1533*0b57cec5SDimitry Andric#endif
1534*0b57cec5SDimitry Andric}
1535*0b57cec5SDimitry Andric
1536*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1537*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1538*0b57cec5SDimitry Andric        unordered_map&& __u, const allocator_type& __a)
1539*0b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
1540*0b57cec5SDimitry Andric{
1541*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1542*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1543*0b57cec5SDimitry Andric#endif
1544*0b57cec5SDimitry Andric    if (__a != __u.get_allocator())
1545*0b57cec5SDimitry Andric    {
1546*0b57cec5SDimitry Andric        iterator __i = __u.begin();
1547*0b57cec5SDimitry Andric        while (__u.size() != 0) {
1548*0b57cec5SDimitry Andric            __table_.__emplace_unique(
1549*0b57cec5SDimitry Andric                __u.__table_.remove((__i++).__i_)->__value_.__move());
1550*0b57cec5SDimitry Andric        }
1551*0b57cec5SDimitry Andric    }
1552*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1553*0b57cec5SDimitry Andric    else
1554*0b57cec5SDimitry Andric        __get_db()->swap(this, &__u);
1555*0b57cec5SDimitry Andric#endif
1556*0b57cec5SDimitry Andric}
1557*0b57cec5SDimitry Andric
1558*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1559*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1560*0b57cec5SDimitry Andric        initializer_list<value_type> __il)
1561*0b57cec5SDimitry Andric{
1562*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1563*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1564*0b57cec5SDimitry Andric#endif
1565*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
1566*0b57cec5SDimitry Andric}
1567*0b57cec5SDimitry Andric
1568*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1569*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1570*0b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1571*0b57cec5SDimitry Andric        const key_equal& __eql)
1572*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
1573*0b57cec5SDimitry Andric{
1574*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1575*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1576*0b57cec5SDimitry Andric#endif
1577*0b57cec5SDimitry Andric    __table_.rehash(__n);
1578*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
1579*0b57cec5SDimitry Andric}
1580*0b57cec5SDimitry Andric
1581*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1582*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1583*0b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1584*0b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
1585*0b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
1586*0b57cec5SDimitry Andric{
1587*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1588*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1589*0b57cec5SDimitry Andric#endif
1590*0b57cec5SDimitry Andric    __table_.rehash(__n);
1591*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
1592*0b57cec5SDimitry Andric}
1593*0b57cec5SDimitry Andric
1594*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1595*0b57cec5SDimitry Andricinline
1596*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
1597*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
1598*0b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
1599*0b57cec5SDimitry Andric{
1600*0b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
1601*0b57cec5SDimitry Andric    return *this;
1602*0b57cec5SDimitry Andric}
1603*0b57cec5SDimitry Andric
1604*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1605*0b57cec5SDimitry Andricinline
1606*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
1607*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
1608*0b57cec5SDimitry Andric        initializer_list<value_type> __il)
1609*0b57cec5SDimitry Andric{
1610*0b57cec5SDimitry Andric    __table_.__assign_unique(__il.begin(), __il.end());
1611*0b57cec5SDimitry Andric    return *this;
1612*0b57cec5SDimitry Andric}
1613*0b57cec5SDimitry Andric
1614*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1615*0b57cec5SDimitry Andric
1616*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1617*0b57cec5SDimitry Andrictemplate <class _InputIterator>
1618*0b57cec5SDimitry Andricinline
1619*0b57cec5SDimitry Andricvoid
1620*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
1621*0b57cec5SDimitry Andric                                                       _InputIterator __last)
1622*0b57cec5SDimitry Andric{
1623*0b57cec5SDimitry Andric    for (; __first != __last; ++__first)
1624*0b57cec5SDimitry Andric        __table_.__insert_unique(*__first);
1625*0b57cec5SDimitry Andric}
1626*0b57cec5SDimitry Andric
1627*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1628*0b57cec5SDimitry Andric
1629*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1630*0b57cec5SDimitry Andric_Tp&
1631*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
1632*0b57cec5SDimitry Andric{
1633*0b57cec5SDimitry Andric    return __table_.__emplace_unique_key_args(__k,
1634*0b57cec5SDimitry Andric        std::piecewise_construct, std::forward_as_tuple(__k),
1635*0b57cec5SDimitry Andric                                  std::forward_as_tuple()).first->__get_value().second;
1636*0b57cec5SDimitry Andric}
1637*0b57cec5SDimitry Andric
1638*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1639*0b57cec5SDimitry Andric_Tp&
1640*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
1641*0b57cec5SDimitry Andric{
1642*0b57cec5SDimitry Andric    return __table_.__emplace_unique_key_args(__k,
1643*0b57cec5SDimitry Andric        std::piecewise_construct, std::forward_as_tuple(std::move(__k)),
1644*0b57cec5SDimitry Andric                                  std::forward_as_tuple()).first->__get_value().second;
1645*0b57cec5SDimitry Andric}
1646*0b57cec5SDimitry Andric#else // _LIBCPP_CXX03_LANG
1647*0b57cec5SDimitry Andric
1648*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1649*0b57cec5SDimitry Andrictypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1650*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
1651*0b57cec5SDimitry Andric{
1652*0b57cec5SDimitry Andric    __node_allocator& __na = __table_.__node_alloc();
1653*0b57cec5SDimitry Andric    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1654*0b57cec5SDimitry Andric    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k);
1655*0b57cec5SDimitry Andric    __h.get_deleter().__first_constructed = true;
1656*0b57cec5SDimitry Andric    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second));
1657*0b57cec5SDimitry Andric    __h.get_deleter().__second_constructed = true;
1658*0b57cec5SDimitry Andric    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
1659*0b57cec5SDimitry Andric}
1660*0b57cec5SDimitry Andric
1661*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1662*0b57cec5SDimitry Andric_Tp&
1663*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
1664*0b57cec5SDimitry Andric{
1665*0b57cec5SDimitry Andric    iterator __i = find(__k);
1666*0b57cec5SDimitry Andric    if (__i != end())
1667*0b57cec5SDimitry Andric        return __i->second;
1668*0b57cec5SDimitry Andric    __node_holder __h = __construct_node_with_key(__k);
1669*0b57cec5SDimitry Andric    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
1670*0b57cec5SDimitry Andric    __h.release();
1671*0b57cec5SDimitry Andric    return __r.first->second;
1672*0b57cec5SDimitry Andric}
1673*0b57cec5SDimitry Andric
1674*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_MODE
1675*0b57cec5SDimitry Andric
1676*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1677*0b57cec5SDimitry Andric_Tp&
1678*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k)
1679*0b57cec5SDimitry Andric{
1680*0b57cec5SDimitry Andric    iterator __i = find(__k);
1681*0b57cec5SDimitry Andric    if (__i == end())
1682*0b57cec5SDimitry Andric        __throw_out_of_range("unordered_map::at: key not found");
1683*0b57cec5SDimitry Andric    return __i->second;
1684*0b57cec5SDimitry Andric}
1685*0b57cec5SDimitry Andric
1686*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1687*0b57cec5SDimitry Andricconst _Tp&
1688*0b57cec5SDimitry Andricunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const
1689*0b57cec5SDimitry Andric{
1690*0b57cec5SDimitry Andric    const_iterator __i = find(__k);
1691*0b57cec5SDimitry Andric    if (__i == end())
1692*0b57cec5SDimitry Andric        __throw_out_of_range("unordered_map::at: key not found");
1693*0b57cec5SDimitry Andric    return __i->second;
1694*0b57cec5SDimitry Andric}
1695*0b57cec5SDimitry Andric
1696*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1697*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1698*0b57cec5SDimitry Andricvoid
1699*0b57cec5SDimitry Andricswap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1700*0b57cec5SDimitry Andric     unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1701*0b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
1702*0b57cec5SDimitry Andric{
1703*0b57cec5SDimitry Andric    __x.swap(__y);
1704*0b57cec5SDimitry Andric}
1705*0b57cec5SDimitry Andric
1706*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
1707*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>
1708*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1709*0b57cec5SDimitry Andricvoid erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
1710*0b57cec5SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); }
1711*0b57cec5SDimitry Andric#endif
1712*0b57cec5SDimitry Andric
1713*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1714*0b57cec5SDimitry Andricbool
1715*0b57cec5SDimitry Andricoperator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1716*0b57cec5SDimitry Andric           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1717*0b57cec5SDimitry Andric{
1718*0b57cec5SDimitry Andric    if (__x.size() != __y.size())
1719*0b57cec5SDimitry Andric        return false;
1720*0b57cec5SDimitry Andric    typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
1721*0b57cec5SDimitry Andric                                                                 const_iterator;
1722*0b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
1723*0b57cec5SDimitry Andric            __i != __ex; ++__i)
1724*0b57cec5SDimitry Andric    {
1725*0b57cec5SDimitry Andric        const_iterator __j = __y.find(__i->first);
1726*0b57cec5SDimitry Andric        if (__j == __ey || !(*__i == *__j))
1727*0b57cec5SDimitry Andric            return false;
1728*0b57cec5SDimitry Andric    }
1729*0b57cec5SDimitry Andric    return true;
1730*0b57cec5SDimitry Andric}
1731*0b57cec5SDimitry Andric
1732*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1733*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1734*0b57cec5SDimitry Andricbool
1735*0b57cec5SDimitry Andricoperator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1736*0b57cec5SDimitry Andric           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1737*0b57cec5SDimitry Andric{
1738*0b57cec5SDimitry Andric    return !(__x == __y);
1739*0b57cec5SDimitry Andric}
1740*0b57cec5SDimitry Andric
1741*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
1742*0b57cec5SDimitry Andric          class _Alloc = allocator<pair<const _Key, _Tp> > >
1743*0b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multimap
1744*0b57cec5SDimitry Andric{
1745*0b57cec5SDimitry Andricpublic:
1746*0b57cec5SDimitry Andric    // types
1747*0b57cec5SDimitry Andric    typedef _Key                                           key_type;
1748*0b57cec5SDimitry Andric    typedef _Tp                                            mapped_type;
1749*0b57cec5SDimitry Andric    typedef typename __identity<_Hash>::type               hasher;
1750*0b57cec5SDimitry Andric    typedef typename __identity<_Pred>::type               key_equal;
1751*0b57cec5SDimitry Andric    typedef typename __identity<_Alloc>::type              allocator_type;
1752*0b57cec5SDimitry Andric    typedef pair<const key_type, mapped_type>              value_type;
1753*0b57cec5SDimitry Andric    typedef value_type&                                    reference;
1754*0b57cec5SDimitry Andric    typedef const value_type&                              const_reference;
1755*0b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1756*0b57cec5SDimitry Andric                  "Invalid allocator::value_type");
1757*0b57cec5SDimitry Andric
1758*0b57cec5SDimitry Andricprivate:
1759*0b57cec5SDimitry Andric    typedef __hash_value_type<key_type, mapped_type>                 __value_type;
1760*0b57cec5SDimitry Andric    typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
1761*0b57cec5SDimitry Andric    typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
1762*0b57cec5SDimitry Andric    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
1763*0b57cec5SDimitry Andric                                                 __value_type>::type __allocator_type;
1764*0b57cec5SDimitry Andric
1765*0b57cec5SDimitry Andric    typedef __hash_table<__value_type, __hasher,
1766*0b57cec5SDimitry Andric                         __key_equal,  __allocator_type>   __table;
1767*0b57cec5SDimitry Andric
1768*0b57cec5SDimitry Andric    __table __table_;
1769*0b57cec5SDimitry Andric
1770*0b57cec5SDimitry Andric    typedef typename __table::_NodeTypes                   _NodeTypes;
1771*0b57cec5SDimitry Andric    typedef typename __table::__node_traits                __node_traits;
1772*0b57cec5SDimitry Andric    typedef typename __table::__node_allocator             __node_allocator;
1773*0b57cec5SDimitry Andric    typedef typename __table::__node                       __node;
1774*0b57cec5SDimitry Andric    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
1775*0b57cec5SDimitry Andric    typedef unique_ptr<__node, _Dp>                         __node_holder;
1776*0b57cec5SDimitry Andric    typedef allocator_traits<allocator_type>               __alloc_traits;
1777*0b57cec5SDimitry Andric    static_assert((is_same<typename __node_traits::size_type,
1778*0b57cec5SDimitry Andric                          typename __alloc_traits::size_type>::value),
1779*0b57cec5SDimitry Andric                 "Allocator uses different size_type for different types");
1780*0b57cec5SDimitry Andricpublic:
1781*0b57cec5SDimitry Andric    typedef typename __alloc_traits::pointer         pointer;
1782*0b57cec5SDimitry Andric    typedef typename __alloc_traits::const_pointer   const_pointer;
1783*0b57cec5SDimitry Andric    typedef typename __table::size_type              size_type;
1784*0b57cec5SDimitry Andric    typedef typename __table::difference_type        difference_type;
1785*0b57cec5SDimitry Andric
1786*0b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::iterator>       iterator;
1787*0b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
1788*0b57cec5SDimitry Andric    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
1789*0b57cec5SDimitry Andric    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
1790*0b57cec5SDimitry Andric
1791*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
1792*0b57cec5SDimitry Andric    typedef __map_node_handle<__node, allocator_type> node_type;
1793*0b57cec5SDimitry Andric#endif
1794*0b57cec5SDimitry Andric
1795*0b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
1796*0b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_map;
1797*0b57cec5SDimitry Andric    template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
1798*0b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
1799*0b57cec5SDimitry Andric
1800*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1801*0b57cec5SDimitry Andric    unordered_multimap()
1802*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
1803*0b57cec5SDimitry Andric        {
1804*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1805*0b57cec5SDimitry Andric            __get_db()->__insert_c(this);
1806*0b57cec5SDimitry Andric#endif
1807*0b57cec5SDimitry Andric        }
1808*0b57cec5SDimitry Andric    explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(),
1809*0b57cec5SDimitry Andric                                const key_equal& __eql = key_equal());
1810*0b57cec5SDimitry Andric    unordered_multimap(size_type __n, const hasher& __hf,
1811*0b57cec5SDimitry Andric                                const key_equal& __eql,
1812*0b57cec5SDimitry Andric                                const allocator_type& __a);
1813*0b57cec5SDimitry Andric    template <class _InputIterator>
1814*0b57cec5SDimitry Andric        unordered_multimap(_InputIterator __first, _InputIterator __last);
1815*0b57cec5SDimitry Andric    template <class _InputIterator>
1816*0b57cec5SDimitry Andric        unordered_multimap(_InputIterator __first, _InputIterator __last,
1817*0b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
1818*0b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
1819*0b57cec5SDimitry Andric    template <class _InputIterator>
1820*0b57cec5SDimitry Andric        unordered_multimap(_InputIterator __first, _InputIterator __last,
1821*0b57cec5SDimitry Andric                      size_type __n, const hasher& __hf,
1822*0b57cec5SDimitry Andric                      const key_equal& __eql,
1823*0b57cec5SDimitry Andric                      const allocator_type& __a);
1824*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1825*0b57cec5SDimitry Andric    explicit unordered_multimap(const allocator_type& __a);
1826*0b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap& __u);
1827*0b57cec5SDimitry Andric    unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
1828*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1829*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1830*0b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&& __u)
1831*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
1832*0b57cec5SDimitry Andric    unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
1833*0b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il);
1834*0b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n,
1835*0b57cec5SDimitry Andric                       const hasher& __hf = hasher(),
1836*0b57cec5SDimitry Andric                       const key_equal& __eql = key_equal());
1837*0b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n,
1838*0b57cec5SDimitry Andric                       const hasher& __hf, const key_equal& __eql,
1839*0b57cec5SDimitry Andric                       const allocator_type& __a);
1840*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1841*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
1842*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1843*0b57cec5SDimitry Andric    unordered_multimap(size_type __n, const allocator_type& __a)
1844*0b57cec5SDimitry Andric      : unordered_multimap(__n, hasher(), key_equal(), __a) {}
1845*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1846*0b57cec5SDimitry Andric    unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
1847*0b57cec5SDimitry Andric      : unordered_multimap(__n, __hf, key_equal(), __a) {}
1848*0b57cec5SDimitry Andric    template <class _InputIterator>
1849*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1850*0b57cec5SDimitry Andric      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
1851*0b57cec5SDimitry Andric      : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
1852*0b57cec5SDimitry Andric    template <class _InputIterator>
1853*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1854*0b57cec5SDimitry Andric      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf,
1855*0b57cec5SDimitry Andric        const allocator_type& __a)
1856*0b57cec5SDimitry Andric      : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
1857*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1858*0b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1859*0b57cec5SDimitry Andric      : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
1860*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1861*0b57cec5SDimitry Andric    unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1862*0b57cec5SDimitry Andric      const allocator_type& __a)
1863*0b57cec5SDimitry Andric      : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
1864*0b57cec5SDimitry Andric#endif
1865*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1866*0b57cec5SDimitry Andric    ~unordered_multimap() {
1867*0b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
1868*0b57cec5SDimitry Andric    }
1869*0b57cec5SDimitry Andric
1870*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1871*0b57cec5SDimitry Andric    unordered_multimap& operator=(const unordered_multimap& __u)
1872*0b57cec5SDimitry Andric    {
1873*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1874*0b57cec5SDimitry Andric        __table_ = __u.__table_;
1875*0b57cec5SDimitry Andric#else
1876*0b57cec5SDimitry Andric        if (this != &__u) {
1877*0b57cec5SDimitry Andric            __table_.clear();
1878*0b57cec5SDimitry Andric            __table_.hash_function() = __u.__table_.hash_function();
1879*0b57cec5SDimitry Andric            __table_.key_eq() = __u.__table_.key_eq();
1880*0b57cec5SDimitry Andric            __table_.max_load_factor() = __u.__table_.max_load_factor();
1881*0b57cec5SDimitry Andric            __table_.__copy_assign_alloc(__u.__table_);
1882*0b57cec5SDimitry Andric            insert(__u.begin(), __u.end());
1883*0b57cec5SDimitry Andric        }
1884*0b57cec5SDimitry Andric#endif
1885*0b57cec5SDimitry Andric        return *this;
1886*0b57cec5SDimitry Andric    }
1887*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1888*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1889*0b57cec5SDimitry Andric    unordered_multimap& operator=(unordered_multimap&& __u)
1890*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
1891*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1892*0b57cec5SDimitry Andric    unordered_multimap& operator=(initializer_list<value_type> __il);
1893*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1894*0b57cec5SDimitry Andric
1895*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1896*0b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
1897*0b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
1898*0b57cec5SDimitry Andric
1899*0b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
1900*0b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
1901*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1902*0b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
1903*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1904*0b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
1905*0b57cec5SDimitry Andric
1906*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1907*0b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
1908*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1909*0b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
1910*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1911*0b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
1912*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1913*0b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
1914*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1915*0b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
1916*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1917*0b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
1918*0b57cec5SDimitry Andric
1919*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1920*0b57cec5SDimitry Andric    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
1921*0b57cec5SDimitry Andric
1922*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1923*0b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __x)
1924*0b57cec5SDimitry Andric        {return __table_.__insert_multi(__p.__i_, __x);}
1925*0b57cec5SDimitry Andric
1926*0b57cec5SDimitry Andric    template <class _InputIterator>
1927*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1928*0b57cec5SDimitry Andric    void insert(_InputIterator __first, _InputIterator __last);
1929*0b57cec5SDimitry Andric
1930*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1931*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1932*0b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
1933*0b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
1934*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1935*0b57cec5SDimitry Andric    iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
1936*0b57cec5SDimitry Andric
1937*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1938*0b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __x)
1939*0b57cec5SDimitry Andric        {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));}
1940*0b57cec5SDimitry Andric
1941*0b57cec5SDimitry Andric    template <class _Pp,
1942*0b57cec5SDimitry Andric              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1943*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1944*0b57cec5SDimitry Andric    iterator insert(_Pp&& __x)
1945*0b57cec5SDimitry Andric        {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
1946*0b57cec5SDimitry Andric
1947*0b57cec5SDimitry Andric    template <class _Pp,
1948*0b57cec5SDimitry Andric              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1949*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1950*0b57cec5SDimitry Andric    iterator insert(const_iterator __p, _Pp&& __x)
1951*0b57cec5SDimitry Andric        {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
1952*0b57cec5SDimitry Andric
1953*0b57cec5SDimitry Andric    template <class... _Args>
1954*0b57cec5SDimitry Andric    iterator emplace(_Args&&... __args) {
1955*0b57cec5SDimitry Andric        return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);
1956*0b57cec5SDimitry Andric    }
1957*0b57cec5SDimitry Andric
1958*0b57cec5SDimitry Andric    template <class... _Args>
1959*0b57cec5SDimitry Andric    iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1960*0b57cec5SDimitry Andric        return __table_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
1961*0b57cec5SDimitry Andric    }
1962*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1963*0b57cec5SDimitry Andric
1964*0b57cec5SDimitry Andric
1965*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1966*0b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
1967*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1968*0b57cec5SDimitry Andric    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
1969*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1970*0b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
1971*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1972*0b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
1973*0b57cec5SDimitry Andric        {return __table_.erase(__first.__i_, __last.__i_);}
1974*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1975*0b57cec5SDimitry Andric    void clear() _NOEXCEPT {__table_.clear();}
1976*0b57cec5SDimitry Andric
1977*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
1978*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1979*0b57cec5SDimitry Andric    iterator insert(node_type&& __nh)
1980*0b57cec5SDimitry Andric    {
1981*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1982*0b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multimap::insert()");
1983*0b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
1984*0b57cec5SDimitry Andric            _VSTD::move(__nh));
1985*0b57cec5SDimitry Andric    }
1986*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1987*0b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
1988*0b57cec5SDimitry Andric    {
1989*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1990*0b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multimap::insert()");
1991*0b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
1992*0b57cec5SDimitry Andric            __hint.__i_, _VSTD::move(__nh));
1993*0b57cec5SDimitry Andric    }
1994*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1995*0b57cec5SDimitry Andric    node_type extract(key_type const& __key)
1996*0b57cec5SDimitry Andric    {
1997*0b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
1998*0b57cec5SDimitry Andric    }
1999*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2000*0b57cec5SDimitry Andric    node_type extract(const_iterator __it)
2001*0b57cec5SDimitry Andric    {
2002*0b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(
2003*0b57cec5SDimitry Andric            __it.__i_);
2004*0b57cec5SDimitry Andric    }
2005*0b57cec5SDimitry Andric
2006*0b57cec5SDimitry Andric    template <class _H2, class _P2>
2007*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2008*0b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
2009*0b57cec5SDimitry Andric    {
2010*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
2011*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
2012*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
2013*0b57cec5SDimitry Andric    }
2014*0b57cec5SDimitry Andric    template <class _H2, class _P2>
2015*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2016*0b57cec5SDimitry Andric    void merge(unordered_multimap<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
2017*0b57cec5SDimitry Andric    {
2018*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
2019*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
2020*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
2021*0b57cec5SDimitry Andric    }
2022*0b57cec5SDimitry Andric    template <class _H2, class _P2>
2023*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2024*0b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>& __source)
2025*0b57cec5SDimitry Andric    {
2026*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
2027*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
2028*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
2029*0b57cec5SDimitry Andric    }
2030*0b57cec5SDimitry Andric    template <class _H2, class _P2>
2031*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2032*0b57cec5SDimitry Andric    void merge(unordered_map<key_type, mapped_type, _H2, _P2, allocator_type>&& __source)
2033*0b57cec5SDimitry Andric    {
2034*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
2035*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
2036*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
2037*0b57cec5SDimitry Andric    }
2038*0b57cec5SDimitry Andric#endif
2039*0b57cec5SDimitry Andric
2040*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2041*0b57cec5SDimitry Andric    void swap(unordered_multimap& __u)
2042*0b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
2043*0b57cec5SDimitry Andric        {__table_.swap(__u.__table_);}
2044*0b57cec5SDimitry Andric
2045*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2046*0b57cec5SDimitry Andric    hasher hash_function() const
2047*0b57cec5SDimitry Andric        {return __table_.hash_function().hash_function();}
2048*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2049*0b57cec5SDimitry Andric    key_equal key_eq() const
2050*0b57cec5SDimitry Andric        {return __table_.key_eq().key_eq();}
2051*0b57cec5SDimitry Andric
2052*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2053*0b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
2054*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2055*0b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
2056*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2057*0b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
2058*0b57cec5SDimitry Andric    #if _LIBCPP_STD_VER > 17
2059*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2060*0b57cec5SDimitry Andric        bool contains(const key_type& __k) const {return find(__k) != end();}
2061*0b57cec5SDimitry Andric    #endif // _LIBCPP_STD_VER > 17
2062*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2063*0b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
2064*0b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
2065*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2066*0b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
2067*0b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
2068*0b57cec5SDimitry Andric
2069*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2070*0b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
2071*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2072*0b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT
2073*0b57cec5SDimitry Andric        {return __table_.max_bucket_count();}
2074*0b57cec5SDimitry Andric
2075*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2076*0b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const
2077*0b57cec5SDimitry Andric        {return __table_.bucket_size(__n);}
2078*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2079*0b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
2080*0b57cec5SDimitry Andric
2081*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2082*0b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
2083*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2084*0b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
2085*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2086*0b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
2087*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2088*0b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
2089*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2090*0b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
2091*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2092*0b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
2093*0b57cec5SDimitry Andric
2094*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2095*0b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
2096*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2097*0b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
2098*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2099*0b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
2100*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2101*0b57cec5SDimitry Andric    void rehash(size_type __n) {__table_.rehash(__n);}
2102*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2103*0b57cec5SDimitry Andric    void reserve(size_type __n) {__table_.reserve(__n);}
2104*0b57cec5SDimitry Andric
2105*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2106*0b57cec5SDimitry Andric
2107*0b57cec5SDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
2108*0b57cec5SDimitry Andric        {return __table_.__dereferenceable(&__i->__i_);}
2109*0b57cec5SDimitry Andric    bool __decrementable(const const_iterator* __i) const
2110*0b57cec5SDimitry Andric        {return __table_.__decrementable(&__i->__i_);}
2111*0b57cec5SDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
2112*0b57cec5SDimitry Andric        {return __table_.__addable(&__i->__i_, __n);}
2113*0b57cec5SDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
2114*0b57cec5SDimitry Andric        {return __table_.__addable(&__i->__i_, __n);}
2115*0b57cec5SDimitry Andric
2116*0b57cec5SDimitry Andric#endif  // _LIBCPP_DEBUG_LEVEL >= 2
2117*0b57cec5SDimitry Andric
2118*0b57cec5SDimitry Andric
2119*0b57cec5SDimitry Andric};
2120*0b57cec5SDimitry Andric
2121*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
2122*0b57cec5SDimitry Andrictemplate<class _InputIterator,
2123*0b57cec5SDimitry Andric         class _Hash = hash<__iter_key_type<_InputIterator>>,
2124*0b57cec5SDimitry Andric         class _Pred = equal_to<__iter_key_type<_InputIterator>>,
2125*0b57cec5SDimitry Andric         class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
2126*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
2127*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
2128*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
2129*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
2130*0b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
2131*0b57cec5SDimitry Andric                   _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
2132*0b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
2133*0b57cec5SDimitry Andric
2134*0b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>,
2135*0b57cec5SDimitry Andric         class _Pred = equal_to<remove_const_t<_Key>>,
2136*0b57cec5SDimitry Andric         class _Allocator = allocator<pair<const _Key, _Tp>>,
2137*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
2138*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
2139*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
2140*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
2141*0b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0,
2142*0b57cec5SDimitry Andric                   _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
2143*0b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
2144*0b57cec5SDimitry Andric
2145*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
2146*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
2147*0b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
2148*0b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
2149*0b57cec5SDimitry Andric                        hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
2150*0b57cec5SDimitry Andric
2151*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
2152*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
2153*0b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, _Allocator)
2154*0b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
2155*0b57cec5SDimitry Andric                        hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
2156*0b57cec5SDimitry Andric
2157*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
2158*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
2159*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
2160*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
2161*0b57cec5SDimitry Andricunordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
2162*0b57cec5SDimitry Andric  -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
2163*0b57cec5SDimitry Andric                        _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>;
2164*0b57cec5SDimitry Andric
2165*0b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
2166*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
2167*0b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
2168*0b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp,
2169*0b57cec5SDimitry Andric                        hash<remove_const_t<_Key>>,
2170*0b57cec5SDimitry Andric                        equal_to<remove_const_t<_Key>>, _Allocator>;
2171*0b57cec5SDimitry Andric
2172*0b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Allocator,
2173*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
2174*0b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
2175*0b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp,
2176*0b57cec5SDimitry Andric                        hash<remove_const_t<_Key>>,
2177*0b57cec5SDimitry Andric                        equal_to<remove_const_t<_Key>>, _Allocator>;
2178*0b57cec5SDimitry Andric
2179*0b57cec5SDimitry Andrictemplate<class _Key, class _Tp, class _Hash, class _Allocator,
2180*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
2181*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
2182*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
2183*0b57cec5SDimitry Andricunordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
2184*0b57cec5SDimitry Andric  -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash,
2185*0b57cec5SDimitry Andric                        equal_to<remove_const_t<_Key>>, _Allocator>;
2186*0b57cec5SDimitry Andric#endif
2187*0b57cec5SDimitry Andric
2188*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2189*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2190*0b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql)
2191*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
2192*0b57cec5SDimitry Andric{
2193*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2194*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2195*0b57cec5SDimitry Andric#endif
2196*0b57cec5SDimitry Andric    __table_.rehash(__n);
2197*0b57cec5SDimitry Andric}
2198*0b57cec5SDimitry Andric
2199*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2200*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2201*0b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql,
2202*0b57cec5SDimitry Andric        const allocator_type& __a)
2203*0b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
2204*0b57cec5SDimitry Andric{
2205*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2206*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2207*0b57cec5SDimitry Andric#endif
2208*0b57cec5SDimitry Andric    __table_.rehash(__n);
2209*0b57cec5SDimitry Andric}
2210*0b57cec5SDimitry Andric
2211*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2212*0b57cec5SDimitry Andrictemplate <class _InputIterator>
2213*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2214*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
2215*0b57cec5SDimitry Andric{
2216*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2217*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2218*0b57cec5SDimitry Andric#endif
2219*0b57cec5SDimitry Andric    insert(__first, __last);
2220*0b57cec5SDimitry Andric}
2221*0b57cec5SDimitry Andric
2222*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2223*0b57cec5SDimitry Andrictemplate <class _InputIterator>
2224*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2225*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
2226*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
2227*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
2228*0b57cec5SDimitry Andric{
2229*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2230*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2231*0b57cec5SDimitry Andric#endif
2232*0b57cec5SDimitry Andric    __table_.rehash(__n);
2233*0b57cec5SDimitry Andric    insert(__first, __last);
2234*0b57cec5SDimitry Andric}
2235*0b57cec5SDimitry Andric
2236*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2237*0b57cec5SDimitry Andrictemplate <class _InputIterator>
2238*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2239*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
2240*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
2241*0b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
2242*0b57cec5SDimitry Andric{
2243*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2244*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2245*0b57cec5SDimitry Andric#endif
2246*0b57cec5SDimitry Andric    __table_.rehash(__n);
2247*0b57cec5SDimitry Andric    insert(__first, __last);
2248*0b57cec5SDimitry Andric}
2249*0b57cec5SDimitry Andric
2250*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2251*0b57cec5SDimitry Andricinline
2252*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2253*0b57cec5SDimitry Andric        const allocator_type& __a)
2254*0b57cec5SDimitry Andric    : __table_(typename __table::allocator_type(__a))
2255*0b57cec5SDimitry Andric{
2256*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2257*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2258*0b57cec5SDimitry Andric#endif
2259*0b57cec5SDimitry Andric}
2260*0b57cec5SDimitry Andric
2261*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2262*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2263*0b57cec5SDimitry Andric        const unordered_multimap& __u)
2264*0b57cec5SDimitry Andric    : __table_(__u.__table_)
2265*0b57cec5SDimitry Andric{
2266*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2267*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2268*0b57cec5SDimitry Andric#endif
2269*0b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
2270*0b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
2271*0b57cec5SDimitry Andric}
2272*0b57cec5SDimitry Andric
2273*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2274*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2275*0b57cec5SDimitry Andric        const unordered_multimap& __u, const allocator_type& __a)
2276*0b57cec5SDimitry Andric    : __table_(__u.__table_, typename __table::allocator_type(__a))
2277*0b57cec5SDimitry Andric{
2278*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2279*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2280*0b57cec5SDimitry Andric#endif
2281*0b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
2282*0b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
2283*0b57cec5SDimitry Andric}
2284*0b57cec5SDimitry Andric
2285*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2286*0b57cec5SDimitry Andric
2287*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2288*0b57cec5SDimitry Andricinline
2289*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2290*0b57cec5SDimitry Andric        unordered_multimap&& __u)
2291*0b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
2292*0b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
2293*0b57cec5SDimitry Andric{
2294*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2295*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2296*0b57cec5SDimitry Andric    __get_db()->swap(this, &__u);
2297*0b57cec5SDimitry Andric#endif
2298*0b57cec5SDimitry Andric}
2299*0b57cec5SDimitry Andric
2300*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2301*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2302*0b57cec5SDimitry Andric        unordered_multimap&& __u, const allocator_type& __a)
2303*0b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a))
2304*0b57cec5SDimitry Andric{
2305*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2306*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2307*0b57cec5SDimitry Andric#endif
2308*0b57cec5SDimitry Andric    if (__a != __u.get_allocator())
2309*0b57cec5SDimitry Andric    {
2310*0b57cec5SDimitry Andric        iterator __i = __u.begin();
2311*0b57cec5SDimitry Andric        while (__u.size() != 0)
2312*0b57cec5SDimitry Andric        {
2313*0b57cec5SDimitry Andric            __table_.__insert_multi(
2314*0b57cec5SDimitry Andric                __u.__table_.remove((__i++).__i_)->__value_.__move());
2315*0b57cec5SDimitry Andric        }
2316*0b57cec5SDimitry Andric    }
2317*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2318*0b57cec5SDimitry Andric    else
2319*0b57cec5SDimitry Andric        __get_db()->swap(this, &__u);
2320*0b57cec5SDimitry Andric#endif
2321*0b57cec5SDimitry Andric}
2322*0b57cec5SDimitry Andric
2323*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2324*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2325*0b57cec5SDimitry Andric        initializer_list<value_type> __il)
2326*0b57cec5SDimitry Andric{
2327*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2328*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2329*0b57cec5SDimitry Andric#endif
2330*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
2331*0b57cec5SDimitry Andric}
2332*0b57cec5SDimitry Andric
2333*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2334*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2335*0b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
2336*0b57cec5SDimitry Andric        const key_equal& __eql)
2337*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
2338*0b57cec5SDimitry Andric{
2339*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2340*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2341*0b57cec5SDimitry Andric#endif
2342*0b57cec5SDimitry Andric    __table_.rehash(__n);
2343*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
2344*0b57cec5SDimitry Andric}
2345*0b57cec5SDimitry Andric
2346*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2347*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2348*0b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
2349*0b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
2350*0b57cec5SDimitry Andric    : __table_(__hf, __eql, typename __table::allocator_type(__a))
2351*0b57cec5SDimitry Andric{
2352*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
2353*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
2354*0b57cec5SDimitry Andric#endif
2355*0b57cec5SDimitry Andric    __table_.rehash(__n);
2356*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
2357*0b57cec5SDimitry Andric}
2358*0b57cec5SDimitry Andric
2359*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2360*0b57cec5SDimitry Andricinline
2361*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
2362*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
2363*0b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
2364*0b57cec5SDimitry Andric{
2365*0b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
2366*0b57cec5SDimitry Andric    return *this;
2367*0b57cec5SDimitry Andric}
2368*0b57cec5SDimitry Andric
2369*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2370*0b57cec5SDimitry Andricinline
2371*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
2372*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
2373*0b57cec5SDimitry Andric        initializer_list<value_type> __il)
2374*0b57cec5SDimitry Andric{
2375*0b57cec5SDimitry Andric    __table_.__assign_multi(__il.begin(), __il.end());
2376*0b57cec5SDimitry Andric    return *this;
2377*0b57cec5SDimitry Andric}
2378*0b57cec5SDimitry Andric
2379*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
2380*0b57cec5SDimitry Andric
2381*0b57cec5SDimitry Andric
2382*0b57cec5SDimitry Andric
2383*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2384*0b57cec5SDimitry Andrictemplate <class _InputIterator>
2385*0b57cec5SDimitry Andricinline
2386*0b57cec5SDimitry Andricvoid
2387*0b57cec5SDimitry Andricunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
2388*0b57cec5SDimitry Andric                                                            _InputIterator __last)
2389*0b57cec5SDimitry Andric{
2390*0b57cec5SDimitry Andric    for (; __first != __last; ++__first)
2391*0b57cec5SDimitry Andric        __table_.__insert_multi(*__first);
2392*0b57cec5SDimitry Andric}
2393*0b57cec5SDimitry Andric
2394*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2395*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
2396*0b57cec5SDimitry Andricvoid
2397*0b57cec5SDimitry Andricswap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2398*0b57cec5SDimitry Andric     unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2399*0b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
2400*0b57cec5SDimitry Andric{
2401*0b57cec5SDimitry Andric    __x.swap(__y);
2402*0b57cec5SDimitry Andric}
2403*0b57cec5SDimitry Andric
2404*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
2405*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>
2406*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
2407*0b57cec5SDimitry Andricvoid erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
2408*0b57cec5SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); }
2409*0b57cec5SDimitry Andric#endif
2410*0b57cec5SDimitry Andric
2411*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2412*0b57cec5SDimitry Andricbool
2413*0b57cec5SDimitry Andricoperator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2414*0b57cec5SDimitry Andric           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2415*0b57cec5SDimitry Andric{
2416*0b57cec5SDimitry Andric    if (__x.size() != __y.size())
2417*0b57cec5SDimitry Andric        return false;
2418*0b57cec5SDimitry Andric    typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
2419*0b57cec5SDimitry Andric                                                                 const_iterator;
2420*0b57cec5SDimitry Andric    typedef pair<const_iterator, const_iterator> _EqRng;
2421*0b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
2422*0b57cec5SDimitry Andric    {
2423*0b57cec5SDimitry Andric        _EqRng __xeq = __x.equal_range(__i->first);
2424*0b57cec5SDimitry Andric        _EqRng __yeq = __y.equal_range(__i->first);
2425*0b57cec5SDimitry Andric        if (_VSTD::distance(__xeq.first, __xeq.second) !=
2426*0b57cec5SDimitry Andric            _VSTD::distance(__yeq.first, __yeq.second) ||
2427*0b57cec5SDimitry Andric                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
2428*0b57cec5SDimitry Andric            return false;
2429*0b57cec5SDimitry Andric        __i = __xeq.second;
2430*0b57cec5SDimitry Andric    }
2431*0b57cec5SDimitry Andric    return true;
2432*0b57cec5SDimitry Andric}
2433*0b57cec5SDimitry Andric
2434*0b57cec5SDimitry Andrictemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2435*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
2436*0b57cec5SDimitry Andricbool
2437*0b57cec5SDimitry Andricoperator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2438*0b57cec5SDimitry Andric           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2439*0b57cec5SDimitry Andric{
2440*0b57cec5SDimitry Andric    return !(__x == __y);
2441*0b57cec5SDimitry Andric}
2442*0b57cec5SDimitry Andric
2443*0b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
2444*0b57cec5SDimitry Andric
2445*0b57cec5SDimitry Andric#endif  // _LIBCPP_UNORDERED_MAP
2446