1227825Stheraven// -*- C++ -*-
2227825Stheraven//===-------------------------- unordered_map -----------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open
7227825Stheraven// Source Licenses. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP_UNORDERED_MAP
12227825Stheraven#define _LIBCPP_UNORDERED_MAP
13227825Stheraven
14227825Stheraven/*
15227825Stheraven
16227825Stheraven    unordered_map synopsis
17227825Stheraven
18227825Stheraven#include <initializer_list>
19227825Stheraven
20227825Stheravennamespace std
21227825Stheraven{
22227825Stheraven
23227825Stheraventemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
24227825Stheraven          class Alloc = allocator<pair<const Key, T>>>
25227825Stheravenclass unordered_map
26227825Stheraven{
27227825Stheravenpublic:
28227825Stheraven    // types
29227825Stheraven    typedef Key                                                        key_type;
30227825Stheraven    typedef T                                                          mapped_type;
31227825Stheraven    typedef Hash                                                       hasher;
32227825Stheraven    typedef Pred                                                       key_equal;
33227825Stheraven    typedef Alloc                                                      allocator_type;
34227825Stheraven    typedef pair<const key_type, mapped_type>                          value_type;
35227825Stheraven    typedef value_type&                                                reference;
36227825Stheraven    typedef const value_type&                                          const_reference;
37227825Stheraven    typedef typename allocator_traits<allocator_type>::pointer         pointer;
38227825Stheraven    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
39227825Stheraven    typedef typename allocator_traits<allocator_type>::size_type       size_type;
40227825Stheraven    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
41227825Stheraven
42227825Stheraven    typedef /unspecified/ iterator;
43227825Stheraven    typedef /unspecified/ const_iterator;
44227825Stheraven    typedef /unspecified/ local_iterator;
45227825Stheraven    typedef /unspecified/ const_local_iterator;
46227825Stheraven
47227825Stheraven    unordered_map()
48227825Stheraven        noexcept(
49227825Stheraven            is_nothrow_default_constructible<hasher>::value &&
50227825Stheraven            is_nothrow_default_constructible<key_equal>::value &&
51227825Stheraven            is_nothrow_default_constructible<allocator_type>::value);
52227825Stheraven    explicit unordered_map(size_type n, const hasher& hf = hasher(),
53227825Stheraven                           const key_equal& eql = key_equal(),
54227825Stheraven                           const allocator_type& a = allocator_type());
55227825Stheraven    template <class InputIterator>
56227825Stheraven        unordered_map(InputIterator f, InputIterator l,
57227825Stheraven                      size_type n = 0, const hasher& hf = hasher(),
58227825Stheraven                      const key_equal& eql = key_equal(),
59227825Stheraven                      const allocator_type& a = allocator_type());
60227825Stheraven    explicit unordered_map(const allocator_type&);
61227825Stheraven    unordered_map(const unordered_map&);
62227825Stheraven    unordered_map(const unordered_map&, const Allocator&);
63227825Stheraven    unordered_map(unordered_map&&)
64227825Stheraven        noexcept(
65227825Stheraven            is_nothrow_move_constructible<hasher>::value &&
66227825Stheraven            is_nothrow_move_constructible<key_equal>::value &&
67227825Stheraven            is_nothrow_move_constructible<allocator_type>::value);
68227825Stheraven    unordered_map(unordered_map&&, const Allocator&);
69227825Stheraven    unordered_map(initializer_list<value_type>, size_type n = 0,
70227825Stheraven                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
71227825Stheraven                  const allocator_type& a = allocator_type());
72261272Sdim    unordered_map(size_type n, const allocator_type& a)
73261272Sdim      : unordered_map(n, hasher(), key_equal(), a) {}  // C++14
74261272Sdim    unordered_map(size_type n, const hasher& hf, const allocator_type& a)
75261272Sdim      : unordered_map(n, hf, key_equal(), a) {}  // C++14
76261272Sdim    template <class InputIterator>
77261272Sdim      unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
78261272Sdim      : unordered_map(f, l, n, hasher(), key_equal(), a) {}  // C++14
79261272Sdim    template <class InputIterator>
80261272Sdim      unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, 
81261272Sdim        const allocator_type& a)
82261272Sdim      : unordered_map(f, l, n, hf, key_equal(), a) {}  // C++14
83261272Sdim    unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
84261272Sdim      : unordered_map(il, n, hasher(), key_equal(), a) {}  // C++14
85261272Sdim    unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf, 
86261272Sdim      const allocator_type& a)
87261272Sdim      : unordered_map(il, n, hf, key_equal(), a) {}  // C++14
88227825Stheraven    ~unordered_map();
89227825Stheraven    unordered_map& operator=(const unordered_map&);
90227825Stheraven    unordered_map& operator=(unordered_map&&)
91227825Stheraven        noexcept(
92227825Stheraven            allocator_type::propagate_on_container_move_assignment::value &&
93227825Stheraven            is_nothrow_move_assignable<allocator_type>::value &&
94227825Stheraven            is_nothrow_move_assignable<hasher>::value &&
95227825Stheraven            is_nothrow_move_assignable<key_equal>::value);
96227825Stheraven    unordered_map& operator=(initializer_list<value_type>);
97227825Stheraven
98227825Stheraven    allocator_type get_allocator() const noexcept;
99227825Stheraven
100227825Stheraven    bool      empty() const noexcept;
101227825Stheraven    size_type size() const noexcept;
102227825Stheraven    size_type max_size() const noexcept;
103227825Stheraven
104227825Stheraven    iterator       begin() noexcept;
105227825Stheraven    iterator       end() noexcept;
106227825Stheraven    const_iterator begin()  const noexcept;
107227825Stheraven    const_iterator end()    const noexcept;
108227825Stheraven    const_iterator cbegin() const noexcept;
109227825Stheraven    const_iterator cend()   const noexcept;
110227825Stheraven
111227825Stheraven    template <class... Args>
112227825Stheraven        pair<iterator, bool> emplace(Args&&... args);
113227825Stheraven    template <class... Args>
114227825Stheraven        iterator emplace_hint(const_iterator position, Args&&... args);
115227825Stheraven    pair<iterator, bool> insert(const value_type& obj);
116227825Stheraven    template <class P>
117227825Stheraven        pair<iterator, bool> insert(P&& obj);
118227825Stheraven    iterator insert(const_iterator hint, const value_type& obj);
119227825Stheraven    template <class P>
120227825Stheraven        iterator insert(const_iterator hint, P&& obj);
121227825Stheraven    template <class InputIterator>
122227825Stheraven        void insert(InputIterator first, InputIterator last);
123227825Stheraven    void insert(initializer_list<value_type>);
124227825Stheraven
125288943Sdim    template <class... Args>
126288943Sdim        pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);          // C++17
127288943Sdim    template <class... Args>
128288943Sdim        pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);               // C++17
129288943Sdim    template <class... Args>
130288943Sdim        iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
131288943Sdim    template <class... Args>
132288943Sdim        iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);      // C++17
133288943Sdim    template <class M>
134288943Sdim        pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);            // C++17
135288943Sdim    template <class M>
136288943Sdim        pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);                 // C++17
137288943Sdim    template <class M>
138288943Sdim        iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);   // C++17
139288943Sdim    template <class M>
140288943Sdim        iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);        // C++17
141288943Sdim
142227825Stheraven    iterator erase(const_iterator position);
143288943Sdim    iterator erase(iterator position);  // C++14
144227825Stheraven    size_type erase(const key_type& k);
145227825Stheraven    iterator erase(const_iterator first, const_iterator last);
146227825Stheraven    void clear() noexcept;
147227825Stheraven
148227825Stheraven    void swap(unordered_map&)
149227825Stheraven        noexcept(
150227825Stheraven            (!allocator_type::propagate_on_container_swap::value ||
151227825Stheraven             __is_nothrow_swappable<allocator_type>::value) &&
152227825Stheraven            __is_nothrow_swappable<hasher>::value &&
153227825Stheraven            __is_nothrow_swappable<key_equal>::value);
154227825Stheraven
155227825Stheraven    hasher hash_function() const;
156227825Stheraven    key_equal key_eq() const;
157227825Stheraven
158227825Stheraven    iterator       find(const key_type& k);
159227825Stheraven    const_iterator find(const key_type& k) const;
160227825Stheraven    size_type count(const key_type& k) const;
161227825Stheraven    pair<iterator, iterator>             equal_range(const key_type& k);
162227825Stheraven    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
163227825Stheraven
164227825Stheraven    mapped_type& operator[](const key_type& k);
165227825Stheraven    mapped_type& operator[](key_type&& k);
166227825Stheraven
167227825Stheraven    mapped_type&       at(const key_type& k);
168227825Stheraven    const mapped_type& at(const key_type& k) const;
169227825Stheraven
170227825Stheraven    size_type bucket_count() const noexcept;
171227825Stheraven    size_type max_bucket_count() const noexcept;
172227825Stheraven
173227825Stheraven    size_type bucket_size(size_type n) const;
174227825Stheraven    size_type bucket(const key_type& k) const;
175227825Stheraven
176227825Stheraven    local_iterator       begin(size_type n);
177227825Stheraven    local_iterator       end(size_type n);
178227825Stheraven    const_local_iterator begin(size_type n) const;
179227825Stheraven    const_local_iterator end(size_type n) const;
180227825Stheraven    const_local_iterator cbegin(size_type n) const;
181227825Stheraven    const_local_iterator cend(size_type n) const;
182227825Stheraven
183227825Stheraven    float load_factor() const noexcept;
184227825Stheraven    float max_load_factor() const noexcept;
185227825Stheraven    void max_load_factor(float z);
186227825Stheraven    void rehash(size_type n);
187227825Stheraven    void reserve(size_type n);
188227825Stheraven};
189227825Stheraven
190227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
191227825Stheraven    void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
192227825Stheraven              unordered_map<Key, T, Hash, Pred, Alloc>& y)
193227825Stheraven              noexcept(noexcept(x.swap(y)));
194227825Stheraven
195227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
196227825Stheraven    bool
197227825Stheraven    operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
198227825Stheraven               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
199227825Stheraven
200227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
201227825Stheraven    bool
202227825Stheraven    operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
203227825Stheraven               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
204227825Stheraven
205227825Stheraventemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
206227825Stheraven          class Alloc = allocator<pair<const Key, T>>>
207227825Stheravenclass unordered_multimap
208227825Stheraven{
209227825Stheravenpublic:
210227825Stheraven    // types
211227825Stheraven    typedef Key                                                        key_type;
212227825Stheraven    typedef T                                                          mapped_type;
213227825Stheraven    typedef Hash                                                       hasher;
214227825Stheraven    typedef Pred                                                       key_equal;
215227825Stheraven    typedef Alloc                                                      allocator_type;
216227825Stheraven    typedef pair<const key_type, mapped_type>                          value_type;
217227825Stheraven    typedef value_type&                                                reference;
218227825Stheraven    typedef const value_type&                                          const_reference;
219227825Stheraven    typedef typename allocator_traits<allocator_type>::pointer         pointer;
220227825Stheraven    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
221227825Stheraven    typedef typename allocator_traits<allocator_type>::size_type       size_type;
222227825Stheraven    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
223227825Stheraven
224227825Stheraven    typedef /unspecified/ iterator;
225227825Stheraven    typedef /unspecified/ const_iterator;
226227825Stheraven    typedef /unspecified/ local_iterator;
227227825Stheraven    typedef /unspecified/ const_local_iterator;
228227825Stheraven
229227825Stheraven    unordered_multimap()
230227825Stheraven        noexcept(
231227825Stheraven            is_nothrow_default_constructible<hasher>::value &&
232227825Stheraven            is_nothrow_default_constructible<key_equal>::value &&
233227825Stheraven            is_nothrow_default_constructible<allocator_type>::value);
234227825Stheraven    explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
235227825Stheraven                           const key_equal& eql = key_equal(),
236227825Stheraven                           const allocator_type& a = allocator_type());
237227825Stheraven    template <class InputIterator>
238227825Stheraven        unordered_multimap(InputIterator f, InputIterator l,
239227825Stheraven                      size_type n = 0, const hasher& hf = hasher(),
240227825Stheraven                      const key_equal& eql = key_equal(),
241227825Stheraven                      const allocator_type& a = allocator_type());
242227825Stheraven    explicit unordered_multimap(const allocator_type&);
243227825Stheraven    unordered_multimap(const unordered_multimap&);
244227825Stheraven    unordered_multimap(const unordered_multimap&, const Allocator&);
245227825Stheraven    unordered_multimap(unordered_multimap&&)
246227825Stheraven        noexcept(
247227825Stheraven            is_nothrow_move_constructible<hasher>::value &&
248227825Stheraven            is_nothrow_move_constructible<key_equal>::value &&
249227825Stheraven            is_nothrow_move_constructible<allocator_type>::value);
250227825Stheraven    unordered_multimap(unordered_multimap&&, const Allocator&);
251227825Stheraven    unordered_multimap(initializer_list<value_type>, size_type n = 0,
252227825Stheraven                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
253227825Stheraven                  const allocator_type& a = allocator_type());
254261272Sdim    unordered_multimap(size_type n, const allocator_type& a)
255261272Sdim      : unordered_multimap(n, hasher(), key_equal(), a) {}  // C++14
256261272Sdim    unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
257261272Sdim      : unordered_multimap(n, hf, key_equal(), a) {}  // C++14
258261272Sdim    template <class InputIterator>
259261272Sdim      unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
260261272Sdim      : unordered_multimap(f, l, n, hasher(), key_equal(), a) {}  // C++14
261261272Sdim    template <class InputIterator>
262261272Sdim      unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, 
263261272Sdim        const allocator_type& a)
264261272Sdim      : unordered_multimap(f, l, n, hf, key_equal(), a) {}  // C++14
265261272Sdim    unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
266261272Sdim      : unordered_multimap(il, n, hasher(), key_equal(), a) {}  // C++14
267261272Sdim    unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf, 
268261272Sdim      const allocator_type& a)
269261272Sdim      : unordered_multimap(il, n, hf, key_equal(), a) {}  // C++14
270227825Stheraven    ~unordered_multimap();
271227825Stheraven    unordered_multimap& operator=(const unordered_multimap&);
272227825Stheraven    unordered_multimap& operator=(unordered_multimap&&)
273227825Stheraven        noexcept(
274227825Stheraven            allocator_type::propagate_on_container_move_assignment::value &&
275227825Stheraven            is_nothrow_move_assignable<allocator_type>::value &&
276227825Stheraven            is_nothrow_move_assignable<hasher>::value &&
277227825Stheraven            is_nothrow_move_assignable<key_equal>::value);
278227825Stheraven    unordered_multimap& operator=(initializer_list<value_type>);
279227825Stheraven
280227825Stheraven    allocator_type get_allocator() const noexcept;
281227825Stheraven
282227825Stheraven    bool      empty() const noexcept;
283227825Stheraven    size_type size() const noexcept;
284227825Stheraven    size_type max_size() const noexcept;
285227825Stheraven
286227825Stheraven    iterator       begin() noexcept;
287227825Stheraven    iterator       end() noexcept;
288227825Stheraven    const_iterator begin()  const noexcept;
289227825Stheraven    const_iterator end()    const noexcept;
290227825Stheraven    const_iterator cbegin() const noexcept;
291227825Stheraven    const_iterator cend()   const noexcept;
292227825Stheraven
293227825Stheraven    template <class... Args>
294227825Stheraven        iterator emplace(Args&&... args);
295227825Stheraven    template <class... Args>
296227825Stheraven        iterator emplace_hint(const_iterator position, Args&&... args);
297227825Stheraven    iterator insert(const value_type& obj);
298227825Stheraven    template <class P>
299227825Stheraven        iterator insert(P&& obj);
300227825Stheraven    iterator insert(const_iterator hint, const value_type& obj);
301227825Stheraven    template <class P>
302227825Stheraven        iterator insert(const_iterator hint, P&& obj);
303227825Stheraven    template <class InputIterator>
304227825Stheraven        void insert(InputIterator first, InputIterator last);
305227825Stheraven    void insert(initializer_list<value_type>);
306227825Stheraven
307227825Stheraven    iterator erase(const_iterator position);
308288943Sdim    iterator erase(iterator position);  // C++14
309227825Stheraven    size_type erase(const key_type& k);
310227825Stheraven    iterator erase(const_iterator first, const_iterator last);
311227825Stheraven    void clear() noexcept;
312227825Stheraven
313227825Stheraven    void swap(unordered_multimap&)
314227825Stheraven        noexcept(
315227825Stheraven            (!allocator_type::propagate_on_container_swap::value ||
316227825Stheraven             __is_nothrow_swappable<allocator_type>::value) &&
317227825Stheraven            __is_nothrow_swappable<hasher>::value &&
318227825Stheraven            __is_nothrow_swappable<key_equal>::value);
319227825Stheraven
320227825Stheraven    hasher hash_function() const;
321227825Stheraven    key_equal key_eq() const;
322227825Stheraven
323227825Stheraven    iterator       find(const key_type& k);
324227825Stheraven    const_iterator find(const key_type& k) const;
325227825Stheraven    size_type count(const key_type& k) const;
326227825Stheraven    pair<iterator, iterator>             equal_range(const key_type& k);
327227825Stheraven    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
328227825Stheraven
329227825Stheraven    size_type bucket_count() const noexcept;
330227825Stheraven    size_type max_bucket_count() const noexcept;
331227825Stheraven
332227825Stheraven    size_type bucket_size(size_type n) const;
333227825Stheraven    size_type bucket(const key_type& k) const;
334227825Stheraven
335227825Stheraven    local_iterator       begin(size_type n);
336227825Stheraven    local_iterator       end(size_type n);
337227825Stheraven    const_local_iterator begin(size_type n) const;
338227825Stheraven    const_local_iterator end(size_type n) const;
339227825Stheraven    const_local_iterator cbegin(size_type n) const;
340227825Stheraven    const_local_iterator cend(size_type n) const;
341227825Stheraven
342227825Stheraven    float load_factor() const noexcept;
343227825Stheraven    float max_load_factor() const noexcept;
344227825Stheraven    void max_load_factor(float z);
345227825Stheraven    void rehash(size_type n);
346227825Stheraven    void reserve(size_type n);
347227825Stheraven};
348227825Stheraven
349227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
350227825Stheraven    void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
351227825Stheraven              unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
352227825Stheraven              noexcept(noexcept(x.swap(y)));
353227825Stheraven
354227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
355227825Stheraven    bool
356227825Stheraven    operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
357227825Stheraven               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
358227825Stheraven
359227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
360227825Stheraven    bool
361227825Stheraven    operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
362227825Stheraven               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
363227825Stheraven
364227825Stheraven}  // std
365227825Stheraven
366227825Stheraven*/
367227825Stheraven
368227825Stheraven#include <__config>
369227825Stheraven#include <__hash_table>
370227825Stheraven#include <functional>
371227825Stheraven#include <stdexcept>
372227825Stheraven
373276792Sdim#include <__debug>
374276792Sdim
375227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
376227825Stheraven#pragma GCC system_header
377227825Stheraven#endif
378227825Stheraven
379227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
380227825Stheraven
381288943Sdimtemplate <class _Key, class _Cp, class _Hash,
382288943Sdim          bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value
383232924Stheraven         >
384227825Stheravenclass __unordered_map_hasher
385227825Stheraven    : private _Hash
386227825Stheraven{
387227825Stheravenpublic:
388227825Stheraven    _LIBCPP_INLINE_VISIBILITY
389227825Stheraven    __unordered_map_hasher()
390227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
391227825Stheraven        : _Hash() {}
392227825Stheraven    _LIBCPP_INLINE_VISIBILITY
393227825Stheraven    __unordered_map_hasher(const _Hash& __h)
394227825Stheraven        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
395227825Stheraven        : _Hash(__h) {}
396227825Stheraven    _LIBCPP_INLINE_VISIBILITY
397227825Stheraven    const _Hash& hash_function() const _NOEXCEPT {return *this;}
398227825Stheraven    _LIBCPP_INLINE_VISIBILITY
399232924Stheraven    size_t operator()(const _Cp& __x) const
400253146Stheraven        {return static_cast<const _Hash&>(*this)(__x.__cc.first);}
401232924Stheraven    _LIBCPP_INLINE_VISIBILITY
402232924Stheraven    size_t operator()(const _Key& __x) const
403227825Stheraven        {return static_cast<const _Hash&>(*this)(__x);}
404288943Sdim    void swap(__unordered_map_hasher&__y)
405288943Sdim        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
406288943Sdim    {
407288943Sdim        using _VSTD::swap;
408288943Sdim        swap(static_cast<const _Hash&>(*this), static_cast<const _Hash&>(__y));
409288943Sdim    }
410227825Stheraven};
411227825Stheraven
412253146Stheraventemplate <class _Key, class _Cp, class _Hash>
413253146Stheravenclass __unordered_map_hasher<_Key, _Cp, _Hash, false>
414227825Stheraven{
415227825Stheraven    _Hash __hash_;
416232924Stheraven
417227825Stheravenpublic:
418227825Stheraven    _LIBCPP_INLINE_VISIBILITY
419227825Stheraven    __unordered_map_hasher()
420227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
421227825Stheraven        : __hash_() {}
422227825Stheraven    _LIBCPP_INLINE_VISIBILITY
423227825Stheraven    __unordered_map_hasher(const _Hash& __h)
424227825Stheraven        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
425227825Stheraven        : __hash_(__h) {}
426227825Stheraven    _LIBCPP_INLINE_VISIBILITY
427227825Stheraven    const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
428227825Stheraven    _LIBCPP_INLINE_VISIBILITY
429232924Stheraven    size_t operator()(const _Cp& __x) const
430253146Stheraven        {return __hash_(__x.__cc.first);}
431232924Stheraven    _LIBCPP_INLINE_VISIBILITY
432232924Stheraven    size_t operator()(const _Key& __x) const
433227825Stheraven        {return __hash_(__x);}
434288943Sdim    void swap(__unordered_map_hasher&__y)
435288943Sdim        _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
436288943Sdim    {
437288943Sdim        using _VSTD::swap;
438288943Sdim        swap(__hash_, __y.__hash_);
439288943Sdim    }
440227825Stheraven};
441227825Stheraven
442288943Sdimtemplate <class _Key, class _Cp, class _Hash, bool __b>
443288943Sdiminline _LIBCPP_INLINE_VISIBILITY
444288943Sdimvoid
445288943Sdimswap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x,
446288943Sdim     __unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y)
447288943Sdim    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
448288943Sdim{
449288943Sdim    __x.swap(__y);
450288943Sdim}
451288943Sdim
452288943Sdimtemplate <class _Key, class _Cp, class _Pred,
453288943Sdim          bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
454232924Stheraven         >
455227825Stheravenclass __unordered_map_equal
456227825Stheraven    : private _Pred
457227825Stheraven{
458227825Stheravenpublic:
459227825Stheraven    _LIBCPP_INLINE_VISIBILITY
460227825Stheraven    __unordered_map_equal()
461227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
462227825Stheraven        : _Pred() {}
463227825Stheraven    _LIBCPP_INLINE_VISIBILITY
464227825Stheraven    __unordered_map_equal(const _Pred& __p)
465227825Stheraven        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
466227825Stheraven        : _Pred(__p) {}
467227825Stheraven    _LIBCPP_INLINE_VISIBILITY
468227825Stheraven    const _Pred& key_eq() const _NOEXCEPT {return *this;}
469227825Stheraven    _LIBCPP_INLINE_VISIBILITY
470232924Stheraven    bool operator()(const _Cp& __x, const _Cp& __y) const
471253146Stheraven        {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y.__cc.first);}
472232924Stheraven    _LIBCPP_INLINE_VISIBILITY
473232924Stheraven    bool operator()(const _Cp& __x, const _Key& __y) const
474253146Stheraven        {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y);}
475232924Stheraven    _LIBCPP_INLINE_VISIBILITY
476232924Stheraven    bool operator()(const _Key& __x, const _Cp& __y) const
477253146Stheraven        {return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);}
478288943Sdim    void swap(__unordered_map_equal&__y)
479288943Sdim        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
480288943Sdim    {
481288943Sdim        using _VSTD::swap;
482288943Sdim        swap(static_cast<const _Pred&>(*this), static_cast<const _Pred&>(__y));
483288943Sdim    }
484227825Stheraven};
485227825Stheraven
486253146Stheraventemplate <class _Key, class _Cp, class _Pred>
487253146Stheravenclass __unordered_map_equal<_Key, _Cp, _Pred, false>
488227825Stheraven{
489227825Stheraven    _Pred __pred_;
490232924Stheraven
491227825Stheravenpublic:
492227825Stheraven    _LIBCPP_INLINE_VISIBILITY
493227825Stheraven    __unordered_map_equal()
494227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
495227825Stheraven        : __pred_() {}
496227825Stheraven    _LIBCPP_INLINE_VISIBILITY
497227825Stheraven    __unordered_map_equal(const _Pred& __p)
498227825Stheraven        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
499227825Stheraven        : __pred_(__p) {}
500227825Stheraven    _LIBCPP_INLINE_VISIBILITY
501227825Stheraven    const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
502227825Stheraven    _LIBCPP_INLINE_VISIBILITY
503232924Stheraven    bool operator()(const _Cp& __x, const _Cp& __y) const
504253146Stheraven        {return __pred_(__x.__cc.first, __y.__cc.first);}
505232924Stheraven    _LIBCPP_INLINE_VISIBILITY
506232924Stheraven    bool operator()(const _Cp& __x, const _Key& __y) const
507253146Stheraven        {return __pred_(__x.__cc.first, __y);}
508232924Stheraven    _LIBCPP_INLINE_VISIBILITY
509232924Stheraven    bool operator()(const _Key& __x, const _Cp& __y) const
510253146Stheraven        {return __pred_(__x, __y.__cc.first);}
511288943Sdim    void swap(__unordered_map_equal&__y)
512288943Sdim        _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
513288943Sdim    {
514288943Sdim        using _VSTD::swap;
515288943Sdim        swap(__pred_, __y.__pred_);
516288943Sdim    }
517227825Stheraven};
518227825Stheraven
519288943Sdimtemplate <class _Key, class _Cp, class _Pred, bool __b>
520288943Sdiminline _LIBCPP_INLINE_VISIBILITY
521288943Sdimvoid
522288943Sdimswap(__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x,
523288943Sdim     __unordered_map_equal<_Key, _Cp, _Pred, __b>& __y)
524288943Sdim    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
525288943Sdim{
526288943Sdim    __x.swap(__y);
527288943Sdim}
528288943Sdim
529227825Stheraventemplate <class _Alloc>
530227825Stheravenclass __hash_map_node_destructor
531227825Stheraven{
532227825Stheraven    typedef _Alloc                              allocator_type;
533227825Stheraven    typedef allocator_traits<allocator_type>    __alloc_traits;
534227825Stheraven    typedef typename __alloc_traits::value_type::value_type value_type;
535227825Stheravenpublic:
536227825Stheraven    typedef typename __alloc_traits::pointer    pointer;
537227825Stheravenprivate:
538253146Stheraven    typedef typename value_type::value_type::first_type     first_type;
539253146Stheraven    typedef typename value_type::value_type::second_type    second_type;
540227825Stheraven
541227825Stheraven    allocator_type& __na_;
542227825Stheraven
543227825Stheraven    __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
544227825Stheraven
545227825Stheravenpublic:
546227825Stheraven    bool __first_constructed;
547227825Stheraven    bool __second_constructed;
548227825Stheraven
549227825Stheraven    _LIBCPP_INLINE_VISIBILITY
550227825Stheraven    explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
551227825Stheraven        : __na_(__na),
552227825Stheraven          __first_constructed(false),
553227825Stheraven          __second_constructed(false)
554227825Stheraven        {}
555227825Stheraven
556227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
557227825Stheraven    _LIBCPP_INLINE_VISIBILITY
558227825Stheraven    __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
559227825Stheraven        _NOEXCEPT
560227825Stheraven        : __na_(__x.__na_),
561227825Stheraven          __first_constructed(__x.__value_constructed),
562227825Stheraven          __second_constructed(__x.__value_constructed)
563227825Stheraven        {
564227825Stheraven            __x.__value_constructed = false;
565227825Stheraven        }
566227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
567227825Stheraven    _LIBCPP_INLINE_VISIBILITY
568227825Stheraven    __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
569227825Stheraven        : __na_(__x.__na_),
570227825Stheraven          __first_constructed(__x.__value_constructed),
571227825Stheraven          __second_constructed(__x.__value_constructed)
572227825Stheraven        {
573227825Stheraven            const_cast<bool&>(__x.__value_constructed) = false;
574227825Stheraven        }
575227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
576227825Stheraven
577227825Stheraven    _LIBCPP_INLINE_VISIBILITY
578227825Stheraven    void operator()(pointer __p) _NOEXCEPT
579227825Stheraven    {
580227825Stheraven        if (__second_constructed)
581253146Stheraven            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
582227825Stheraven        if (__first_constructed)
583253146Stheraven            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
584227825Stheraven        if (__p)
585227825Stheraven            __alloc_traits::deallocate(__na_, __p, 1);
586227825Stheraven    }
587227825Stheraven};
588227825Stheraven
589261272Sdim#if __cplusplus >= 201103L
590261272Sdim
591261272Sdimtemplate <class _Key, class _Tp>
592261272Sdimunion __hash_value_type
593261272Sdim{
594261272Sdim    typedef _Key                                     key_type;
595261272Sdim    typedef _Tp                                      mapped_type;
596261272Sdim    typedef pair<const key_type, mapped_type>        value_type;
597261272Sdim    typedef pair<key_type, mapped_type>              __nc_value_type;
598261272Sdim
599261272Sdim    value_type __cc;
600261272Sdim    __nc_value_type __nc;
601261272Sdim
602261272Sdim    template <class ..._Args>
603261272Sdim    _LIBCPP_INLINE_VISIBILITY
604261272Sdim    __hash_value_type(_Args&& ...__args)
605261272Sdim        : __cc(std::forward<_Args>(__args)...) {}
606261272Sdim
607261272Sdim    _LIBCPP_INLINE_VISIBILITY
608261272Sdim    __hash_value_type(const __hash_value_type& __v)
609261272Sdim        : __cc(__v.__cc) {}
610261272Sdim
611261272Sdim    _LIBCPP_INLINE_VISIBILITY
612261272Sdim    __hash_value_type(__hash_value_type&& __v)
613288943Sdim        : __nc(_VSTD::move(__v.__nc)) {}
614261272Sdim
615261272Sdim    _LIBCPP_INLINE_VISIBILITY
616261272Sdim    __hash_value_type& operator=(const __hash_value_type& __v)
617261272Sdim        {__nc = __v.__cc; return *this;}
618261272Sdim
619261272Sdim    _LIBCPP_INLINE_VISIBILITY
620261272Sdim    __hash_value_type& operator=(__hash_value_type&& __v)
621288943Sdim        {__nc = _VSTD::move(__v.__nc); return *this;}
622261272Sdim
623261272Sdim    _LIBCPP_INLINE_VISIBILITY
624261272Sdim    ~__hash_value_type() {__cc.~value_type();}
625261272Sdim};
626261272Sdim
627261272Sdim#else
628261272Sdim
629261272Sdimtemplate <class _Key, class _Tp>
630261272Sdimstruct __hash_value_type
631261272Sdim{
632261272Sdim    typedef _Key                                     key_type;
633261272Sdim    typedef _Tp                                      mapped_type;
634261272Sdim    typedef pair<const key_type, mapped_type>        value_type;
635261272Sdim
636261272Sdim    value_type __cc;
637261272Sdim
638261272Sdim    _LIBCPP_INLINE_VISIBILITY
639261272Sdim    __hash_value_type() {}
640261272Sdim
641261272Sdim    template <class _A0>
642261272Sdim    _LIBCPP_INLINE_VISIBILITY
643261272Sdim    __hash_value_type(const _A0& __a0)
644261272Sdim        : __cc(__a0) {}
645261272Sdim
646261272Sdim    template <class _A0, class _A1>
647261272Sdim    _LIBCPP_INLINE_VISIBILITY
648261272Sdim    __hash_value_type(const _A0& __a0, const _A1& __a1)
649261272Sdim        : __cc(__a0, __a1) {}
650261272Sdim};
651261272Sdim
652261272Sdim#endif
653261272Sdim
654227825Stheraventemplate <class _HashIterator>
655261272Sdimclass _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator
656227825Stheraven{
657227825Stheraven    _HashIterator __i_;
658227825Stheraven
659253146Stheraven    typedef const typename _HashIterator::value_type::value_type::first_type key_type;
660253146Stheraven    typedef typename _HashIterator::value_type::value_type::second_type      mapped_type;
661227825Stheravenpublic:
662227825Stheraven    typedef forward_iterator_tag                                 iterator_category;
663227825Stheraven    typedef pair<key_type, mapped_type>                          value_type;
664227825Stheraven    typedef typename _HashIterator::difference_type              difference_type;
665227825Stheraven    typedef value_type&                                          reference;
666300770Sdim    typedef typename __rebind_pointer<typename _HashIterator::pointer, value_type>::type
667300770Sdim        pointer;
668227825Stheraven
669227825Stheraven    _LIBCPP_INLINE_VISIBILITY
670227825Stheraven    __hash_map_iterator() _NOEXCEPT {}
671227825Stheraven
672227825Stheraven    _LIBCPP_INLINE_VISIBILITY
673227825Stheraven    __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
674227825Stheraven
675227825Stheraven    _LIBCPP_INLINE_VISIBILITY
676253146Stheraven    reference operator*() const {return __i_->__cc;}
677227825Stheraven    _LIBCPP_INLINE_VISIBILITY
678253146Stheraven    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
679227825Stheraven
680227825Stheraven    _LIBCPP_INLINE_VISIBILITY
681227825Stheraven    __hash_map_iterator& operator++() {++__i_; return *this;}
682227825Stheraven    _LIBCPP_INLINE_VISIBILITY
683227825Stheraven    __hash_map_iterator operator++(int)
684227825Stheraven    {
685227825Stheraven        __hash_map_iterator __t(*this);
686227825Stheraven        ++(*this);
687227825Stheraven        return __t;
688227825Stheraven    }
689227825Stheraven
690227825Stheraven    friend _LIBCPP_INLINE_VISIBILITY
691227825Stheraven        bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
692227825Stheraven        {return __x.__i_ == __y.__i_;}
693227825Stheraven    friend _LIBCPP_INLINE_VISIBILITY
694227825Stheraven        bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
695227825Stheraven        {return __x.__i_ != __y.__i_;}
696227825Stheraven
697261272Sdim    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
698261272Sdim    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
699261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
700261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
701261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
702227825Stheraven};
703227825Stheraven
704227825Stheraventemplate <class _HashIterator>
705261272Sdimclass _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator
706227825Stheraven{
707227825Stheraven    _HashIterator __i_;
708227825Stheraven
709253146Stheraven    typedef const typename _HashIterator::value_type::value_type::first_type key_type;
710253146Stheraven    typedef typename _HashIterator::value_type::value_type::second_type      mapped_type;
711227825Stheravenpublic:
712227825Stheraven    typedef forward_iterator_tag                                 iterator_category;
713227825Stheraven    typedef pair<key_type, mapped_type>                          value_type;
714227825Stheraven    typedef typename _HashIterator::difference_type              difference_type;
715227825Stheraven    typedef const value_type&                                    reference;
716300770Sdim    typedef typename __rebind_pointer<typename _HashIterator::pointer, const value_type>::type
717300770Sdim        pointer;
718227825Stheraven
719227825Stheraven    _LIBCPP_INLINE_VISIBILITY
720227825Stheraven    __hash_map_const_iterator() _NOEXCEPT {}
721227825Stheraven
722227825Stheraven    _LIBCPP_INLINE_VISIBILITY
723227825Stheraven    __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
724227825Stheraven    _LIBCPP_INLINE_VISIBILITY
725227825Stheraven    __hash_map_const_iterator(
726227825Stheraven            __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
727227825Stheraven                 _NOEXCEPT
728227825Stheraven                : __i_(__i.__i_) {}
729227825Stheraven
730227825Stheraven    _LIBCPP_INLINE_VISIBILITY
731253146Stheraven    reference operator*() const {return __i_->__cc;}
732227825Stheraven    _LIBCPP_INLINE_VISIBILITY
733253146Stheraven    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
734227825Stheraven
735227825Stheraven    _LIBCPP_INLINE_VISIBILITY
736227825Stheraven    __hash_map_const_iterator& operator++() {++__i_; return *this;}
737227825Stheraven    _LIBCPP_INLINE_VISIBILITY
738227825Stheraven    __hash_map_const_iterator operator++(int)
739227825Stheraven    {
740227825Stheraven        __hash_map_const_iterator __t(*this);
741227825Stheraven        ++(*this);
742227825Stheraven        return __t;
743227825Stheraven    }
744227825Stheraven
745227825Stheraven    friend _LIBCPP_INLINE_VISIBILITY
746227825Stheraven        bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
747227825Stheraven        {return __x.__i_ == __y.__i_;}
748227825Stheraven    friend _LIBCPP_INLINE_VISIBILITY
749227825Stheraven        bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
750227825Stheraven        {return __x.__i_ != __y.__i_;}
751227825Stheraven
752261272Sdim    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
753261272Sdim    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
754261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
755261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
756227825Stheraven};
757227825Stheraven
758227825Stheraventemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
759227825Stheraven          class _Alloc = allocator<pair<const _Key, _Tp> > >
760261272Sdimclass _LIBCPP_TYPE_VIS_ONLY unordered_map
761227825Stheraven{
762227825Stheravenpublic:
763227825Stheraven    // types
764227825Stheraven    typedef _Key                                           key_type;
765227825Stheraven    typedef _Tp                                            mapped_type;
766227825Stheraven    typedef _Hash                                          hasher;
767227825Stheraven    typedef _Pred                                          key_equal;
768227825Stheraven    typedef _Alloc                                         allocator_type;
769227825Stheraven    typedef pair<const key_type, mapped_type>              value_type;
770253146Stheraven    typedef pair<key_type, mapped_type>                    __nc_value_type;
771227825Stheraven    typedef value_type&                                    reference;
772227825Stheraven    typedef const value_type&                              const_reference;
773261272Sdim    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
774261272Sdim                  "Invalid allocator::value_type");
775227825Stheraven
776227825Stheravenprivate:
777261272Sdim    typedef __hash_value_type<key_type, mapped_type>                 __value_type;
778253146Stheraven    typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
779253146Stheraven    typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
780288943Sdim    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
781288943Sdim                                                 __value_type>::type __allocator_type;
782227825Stheraven
783227825Stheraven    typedef __hash_table<__value_type, __hasher,
784227825Stheraven                         __key_equal,  __allocator_type>   __table;
785227825Stheraven
786227825Stheraven    __table __table_;
787227825Stheraven
788227825Stheraven    typedef typename __table::__node_pointer               __node_pointer;
789227825Stheraven    typedef typename __table::__node_const_pointer         __node_const_pointer;
790227825Stheraven    typedef typename __table::__node_traits                __node_traits;
791227825Stheraven    typedef typename __table::__node_allocator             __node_allocator;
792227825Stheraven    typedef typename __table::__node                       __node;
793232924Stheraven    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
794232924Stheraven    typedef unique_ptr<__node, _Dp>                         __node_holder;
795227825Stheraven    typedef allocator_traits<allocator_type>               __alloc_traits;
796227825Stheravenpublic:
797227825Stheraven    typedef typename __alloc_traits::pointer         pointer;
798227825Stheraven    typedef typename __alloc_traits::const_pointer   const_pointer;
799227825Stheraven    typedef typename __alloc_traits::size_type       size_type;
800227825Stheraven    typedef typename __alloc_traits::difference_type difference_type;
801227825Stheraven
802227825Stheraven    typedef __hash_map_iterator<typename __table::iterator>       iterator;
803227825Stheraven    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
804227825Stheraven    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
805227825Stheraven    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
806227825Stheraven
807227825Stheraven    _LIBCPP_INLINE_VISIBILITY
808227825Stheraven    unordered_map()
809227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
810261272Sdim        {
811261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
812261272Sdim            __get_db()->__insert_c(this);
813261272Sdim#endif
814261272Sdim        }
815227825Stheraven    explicit unordered_map(size_type __n, const hasher& __hf = hasher(),
816227825Stheraven                           const key_equal& __eql = key_equal());
817227825Stheraven    unordered_map(size_type __n, const hasher& __hf,
818227825Stheraven                  const key_equal& __eql,
819227825Stheraven                  const allocator_type& __a);
820227825Stheraven    template <class _InputIterator>
821227825Stheraven        unordered_map(_InputIterator __first, _InputIterator __last);
822227825Stheraven    template <class _InputIterator>
823227825Stheraven        unordered_map(_InputIterator __first, _InputIterator __last,
824227825Stheraven                      size_type __n, const hasher& __hf = hasher(),
825227825Stheraven                      const key_equal& __eql = key_equal());
826227825Stheraven    template <class _InputIterator>
827227825Stheraven        unordered_map(_InputIterator __first, _InputIterator __last,
828227825Stheraven                      size_type __n, const hasher& __hf,
829227825Stheraven                      const key_equal& __eql,
830227825Stheraven                      const allocator_type& __a);
831227825Stheraven    explicit unordered_map(const allocator_type& __a);
832227825Stheraven    unordered_map(const unordered_map& __u);
833227825Stheraven    unordered_map(const unordered_map& __u, const allocator_type& __a);
834227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
835227825Stheraven    unordered_map(unordered_map&& __u)
836227825Stheraven        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
837227825Stheraven    unordered_map(unordered_map&& __u, const allocator_type& __a);
838227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
839227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
840227825Stheraven    unordered_map(initializer_list<value_type> __il);
841227825Stheraven    unordered_map(initializer_list<value_type> __il, size_type __n,
842227825Stheraven                  const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
843227825Stheraven    unordered_map(initializer_list<value_type> __il, size_type __n,
844227825Stheraven                  const hasher& __hf, const key_equal& __eql,
845227825Stheraven                  const allocator_type& __a);
846227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
847261272Sdim#if _LIBCPP_STD_VER > 11
848261272Sdim    _LIBCPP_INLINE_VISIBILITY
849261272Sdim    unordered_map(size_type __n, const allocator_type& __a)
850261272Sdim      : unordered_map(__n, hasher(), key_equal(), __a) {}
851261272Sdim    _LIBCPP_INLINE_VISIBILITY
852261272Sdim    unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
853261272Sdim      : unordered_map(__n, __hf, key_equal(), __a) {}
854261272Sdim    template <class _InputIterator>
855261272Sdim    _LIBCPP_INLINE_VISIBILITY
856261272Sdim      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
857261272Sdim      : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
858261272Sdim    template <class _InputIterator>
859261272Sdim    _LIBCPP_INLINE_VISIBILITY
860261272Sdim      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, 
861261272Sdim        const allocator_type& __a)
862261272Sdim      : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
863261272Sdim    _LIBCPP_INLINE_VISIBILITY
864261272Sdim    unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
865261272Sdim      : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
866261272Sdim    _LIBCPP_INLINE_VISIBILITY
867261272Sdim    unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, 
868261272Sdim      const allocator_type& __a)
869261272Sdim      : unordered_map(__il, __n, __hf, key_equal(), __a) {}
870261272Sdim#endif
871227825Stheraven    // ~unordered_map() = default;
872227825Stheraven    _LIBCPP_INLINE_VISIBILITY
873227825Stheraven    unordered_map& operator=(const unordered_map& __u)
874227825Stheraven    {
875253146Stheraven#if __cplusplus >= 201103L
876227825Stheraven        __table_ = __u.__table_;
877253146Stheraven#else
878276792Sdim        if (this != &__u) {
879276792Sdim            __table_.clear();
880276792Sdim            __table_.hash_function() = __u.__table_.hash_function();
881276792Sdim            __table_.key_eq() = __u.__table_.key_eq();
882276792Sdim            __table_.max_load_factor() = __u.__table_.max_load_factor();
883276792Sdim            __table_.__copy_assign_alloc(__u.__table_);
884276792Sdim            insert(__u.begin(), __u.end());
885276792Sdim        }
886253146Stheraven#endif
887227825Stheraven        return *this;
888227825Stheraven    }
889227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
890227825Stheraven    unordered_map& operator=(unordered_map&& __u)
891227825Stheraven        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
892227825Stheraven#endif
893227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
894227825Stheraven    unordered_map& operator=(initializer_list<value_type> __il);
895227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
896227825Stheraven
897227825Stheraven    _LIBCPP_INLINE_VISIBILITY
898227825Stheraven    allocator_type get_allocator() const _NOEXCEPT
899227825Stheraven        {return allocator_type(__table_.__node_alloc());}
900227825Stheraven
901227825Stheraven    _LIBCPP_INLINE_VISIBILITY
902227825Stheraven    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
903227825Stheraven    _LIBCPP_INLINE_VISIBILITY
904227825Stheraven    size_type size() const _NOEXCEPT  {return __table_.size();}
905227825Stheraven    _LIBCPP_INLINE_VISIBILITY
906227825Stheraven    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
907227825Stheraven
908227825Stheraven    _LIBCPP_INLINE_VISIBILITY
909227825Stheraven    iterator       begin() _NOEXCEPT        {return __table_.begin();}
910227825Stheraven    _LIBCPP_INLINE_VISIBILITY
911227825Stheraven    iterator       end() _NOEXCEPT          {return __table_.end();}
912227825Stheraven    _LIBCPP_INLINE_VISIBILITY
913227825Stheraven    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
914227825Stheraven    _LIBCPP_INLINE_VISIBILITY
915227825Stheraven    const_iterator end()    const _NOEXCEPT {return __table_.end();}
916227825Stheraven    _LIBCPP_INLINE_VISIBILITY
917227825Stheraven    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
918227825Stheraven    _LIBCPP_INLINE_VISIBILITY
919227825Stheraven    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
920227825Stheraven
921227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
922227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
923227825Stheraven
924241900Sdim    template <class... _Args>
925241900Sdim        pair<iterator, bool> emplace(_Args&&... __args);
926227825Stheraven
927241900Sdim    template <class... _Args>
928227825Stheraven        _LIBCPP_INLINE_VISIBILITY
929261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
930261272Sdim        iterator emplace_hint(const_iterator __p, _Args&&... __args)
931261272Sdim        {
932261272Sdim            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
933261272Sdim                "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
934261272Sdim                " referring to this unordered_map");
935261272Sdim            return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
936261272Sdim        }
937261272Sdim#else
938241900Sdim        iterator emplace_hint(const_iterator, _Args&&... __args)
939241900Sdim            {return emplace(_VSTD::forward<_Args>(__args)...).first;}
940261272Sdim#endif
941227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
942227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
943227825Stheraven    _LIBCPP_INLINE_VISIBILITY
944227825Stheraven    pair<iterator, bool> insert(const value_type& __x)
945227825Stheraven        {return __table_.__insert_unique(__x);}
946227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
947232924Stheraven    template <class _Pp,
948232924Stheraven              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
949227825Stheraven        _LIBCPP_INLINE_VISIBILITY
950232924Stheraven        pair<iterator, bool> insert(_Pp&& __x)
951232924Stheraven            {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
952227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
953227825Stheraven    _LIBCPP_INLINE_VISIBILITY
954261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
955261272Sdim    iterator insert(const_iterator __p, const value_type& __x)
956261272Sdim        {
957261272Sdim            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
958261272Sdim                "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
959261272Sdim                " referring to this unordered_map");
960261272Sdim            return insert(__x).first;
961261272Sdim        }
962261272Sdim#else
963227825Stheraven    iterator insert(const_iterator, const value_type& __x)
964227825Stheraven        {return insert(__x).first;}
965261272Sdim#endif
966227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
967232924Stheraven    template <class _Pp,
968232924Stheraven              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
969227825Stheraven        _LIBCPP_INLINE_VISIBILITY
970261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
971261272Sdim        iterator insert(const_iterator __p, _Pp&& __x)
972261272Sdim        {
973261272Sdim            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
974261272Sdim                "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
975261272Sdim                " referring to this unordered_map");
976261272Sdim            return insert(_VSTD::forward<_Pp>(__x)).first;
977261272Sdim        }
978261272Sdim#else
979232924Stheraven        iterator insert(const_iterator, _Pp&& __x)
980232924Stheraven            {return insert(_VSTD::forward<_Pp>(__x)).first;}
981261272Sdim#endif
982227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
983227825Stheraven    template <class _InputIterator>
984227825Stheraven        void insert(_InputIterator __first, _InputIterator __last);
985227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
986227825Stheraven    _LIBCPP_INLINE_VISIBILITY
987227825Stheraven    void insert(initializer_list<value_type> __il)
988227825Stheraven        {insert(__il.begin(), __il.end());}
989227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
990227825Stheraven
991288943Sdim#if _LIBCPP_STD_VER > 14
992288943Sdim#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
993288943Sdim#ifndef _LIBCPP_HAS_NO_VARIADICS
994288943Sdim    template <class... _Args>
995288943Sdim        _LIBCPP_INLINE_VISIBILITY
996288943Sdim        pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
997288943Sdim    {
998288943Sdim        iterator __p = __table_.find(__k);
999288943Sdim        if ( __p != end())
1000288943Sdim            return _VSTD::make_pair(__p, false);
1001288943Sdim        else
1002288943Sdim            return _VSTD::make_pair(
1003288943Sdim                      emplace_hint(__p, 
1004288943Sdim                        _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), 
1005288943Sdim                        _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
1006288943Sdim                      true);
1007288943Sdim    }
1008288943Sdim
1009288943Sdim    template <class... _Args>
1010288943Sdim        _LIBCPP_INLINE_VISIBILITY
1011288943Sdim        pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
1012288943Sdim    {
1013288943Sdim        iterator __p = __table_.find(__k);
1014288943Sdim        if ( __p != end())
1015288943Sdim            return _VSTD::make_pair(__p, false);
1016288943Sdim        else
1017288943Sdim            return _VSTD::make_pair(
1018288943Sdim                      emplace_hint(__p, 
1019288943Sdim                        _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), 
1020288943Sdim                        _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
1021288943Sdim                      true);
1022288943Sdim    }
1023288943Sdim
1024288943Sdim    template <class... _Args>
1025288943Sdim        _LIBCPP_INLINE_VISIBILITY
1026288943Sdim        iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
1027288943Sdim    {
1028288943Sdim        iterator __p = __table_.find(__k);
1029288943Sdim        if ( __p != end())
1030288943Sdim            return __p;
1031288943Sdim        else
1032288943Sdim            return emplace_hint(__h, 
1033288943Sdim                      _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), 
1034288943Sdim                      _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
1035288943Sdim    }
1036288943Sdim
1037288943Sdim    template <class... _Args>
1038288943Sdim        _LIBCPP_INLINE_VISIBILITY
1039288943Sdim        iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
1040288943Sdim    {
1041288943Sdim        iterator __p = __table_.find(__k);
1042288943Sdim        if ( __p != end())
1043288943Sdim            return __p;
1044288943Sdim        else
1045288943Sdim            return emplace_hint(__h, 
1046288943Sdim                      _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), 
1047288943Sdim                      _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
1048288943Sdim    }
1049288943Sdim
1050288943Sdim    template <class _Vp>
1051288943Sdim        _LIBCPP_INLINE_VISIBILITY
1052288943Sdim        pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
1053288943Sdim    {
1054288943Sdim        iterator __p = __table_.find(__k);
1055288943Sdim        if ( __p != end())
1056288943Sdim        {
1057288943Sdim            __p->second = _VSTD::move(__v);
1058288943Sdim            return _VSTD::make_pair(__p, false);
1059288943Sdim        }
1060288943Sdim        return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
1061288943Sdim    }
1062288943Sdim        
1063288943Sdim    template <class _Vp>
1064288943Sdim        _LIBCPP_INLINE_VISIBILITY
1065288943Sdim        pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
1066288943Sdim    {
1067288943Sdim        iterator __p = __table_.find(__k);
1068288943Sdim        if ( __p != end())
1069288943Sdim        {
1070288943Sdim            __p->second = _VSTD::move(__v);
1071288943Sdim            return _VSTD::make_pair(__p, false);
1072288943Sdim        }
1073288943Sdim        return _VSTD::make_pair(emplace_hint(__p, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v)), true);
1074288943Sdim    }
1075288943Sdim
1076288943Sdim    template <class _Vp>
1077288943Sdim        _LIBCPP_INLINE_VISIBILITY
1078288943Sdim        iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
1079288943Sdim     {
1080288943Sdim        iterator __p = __table_.find(__k);
1081288943Sdim        if ( __p != end())
1082288943Sdim        {
1083288943Sdim            __p->second = _VSTD::move(__v);
1084288943Sdim            return __p;
1085288943Sdim        }
1086288943Sdim        return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v));
1087288943Sdim     }
1088288943Sdim
1089288943Sdim    template <class _Vp>
1090288943Sdim        _LIBCPP_INLINE_VISIBILITY
1091288943Sdim        iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
1092288943Sdim     {
1093288943Sdim        iterator __p = __table_.find(__k);
1094288943Sdim        if ( __p != end())
1095288943Sdim        {
1096288943Sdim            __p->second = _VSTD::move(__v);
1097288943Sdim            return __p;
1098288943Sdim        }
1099288943Sdim        return emplace_hint(__h, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v));
1100288943Sdim     }
1101288943Sdim#endif
1102288943Sdim#endif
1103288943Sdim#endif
1104288943Sdim
1105227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1106227825Stheraven    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
1107227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1108288943Sdim    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
1109288943Sdim    _LIBCPP_INLINE_VISIBILITY
1110227825Stheraven    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
1111227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1112227825Stheraven    iterator erase(const_iterator __first, const_iterator __last)
1113227825Stheraven        {return __table_.erase(__first.__i_, __last.__i_);}
1114227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1115227825Stheraven    void clear() _NOEXCEPT {__table_.clear();}
1116227825Stheraven
1117227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1118227825Stheraven    void swap(unordered_map& __u)
1119227825Stheraven        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
1120227825Stheraven        {__table_.swap(__u.__table_);}
1121227825Stheraven
1122227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1123227825Stheraven    hasher hash_function() const
1124227825Stheraven        {return __table_.hash_function().hash_function();}
1125227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1126227825Stheraven    key_equal key_eq() const
1127227825Stheraven        {return __table_.key_eq().key_eq();}
1128227825Stheraven
1129227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1130227825Stheraven    iterator       find(const key_type& __k)       {return __table_.find(__k);}
1131227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1132227825Stheraven    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1133227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1134227825Stheraven    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
1135227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1136227825Stheraven    pair<iterator, iterator>             equal_range(const key_type& __k)
1137227825Stheraven        {return __table_.__equal_range_unique(__k);}
1138227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1139227825Stheraven    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
1140227825Stheraven        {return __table_.__equal_range_unique(__k);}
1141227825Stheraven
1142227825Stheraven    mapped_type& operator[](const key_type& __k);
1143227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1144227825Stheraven    mapped_type& operator[](key_type&& __k);
1145227825Stheraven#endif
1146227825Stheraven
1147227825Stheraven    mapped_type&       at(const key_type& __k);
1148227825Stheraven    const mapped_type& at(const key_type& __k) const;
1149227825Stheraven
1150227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1151227825Stheraven    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
1152227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1153227825Stheraven    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
1154227825Stheraven
1155227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1156227825Stheraven    size_type bucket_size(size_type __n) const
1157227825Stheraven        {return __table_.bucket_size(__n);}
1158227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1159227825Stheraven    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
1160227825Stheraven
1161227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1162227825Stheraven    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
1163227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1164227825Stheraven    local_iterator       end(size_type __n)          {return __table_.end(__n);}
1165227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1166227825Stheraven    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
1167227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1168227825Stheraven    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
1169227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1170227825Stheraven    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
1171227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1172227825Stheraven    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
1173227825Stheraven
1174227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1175227825Stheraven    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
1176227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1177227825Stheraven    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
1178227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1179227825Stheraven    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
1180227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1181227825Stheraven    void rehash(size_type __n) {__table_.rehash(__n);}
1182227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1183227825Stheraven    void reserve(size_type __n) {__table_.reserve(__n);}
1184227825Stheraven
1185261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1186261272Sdim
1187261272Sdim    bool __dereferenceable(const const_iterator* __i) const
1188261272Sdim        {return __table_.__dereferenceable(&__i->__i_);}
1189261272Sdim    bool __decrementable(const const_iterator* __i) const
1190261272Sdim        {return __table_.__decrementable(&__i->__i_);}
1191261272Sdim    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1192261272Sdim        {return __table_.__addable(&__i->__i_, __n);}
1193261272Sdim    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1194261272Sdim        {return __table_.__addable(&__i->__i_, __n);}
1195261272Sdim
1196261272Sdim#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1197261272Sdim
1198227825Stheravenprivate:
1199227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1200241900Sdim    __node_holder __construct_node();
1201241900Sdim    template <class _A0>
1202253146Stheraven        __node_holder
1203241900Sdim         __construct_node(_A0&& __a0);
1204253146Stheraven    __node_holder __construct_node_with_key(key_type&& __k);
1205227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1206241900Sdim    template <class _A0, class _A1, class ..._Args>
1207241900Sdim        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
1208227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1209253146Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1210253146Stheraven    __node_holder __construct_node_with_key(const key_type& __k);
1211227825Stheraven};
1212227825Stheraven
1213227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1214227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1215227825Stheraven        size_type __n, const hasher& __hf, const key_equal& __eql)
1216227825Stheraven    : __table_(__hf, __eql)
1217227825Stheraven{
1218261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1219261272Sdim    __get_db()->__insert_c(this);
1220261272Sdim#endif
1221227825Stheraven    __table_.rehash(__n);
1222227825Stheraven}
1223227825Stheraven
1224227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1225227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1226227825Stheraven        size_type __n, const hasher& __hf, const key_equal& __eql,
1227227825Stheraven        const allocator_type& __a)
1228227825Stheraven    : __table_(__hf, __eql, __a)
1229227825Stheraven{
1230261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1231261272Sdim    __get_db()->__insert_c(this);
1232261272Sdim#endif
1233227825Stheraven    __table_.rehash(__n);
1234227825Stheraven}
1235227825Stheraven
1236227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1237227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1238227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1239227825Stheraven        const allocator_type& __a)
1240227825Stheraven    : __table_(__a)
1241227825Stheraven{
1242261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1243261272Sdim    __get_db()->__insert_c(this);
1244261272Sdim#endif
1245227825Stheraven}
1246227825Stheraven
1247227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1248227825Stheraventemplate <class _InputIterator>
1249227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1250227825Stheraven        _InputIterator __first, _InputIterator __last)
1251227825Stheraven{
1252261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1253261272Sdim    __get_db()->__insert_c(this);
1254261272Sdim#endif
1255227825Stheraven    insert(__first, __last);
1256227825Stheraven}
1257227825Stheraven
1258227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1259227825Stheraventemplate <class _InputIterator>
1260227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1261227825Stheraven        _InputIterator __first, _InputIterator __last, size_type __n,
1262227825Stheraven        const hasher& __hf, const key_equal& __eql)
1263227825Stheraven    : __table_(__hf, __eql)
1264227825Stheraven{
1265261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1266261272Sdim    __get_db()->__insert_c(this);
1267261272Sdim#endif
1268227825Stheraven    __table_.rehash(__n);
1269227825Stheraven    insert(__first, __last);
1270227825Stheraven}
1271227825Stheraven
1272227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1273227825Stheraventemplate <class _InputIterator>
1274227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1275227825Stheraven        _InputIterator __first, _InputIterator __last, size_type __n,
1276227825Stheraven        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1277227825Stheraven    : __table_(__hf, __eql, __a)
1278227825Stheraven{
1279261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1280261272Sdim    __get_db()->__insert_c(this);
1281261272Sdim#endif
1282227825Stheraven    __table_.rehash(__n);
1283227825Stheraven    insert(__first, __last);
1284227825Stheraven}
1285227825Stheraven
1286227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1287227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1288227825Stheraven        const unordered_map& __u)
1289227825Stheraven    : __table_(__u.__table_)
1290227825Stheraven{
1291261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1292261272Sdim    __get_db()->__insert_c(this);
1293261272Sdim#endif
1294227825Stheraven    __table_.rehash(__u.bucket_count());
1295227825Stheraven    insert(__u.begin(), __u.end());
1296227825Stheraven}
1297227825Stheraven
1298227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1299227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1300227825Stheraven        const unordered_map& __u, const allocator_type& __a)
1301227825Stheraven    : __table_(__u.__table_, __a)
1302227825Stheraven{
1303261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1304261272Sdim    __get_db()->__insert_c(this);
1305261272Sdim#endif
1306227825Stheraven    __table_.rehash(__u.bucket_count());
1307227825Stheraven    insert(__u.begin(), __u.end());
1308227825Stheraven}
1309227825Stheraven
1310227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1311227825Stheraven
1312227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1313227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1314227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1315227825Stheraven        unordered_map&& __u)
1316227825Stheraven    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1317227825Stheraven    : __table_(_VSTD::move(__u.__table_))
1318227825Stheraven{
1319261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1320261272Sdim    __get_db()->__insert_c(this);
1321261272Sdim    __get_db()->swap(this, &__u);
1322261272Sdim#endif
1323227825Stheraven}
1324227825Stheraven
1325227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1326227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1327227825Stheraven        unordered_map&& __u, const allocator_type& __a)
1328227825Stheraven    : __table_(_VSTD::move(__u.__table_), __a)
1329227825Stheraven{
1330261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1331261272Sdim    __get_db()->__insert_c(this);
1332261272Sdim#endif
1333227825Stheraven    if (__a != __u.get_allocator())
1334227825Stheraven    {
1335227825Stheraven        iterator __i = __u.begin();
1336227825Stheraven        while (__u.size() != 0)
1337227825Stheraven            __table_.__insert_unique(
1338227825Stheraven                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
1339227825Stheraven                                    );
1340227825Stheraven    }
1341261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1342261272Sdim    else
1343261272Sdim        __get_db()->swap(this, &__u);
1344261272Sdim#endif
1345227825Stheraven}
1346227825Stheraven
1347227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1348227825Stheraven
1349227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1350227825Stheraven
1351227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1352227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1353227825Stheraven        initializer_list<value_type> __il)
1354227825Stheraven{
1355261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1356261272Sdim    __get_db()->__insert_c(this);
1357261272Sdim#endif
1358227825Stheraven    insert(__il.begin(), __il.end());
1359227825Stheraven}
1360227825Stheraven
1361227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1362227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1363227825Stheraven        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1364227825Stheraven        const key_equal& __eql)
1365227825Stheraven    : __table_(__hf, __eql)
1366227825Stheraven{
1367261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1368261272Sdim    __get_db()->__insert_c(this);
1369261272Sdim#endif
1370227825Stheraven    __table_.rehash(__n);
1371227825Stheraven    insert(__il.begin(), __il.end());
1372227825Stheraven}
1373227825Stheraven
1374227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1375227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1376227825Stheraven        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1377227825Stheraven        const key_equal& __eql, const allocator_type& __a)
1378227825Stheraven    : __table_(__hf, __eql, __a)
1379227825Stheraven{
1380261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1381261272Sdim    __get_db()->__insert_c(this);
1382261272Sdim#endif
1383227825Stheraven    __table_.rehash(__n);
1384227825Stheraven    insert(__il.begin(), __il.end());
1385227825Stheraven}
1386227825Stheraven
1387227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1388227825Stheraven
1389227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1390227825Stheraven
1391227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1392227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1393227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
1394227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
1395227825Stheraven    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
1396227825Stheraven{
1397227825Stheraven    __table_ = _VSTD::move(__u.__table_);
1398227825Stheraven    return *this;
1399227825Stheraven}
1400227825Stheraven
1401227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1402227825Stheraven
1403227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1404227825Stheraven
1405227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1406227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1407227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
1408227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
1409227825Stheraven        initializer_list<value_type> __il)
1410227825Stheraven{
1411227825Stheraven    __table_.__assign_unique(__il.begin(), __il.end());
1412227825Stheraven    return *this;
1413227825Stheraven}
1414227825Stheraven
1415227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1416227825Stheraven
1417227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1418227825Stheraven
1419227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1420227825Stheraventypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1421241900Sdimunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
1422227825Stheraven{
1423227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
1424232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1425241900Sdim    __node_traits::construct(__na, _VSTD::addressof(__h->__value_));
1426227825Stheraven    __h.get_deleter().__first_constructed = true;
1427227825Stheraven    __h.get_deleter().__second_constructed = true;
1428227825Stheraven    return __h;
1429227825Stheraven}
1430227825Stheraven
1431227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1432241900Sdimtemplate <class _A0>
1433253146Stheraventypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1434227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
1435227825Stheraven{
1436227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
1437232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1438227825Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
1439227825Stheraven                             _VSTD::forward<_A0>(__a0));
1440227825Stheraven    __h.get_deleter().__first_constructed = true;
1441227825Stheraven    __h.get_deleter().__second_constructed = true;
1442227825Stheraven    return __h;
1443227825Stheraven}
1444227825Stheraven
1445241900Sdimtemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1446253146Stheraventypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1447253146Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_type&& __k)
1448241900Sdim{
1449241900Sdim    __node_allocator& __na = __table_.__node_alloc();
1450241900Sdim    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1451253146Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
1452241900Sdim    __h.get_deleter().__first_constructed = true;
1453253146Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
1454241900Sdim    __h.get_deleter().__second_constructed = true;
1455261272Sdim    return __h;
1456241900Sdim}
1457241900Sdim
1458227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1459227825Stheraven
1460227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1461241900Sdimtemplate <class _A0, class _A1, class ..._Args>
1462241900Sdimtypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1463241900Sdimunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0,
1464241900Sdim                                                                 _A1&& __a1,
1465241900Sdim                                                                 _Args&&... __args)
1466241900Sdim{
1467241900Sdim    __node_allocator& __na = __table_.__node_alloc();
1468241900Sdim    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1469241900Sdim    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
1470241900Sdim                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
1471241900Sdim                             _VSTD::forward<_Args>(__args)...);
1472241900Sdim    __h.get_deleter().__first_constructed = true;
1473241900Sdim    __h.get_deleter().__second_constructed = true;
1474241900Sdim    return __h;
1475241900Sdim}
1476241900Sdim
1477241900Sdimtemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1478241900Sdimtemplate <class... _Args>
1479227825Stheravenpair<typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator, bool>
1480241900Sdimunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
1481227825Stheraven{
1482241900Sdim    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
1483227825Stheraven    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
1484227825Stheraven    if (__r.second)
1485227825Stheraven        __h.release();
1486227825Stheraven    return __r;
1487227825Stheraven}
1488227825Stheraven
1489227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1490253146Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1491227825Stheraven
1492227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1493227825Stheraventypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1494253146Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
1495227825Stheraven{
1496227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
1497232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1498253146Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k);
1499227825Stheraven    __h.get_deleter().__first_constructed = true;
1500253146Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
1501227825Stheraven    __h.get_deleter().__second_constructed = true;
1502300770Sdim    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
1503227825Stheraven}
1504227825Stheraven
1505227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1506227825Stheraventemplate <class _InputIterator>
1507227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1508227825Stheravenvoid
1509227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
1510227825Stheraven                                                       _InputIterator __last)
1511227825Stheraven{
1512227825Stheraven    for (; __first != __last; ++__first)
1513227825Stheraven        __table_.__insert_unique(*__first);
1514227825Stheraven}
1515227825Stheraven
1516227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1517227825Stheraven_Tp&
1518227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
1519227825Stheraven{
1520227825Stheraven    iterator __i = find(__k);
1521227825Stheraven    if (__i != end())
1522227825Stheraven        return __i->second;
1523253146Stheraven    __node_holder __h = __construct_node_with_key(__k);
1524227825Stheraven    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
1525227825Stheraven    __h.release();
1526227825Stheraven    return __r.first->second;
1527227825Stheraven}
1528227825Stheraven
1529227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1530227825Stheraven
1531227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1532227825Stheraven_Tp&
1533227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
1534227825Stheraven{
1535227825Stheraven    iterator __i = find(__k);
1536227825Stheraven    if (__i != end())
1537227825Stheraven        return __i->second;
1538253146Stheraven    __node_holder __h = __construct_node_with_key(_VSTD::move(__k));
1539227825Stheraven    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
1540227825Stheraven    __h.release();
1541227825Stheraven    return __r.first->second;
1542227825Stheraven}
1543227825Stheraven
1544227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1545227825Stheraven
1546227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1547227825Stheraven_Tp&
1548227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k)
1549227825Stheraven{
1550227825Stheraven    iterator __i = find(__k);
1551227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS
1552227825Stheraven    if (__i == end())
1553227825Stheraven        throw out_of_range("unordered_map::at: key not found");
1554227825Stheraven#endif  // _LIBCPP_NO_EXCEPTIONS
1555227825Stheraven    return __i->second;
1556227825Stheraven}
1557227825Stheraven
1558227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1559227825Stheravenconst _Tp&
1560227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const
1561227825Stheraven{
1562227825Stheraven    const_iterator __i = find(__k);
1563227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS
1564227825Stheraven    if (__i == end())
1565227825Stheraven        throw out_of_range("unordered_map::at: key not found");
1566227825Stheraven#endif  // _LIBCPP_NO_EXCEPTIONS
1567227825Stheraven    return __i->second;
1568227825Stheraven}
1569227825Stheraven
1570227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1571227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1572227825Stheravenvoid
1573227825Stheravenswap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1574227825Stheraven     unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1575227825Stheraven    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
1576227825Stheraven{
1577227825Stheraven    __x.swap(__y);
1578227825Stheraven}
1579227825Stheraven
1580227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1581227825Stheravenbool
1582227825Stheravenoperator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1583227825Stheraven           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1584227825Stheraven{
1585227825Stheraven    if (__x.size() != __y.size())
1586227825Stheraven        return false;
1587227825Stheraven    typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
1588227825Stheraven                                                                 const_iterator;
1589227825Stheraven    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
1590227825Stheraven            __i != __ex; ++__i)
1591227825Stheraven    {
1592227825Stheraven        const_iterator __j = __y.find(__i->first);
1593227825Stheraven        if (__j == __ey || !(*__i == *__j))
1594227825Stheraven            return false;
1595227825Stheraven    }
1596227825Stheraven    return true;
1597227825Stheraven}
1598227825Stheraven
1599227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1600227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1601227825Stheravenbool
1602227825Stheravenoperator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1603227825Stheraven           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1604227825Stheraven{
1605227825Stheraven    return !(__x == __y);
1606227825Stheraven}
1607227825Stheraven
1608227825Stheraventemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
1609227825Stheraven          class _Alloc = allocator<pair<const _Key, _Tp> > >
1610261272Sdimclass _LIBCPP_TYPE_VIS_ONLY unordered_multimap
1611227825Stheraven{
1612227825Stheravenpublic:
1613227825Stheraven    // types
1614227825Stheraven    typedef _Key                                           key_type;
1615227825Stheraven    typedef _Tp                                            mapped_type;
1616227825Stheraven    typedef _Hash                                          hasher;
1617227825Stheraven    typedef _Pred                                          key_equal;
1618227825Stheraven    typedef _Alloc                                         allocator_type;
1619227825Stheraven    typedef pair<const key_type, mapped_type>              value_type;
1620253146Stheraven    typedef pair<key_type, mapped_type>                    __nc_value_type;
1621227825Stheraven    typedef value_type&                                    reference;
1622227825Stheraven    typedef const value_type&                              const_reference;
1623261272Sdim    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1624261272Sdim                  "Invalid allocator::value_type");
1625227825Stheraven
1626227825Stheravenprivate:
1627261272Sdim    typedef __hash_value_type<key_type, mapped_type>                 __value_type;
1628253146Stheraven    typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
1629253146Stheraven    typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
1630288943Sdim    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
1631288943Sdim                                                 __value_type>::type __allocator_type;
1632227825Stheraven
1633227825Stheraven    typedef __hash_table<__value_type, __hasher,
1634227825Stheraven                         __key_equal,  __allocator_type>   __table;
1635227825Stheraven
1636227825Stheraven    __table __table_;
1637227825Stheraven
1638227825Stheraven    typedef typename __table::__node_traits                __node_traits;
1639227825Stheraven    typedef typename __table::__node_allocator             __node_allocator;
1640227825Stheraven    typedef typename __table::__node                       __node;
1641232924Stheraven    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
1642232924Stheraven    typedef unique_ptr<__node, _Dp>                         __node_holder;
1643227825Stheraven    typedef allocator_traits<allocator_type>               __alloc_traits;
1644227825Stheravenpublic:
1645227825Stheraven    typedef typename __alloc_traits::pointer         pointer;
1646227825Stheraven    typedef typename __alloc_traits::const_pointer   const_pointer;
1647227825Stheraven    typedef typename __alloc_traits::size_type       size_type;
1648227825Stheraven    typedef typename __alloc_traits::difference_type difference_type;
1649227825Stheraven
1650227825Stheraven    typedef __hash_map_iterator<typename __table::iterator>       iterator;
1651227825Stheraven    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
1652227825Stheraven    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
1653227825Stheraven    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
1654227825Stheraven
1655227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1656227825Stheraven    unordered_multimap()
1657227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
1658261272Sdim        {
1659261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1660261272Sdim            __get_db()->__insert_c(this);
1661261272Sdim#endif
1662261272Sdim        }
1663227825Stheraven    explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(),
1664227825Stheraven                                const key_equal& __eql = key_equal());
1665227825Stheraven    unordered_multimap(size_type __n, const hasher& __hf,
1666227825Stheraven                                const key_equal& __eql,
1667227825Stheraven                                const allocator_type& __a);
1668227825Stheraven    template <class _InputIterator>
1669227825Stheraven        unordered_multimap(_InputIterator __first, _InputIterator __last);
1670227825Stheraven    template <class _InputIterator>
1671227825Stheraven        unordered_multimap(_InputIterator __first, _InputIterator __last,
1672227825Stheraven                      size_type __n, const hasher& __hf = hasher(),
1673227825Stheraven                      const key_equal& __eql = key_equal());
1674227825Stheraven    template <class _InputIterator>
1675227825Stheraven        unordered_multimap(_InputIterator __first, _InputIterator __last,
1676227825Stheraven                      size_type __n, const hasher& __hf,
1677227825Stheraven                      const key_equal& __eql,
1678227825Stheraven                      const allocator_type& __a);
1679227825Stheraven    explicit unordered_multimap(const allocator_type& __a);
1680227825Stheraven    unordered_multimap(const unordered_multimap& __u);
1681227825Stheraven    unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
1682227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1683227825Stheraven    unordered_multimap(unordered_multimap&& __u)
1684227825Stheraven        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
1685227825Stheraven    unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
1686227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1687227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1688227825Stheraven    unordered_multimap(initializer_list<value_type> __il);
1689227825Stheraven    unordered_multimap(initializer_list<value_type> __il, size_type __n,
1690227825Stheraven                       const hasher& __hf = hasher(),
1691227825Stheraven                       const key_equal& __eql = key_equal());
1692227825Stheraven    unordered_multimap(initializer_list<value_type> __il, size_type __n,
1693227825Stheraven                       const hasher& __hf, const key_equal& __eql,
1694227825Stheraven                       const allocator_type& __a);
1695227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1696261272Sdim#if _LIBCPP_STD_VER > 11
1697261272Sdim    _LIBCPP_INLINE_VISIBILITY
1698261272Sdim    unordered_multimap(size_type __n, const allocator_type& __a)
1699261272Sdim      : unordered_multimap(__n, hasher(), key_equal(), __a) {}
1700261272Sdim    _LIBCPP_INLINE_VISIBILITY
1701261272Sdim    unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
1702261272Sdim      : unordered_multimap(__n, __hf, key_equal(), __a) {}
1703261272Sdim    template <class _InputIterator>
1704261272Sdim    _LIBCPP_INLINE_VISIBILITY
1705261272Sdim      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
1706261272Sdim      : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
1707261272Sdim    template <class _InputIterator>
1708261272Sdim    _LIBCPP_INLINE_VISIBILITY
1709261272Sdim      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, 
1710261272Sdim        const allocator_type& __a)
1711261272Sdim      : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
1712261272Sdim    _LIBCPP_INLINE_VISIBILITY
1713261272Sdim    unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1714261272Sdim      : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
1715261272Sdim    _LIBCPP_INLINE_VISIBILITY
1716261272Sdim    unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, 
1717261272Sdim      const allocator_type& __a)
1718261272Sdim      : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
1719261272Sdim#endif
1720227825Stheraven    // ~unordered_multimap() = default;
1721227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1722227825Stheraven    unordered_multimap& operator=(const unordered_multimap& __u)
1723227825Stheraven    {
1724253146Stheraven#if __cplusplus >= 201103L
1725227825Stheraven        __table_ = __u.__table_;
1726253146Stheraven#else
1727276792Sdim        if (this != &__u) {
1728276792Sdim            __table_.clear();
1729276792Sdim            __table_.hash_function() = __u.__table_.hash_function();
1730276792Sdim            __table_.key_eq() = __u.__table_.key_eq();
1731276792Sdim            __table_.max_load_factor() = __u.__table_.max_load_factor();
1732276792Sdim            __table_.__copy_assign_alloc(__u.__table_);
1733276792Sdim            insert(__u.begin(), __u.end());
1734276792Sdim        }
1735253146Stheraven#endif
1736227825Stheraven        return *this;
1737227825Stheraven    }
1738227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1739227825Stheraven    unordered_multimap& operator=(unordered_multimap&& __u)
1740227825Stheraven        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
1741227825Stheraven#endif
1742227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1743227825Stheraven    unordered_multimap& operator=(initializer_list<value_type> __il);
1744227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1745227825Stheraven
1746227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1747227825Stheraven    allocator_type get_allocator() const _NOEXCEPT
1748227825Stheraven        {return allocator_type(__table_.__node_alloc());}
1749227825Stheraven
1750227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1751227825Stheraven    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
1752227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1753227825Stheraven    size_type size() const _NOEXCEPT  {return __table_.size();}
1754227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1755227825Stheraven    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
1756227825Stheraven
1757227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1758227825Stheraven    iterator       begin() _NOEXCEPT        {return __table_.begin();}
1759227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1760227825Stheraven    iterator       end() _NOEXCEPT          {return __table_.end();}
1761227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1762227825Stheraven    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
1763227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1764227825Stheraven    const_iterator end()    const _NOEXCEPT {return __table_.end();}
1765227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1766227825Stheraven    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
1767227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1768227825Stheraven    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
1769227825Stheraven
1770227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1771227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1772227825Stheraven
1773241900Sdim    template <class... _Args>
1774241900Sdim        iterator emplace(_Args&&... __args);
1775227825Stheraven
1776241900Sdim    template <class... _Args>
1777241900Sdim        iterator emplace_hint(const_iterator __p, _Args&&... __args);
1778227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1779227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1780227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1781227825Stheraven    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
1782227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1783232924Stheraven    template <class _Pp,
1784232924Stheraven              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1785227825Stheraven        _LIBCPP_INLINE_VISIBILITY
1786232924Stheraven        iterator insert(_Pp&& __x)
1787232924Stheraven            {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
1788227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1789227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1790227825Stheraven    iterator insert(const_iterator __p, const value_type& __x)
1791227825Stheraven        {return __table_.__insert_multi(__p.__i_, __x);}
1792227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1793232924Stheraven    template <class _Pp,
1794232924Stheraven              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1795227825Stheraven        _LIBCPP_INLINE_VISIBILITY
1796232924Stheraven        iterator insert(const_iterator __p, _Pp&& __x)
1797232924Stheraven            {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
1798227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1799227825Stheraven    template <class _InputIterator>
1800227825Stheraven        void insert(_InputIterator __first, _InputIterator __last);
1801227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1802227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1803227825Stheraven    void insert(initializer_list<value_type> __il)
1804227825Stheraven        {insert(__il.begin(), __il.end());}
1805227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1806227825Stheraven
1807227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1808227825Stheraven    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
1809227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1810288943Sdim    iterator erase(iterator __p)       {return __table_.erase(__p.__i_);}
1811288943Sdim    _LIBCPP_INLINE_VISIBILITY
1812227825Stheraven    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
1813227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1814227825Stheraven    iterator erase(const_iterator __first, const_iterator __last)
1815227825Stheraven        {return __table_.erase(__first.__i_, __last.__i_);}
1816227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1817227825Stheraven    void clear() _NOEXCEPT {__table_.clear();}
1818227825Stheraven
1819227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1820227825Stheraven    void swap(unordered_multimap& __u)
1821227825Stheraven        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
1822227825Stheraven        {__table_.swap(__u.__table_);}
1823227825Stheraven
1824227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1825227825Stheraven    hasher hash_function() const
1826227825Stheraven        {return __table_.hash_function().hash_function();}
1827227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1828227825Stheraven    key_equal key_eq() const
1829227825Stheraven        {return __table_.key_eq().key_eq();}
1830227825Stheraven
1831227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1832227825Stheraven    iterator       find(const key_type& __k)       {return __table_.find(__k);}
1833227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1834227825Stheraven    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1835227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1836227825Stheraven    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
1837227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1838227825Stheraven    pair<iterator, iterator>             equal_range(const key_type& __k)
1839227825Stheraven        {return __table_.__equal_range_multi(__k);}
1840227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1841227825Stheraven    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
1842227825Stheraven        {return __table_.__equal_range_multi(__k);}
1843227825Stheraven
1844227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1845227825Stheraven    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
1846227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1847227825Stheraven    size_type max_bucket_count() const _NOEXCEPT
1848227825Stheraven        {return __table_.max_bucket_count();}
1849227825Stheraven
1850227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1851227825Stheraven    size_type bucket_size(size_type __n) const
1852227825Stheraven        {return __table_.bucket_size(__n);}
1853227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1854227825Stheraven    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
1855227825Stheraven
1856227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1857227825Stheraven    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
1858227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1859227825Stheraven    local_iterator       end(size_type __n)          {return __table_.end(__n);}
1860227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1861227825Stheraven    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
1862227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1863227825Stheraven    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
1864227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1865227825Stheraven    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
1866227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1867227825Stheraven    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
1868227825Stheraven
1869227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1870227825Stheraven    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
1871227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1872227825Stheraven    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
1873227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1874227825Stheraven    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
1875227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1876227825Stheraven    void rehash(size_type __n) {__table_.rehash(__n);}
1877227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1878227825Stheraven    void reserve(size_type __n) {__table_.reserve(__n);}
1879227825Stheraven
1880261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1881261272Sdim
1882261272Sdim    bool __dereferenceable(const const_iterator* __i) const
1883261272Sdim        {return __table_.__dereferenceable(&__i->__i_);}
1884261272Sdim    bool __decrementable(const const_iterator* __i) const
1885261272Sdim        {return __table_.__decrementable(&__i->__i_);}
1886261272Sdim    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1887261272Sdim        {return __table_.__addable(&__i->__i_, __n);}
1888261272Sdim    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1889261272Sdim        {return __table_.__addable(&__i->__i_, __n);}
1890261272Sdim
1891261272Sdim#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1892261272Sdim
1893227825Stheravenprivate:
1894241900Sdim#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1895241900Sdim    __node_holder __construct_node();
1896241900Sdim    template <class _A0>
1897253146Stheraven        __node_holder
1898241900Sdim         __construct_node(_A0&& __a0);
1899241900Sdim#ifndef _LIBCPP_HAS_NO_VARIADICS
1900241900Sdim    template <class _A0, class _A1, class ..._Args>
1901241900Sdim        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
1902241900Sdim#endif  // _LIBCPP_HAS_NO_VARIADICS
1903241900Sdim#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1904227825Stheraven};
1905227825Stheraven
1906227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1907227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1908227825Stheraven        size_type __n, const hasher& __hf, const key_equal& __eql)
1909227825Stheraven    : __table_(__hf, __eql)
1910227825Stheraven{
1911261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1912261272Sdim    __get_db()->__insert_c(this);
1913261272Sdim#endif
1914227825Stheraven    __table_.rehash(__n);
1915227825Stheraven}
1916227825Stheraven
1917227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1918227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1919227825Stheraven        size_type __n, const hasher& __hf, const key_equal& __eql,
1920227825Stheraven        const allocator_type& __a)
1921227825Stheraven    : __table_(__hf, __eql, __a)
1922227825Stheraven{
1923261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1924261272Sdim    __get_db()->__insert_c(this);
1925261272Sdim#endif
1926227825Stheraven    __table_.rehash(__n);
1927227825Stheraven}
1928227825Stheraven
1929227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1930227825Stheraventemplate <class _InputIterator>
1931227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1932227825Stheraven        _InputIterator __first, _InputIterator __last)
1933227825Stheraven{
1934261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1935261272Sdim    __get_db()->__insert_c(this);
1936261272Sdim#endif
1937227825Stheraven    insert(__first, __last);
1938227825Stheraven}
1939227825Stheraven
1940227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1941227825Stheraventemplate <class _InputIterator>
1942227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1943227825Stheraven        _InputIterator __first, _InputIterator __last, size_type __n,
1944227825Stheraven        const hasher& __hf, const key_equal& __eql)
1945227825Stheraven    : __table_(__hf, __eql)
1946227825Stheraven{
1947261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1948261272Sdim    __get_db()->__insert_c(this);
1949261272Sdim#endif
1950227825Stheraven    __table_.rehash(__n);
1951227825Stheraven    insert(__first, __last);
1952227825Stheraven}
1953227825Stheraven
1954227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1955227825Stheraventemplate <class _InputIterator>
1956227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1957227825Stheraven        _InputIterator __first, _InputIterator __last, size_type __n,
1958227825Stheraven        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1959227825Stheraven    : __table_(__hf, __eql, __a)
1960227825Stheraven{
1961261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1962261272Sdim    __get_db()->__insert_c(this);
1963261272Sdim#endif
1964227825Stheraven    __table_.rehash(__n);
1965227825Stheraven    insert(__first, __last);
1966227825Stheraven}
1967227825Stheraven
1968227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1969227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1970227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1971227825Stheraven        const allocator_type& __a)
1972227825Stheraven    : __table_(__a)
1973227825Stheraven{
1974261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1975261272Sdim    __get_db()->__insert_c(this);
1976261272Sdim#endif
1977227825Stheraven}
1978227825Stheraven
1979227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1980227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1981227825Stheraven        const unordered_multimap& __u)
1982227825Stheraven    : __table_(__u.__table_)
1983227825Stheraven{
1984261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1985261272Sdim    __get_db()->__insert_c(this);
1986261272Sdim#endif
1987227825Stheraven    __table_.rehash(__u.bucket_count());
1988227825Stheraven    insert(__u.begin(), __u.end());
1989227825Stheraven}
1990227825Stheraven
1991227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1992227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1993227825Stheraven        const unordered_multimap& __u, const allocator_type& __a)
1994227825Stheraven    : __table_(__u.__table_, __a)
1995227825Stheraven{
1996261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1997261272Sdim    __get_db()->__insert_c(this);
1998261272Sdim#endif
1999227825Stheraven    __table_.rehash(__u.bucket_count());
2000227825Stheraven    insert(__u.begin(), __u.end());
2001227825Stheraven}
2002227825Stheraven
2003227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2004227825Stheraven
2005227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2006227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2007227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2008227825Stheraven        unordered_multimap&& __u)
2009227825Stheraven    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
2010227825Stheraven    : __table_(_VSTD::move(__u.__table_))
2011227825Stheraven{
2012261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
2013261272Sdim    __get_db()->__insert_c(this);
2014261272Sdim    __get_db()->swap(this, &__u);
2015261272Sdim#endif
2016227825Stheraven}
2017227825Stheraven
2018227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2019227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2020227825Stheraven        unordered_multimap&& __u, const allocator_type& __a)
2021227825Stheraven    : __table_(_VSTD::move(__u.__table_), __a)
2022227825Stheraven{
2023261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
2024261272Sdim    __get_db()->__insert_c(this);
2025261272Sdim#endif
2026227825Stheraven    if (__a != __u.get_allocator())
2027227825Stheraven    {
2028227825Stheraven        iterator __i = __u.begin();
2029227825Stheraven        while (__u.size() != 0)
2030261272Sdim        {
2031227825Stheraven            __table_.__insert_multi(
2032227825Stheraven                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
2033227825Stheraven                                   );
2034261272Sdim        }
2035227825Stheraven    }
2036261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
2037261272Sdim    else
2038261272Sdim        __get_db()->swap(this, &__u);
2039261272Sdim#endif
2040227825Stheraven}
2041227825Stheraven
2042227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2043227825Stheraven
2044227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2045227825Stheraven
2046227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2047227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2048227825Stheraven        initializer_list<value_type> __il)
2049227825Stheraven{
2050261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
2051261272Sdim    __get_db()->__insert_c(this);
2052261272Sdim#endif
2053227825Stheraven    insert(__il.begin(), __il.end());
2054227825Stheraven}
2055227825Stheraven
2056227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2057227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2058227825Stheraven        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
2059227825Stheraven        const key_equal& __eql)
2060227825Stheraven    : __table_(__hf, __eql)
2061227825Stheraven{
2062261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
2063261272Sdim    __get_db()->__insert_c(this);
2064261272Sdim#endif
2065227825Stheraven    __table_.rehash(__n);
2066227825Stheraven    insert(__il.begin(), __il.end());
2067227825Stheraven}
2068227825Stheraven
2069227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2070227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2071227825Stheraven        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
2072227825Stheraven        const key_equal& __eql, const allocator_type& __a)
2073227825Stheraven    : __table_(__hf, __eql, __a)
2074227825Stheraven{
2075261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
2076261272Sdim    __get_db()->__insert_c(this);
2077261272Sdim#endif
2078227825Stheraven    __table_.rehash(__n);
2079227825Stheraven    insert(__il.begin(), __il.end());
2080227825Stheraven}
2081227825Stheraven
2082227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2083227825Stheraven
2084227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2085227825Stheraven
2086227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2087227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2088227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
2089227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
2090227825Stheraven    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
2091227825Stheraven{
2092227825Stheraven    __table_ = _VSTD::move(__u.__table_);
2093227825Stheraven    return *this;
2094227825Stheraven}
2095227825Stheraven
2096227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2097227825Stheraven
2098227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2099227825Stheraven
2100227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2101227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2102227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
2103227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
2104227825Stheraven        initializer_list<value_type> __il)
2105227825Stheraven{
2106227825Stheraven    __table_.__assign_multi(__il.begin(), __il.end());
2107227825Stheraven    return *this;
2108227825Stheraven}
2109227825Stheraven
2110227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2111227825Stheraven
2112227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2113227825Stheraven
2114227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2115227825Stheraventypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
2116241900Sdimunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
2117227825Stheraven{
2118227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
2119232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2120241900Sdim    __node_traits::construct(__na, _VSTD::addressof(__h->__value_));
2121227825Stheraven    __h.get_deleter().__first_constructed = true;
2122227825Stheraven    __h.get_deleter().__second_constructed = true;
2123227825Stheraven    return __h;
2124227825Stheraven}
2125227825Stheraven
2126227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2127241900Sdimtemplate <class _A0>
2128253146Stheraventypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
2129227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
2130227825Stheraven{
2131227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
2132232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2133227825Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
2134227825Stheraven                             _VSTD::forward<_A0>(__a0));
2135227825Stheraven    __h.get_deleter().__first_constructed = true;
2136227825Stheraven    __h.get_deleter().__second_constructed = true;
2137227825Stheraven    return __h;
2138227825Stheraven}
2139227825Stheraven
2140227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
2141227825Stheraven
2142227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2143241900Sdimtemplate <class _A0, class _A1, class ..._Args>
2144241900Sdimtypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
2145241900Sdimunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(
2146241900Sdim        _A0&& __a0, _A1&& __a1, _Args&&... __args)
2147241900Sdim{
2148241900Sdim    __node_allocator& __na = __table_.__node_alloc();
2149241900Sdim    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2150241900Sdim    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
2151241900Sdim                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
2152241900Sdim                             _VSTD::forward<_Args>(__args)...);
2153241900Sdim    __h.get_deleter().__first_constructed = true;
2154241900Sdim    __h.get_deleter().__second_constructed = true;
2155241900Sdim    return __h;
2156241900Sdim}
2157241900Sdim
2158241900Sdimtemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2159241900Sdimtemplate <class... _Args>
2160227825Stheraventypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator
2161241900Sdimunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
2162227825Stheraven{
2163241900Sdim    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
2164227825Stheraven    iterator __r = __table_.__node_insert_multi(__h.get());
2165227825Stheraven    __h.release();
2166227825Stheraven    return __r;
2167227825Stheraven}
2168227825Stheraven
2169227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2170241900Sdimtemplate <class... _Args>
2171227825Stheraventypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator
2172227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace_hint(
2173241900Sdim        const_iterator __p, _Args&&... __args)
2174227825Stheraven{
2175241900Sdim    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
2176227825Stheraven    iterator __r = __table_.__node_insert_multi(__p.__i_, __h.get());
2177227825Stheraven    __h.release();
2178227825Stheraven    return __r;
2179227825Stheraven}
2180227825Stheraven
2181227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2182227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2183227825Stheraven
2184227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2185227825Stheraventemplate <class _InputIterator>
2186227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2187227825Stheravenvoid
2188227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
2189227825Stheraven                                                            _InputIterator __last)
2190227825Stheraven{
2191227825Stheraven    for (; __first != __last; ++__first)
2192227825Stheraven        __table_.__insert_multi(*__first);
2193227825Stheraven}
2194227825Stheraven
2195227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2196227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2197227825Stheravenvoid
2198227825Stheravenswap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2199227825Stheraven     unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2200227825Stheraven    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
2201227825Stheraven{
2202227825Stheraven    __x.swap(__y);
2203227825Stheraven}
2204227825Stheraven
2205227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2206227825Stheravenbool
2207227825Stheravenoperator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2208227825Stheraven           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2209227825Stheraven{
2210227825Stheraven    if (__x.size() != __y.size())
2211227825Stheraven        return false;
2212227825Stheraven    typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
2213227825Stheraven                                                                 const_iterator;
2214227825Stheraven    typedef pair<const_iterator, const_iterator> _EqRng;
2215227825Stheraven    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
2216227825Stheraven    {
2217227825Stheraven        _EqRng __xeq = __x.equal_range(__i->first);
2218227825Stheraven        _EqRng __yeq = __y.equal_range(__i->first);
2219227825Stheraven        if (_VSTD::distance(__xeq.first, __xeq.second) !=
2220227825Stheraven            _VSTD::distance(__yeq.first, __yeq.second) ||
2221227825Stheraven                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
2222227825Stheraven            return false;
2223227825Stheraven        __i = __xeq.second;
2224227825Stheraven    }
2225227825Stheraven    return true;
2226227825Stheraven}
2227227825Stheraven
2228227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2229227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2230227825Stheravenbool
2231227825Stheravenoperator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2232227825Stheraven           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2233227825Stheraven{
2234227825Stheraven    return !(__x == __y);
2235227825Stheraven}
2236227825Stheraven
2237227825Stheraven_LIBCPP_END_NAMESPACE_STD
2238227825Stheraven
2239227825Stheraven#endif  // _LIBCPP_UNORDERED_MAP
2240