unordered_map revision 261272
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
125227825Stheraven    iterator erase(const_iterator position);
126227825Stheraven    size_type erase(const key_type& k);
127227825Stheraven    iterator erase(const_iterator first, const_iterator last);
128227825Stheraven    void clear() noexcept;
129227825Stheraven
130227825Stheraven    void swap(unordered_map&)
131227825Stheraven        noexcept(
132227825Stheraven            (!allocator_type::propagate_on_container_swap::value ||
133227825Stheraven             __is_nothrow_swappable<allocator_type>::value) &&
134227825Stheraven            __is_nothrow_swappable<hasher>::value &&
135227825Stheraven            __is_nothrow_swappable<key_equal>::value);
136227825Stheraven
137227825Stheraven    hasher hash_function() const;
138227825Stheraven    key_equal key_eq() const;
139227825Stheraven
140227825Stheraven    iterator       find(const key_type& k);
141227825Stheraven    const_iterator find(const key_type& k) const;
142227825Stheraven    size_type count(const key_type& k) const;
143227825Stheraven    pair<iterator, iterator>             equal_range(const key_type& k);
144227825Stheraven    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
145227825Stheraven
146227825Stheraven    mapped_type& operator[](const key_type& k);
147227825Stheraven    mapped_type& operator[](key_type&& k);
148227825Stheraven
149227825Stheraven    mapped_type&       at(const key_type& k);
150227825Stheraven    const mapped_type& at(const key_type& k) const;
151227825Stheraven
152227825Stheraven    size_type bucket_count() const noexcept;
153227825Stheraven    size_type max_bucket_count() const noexcept;
154227825Stheraven
155227825Stheraven    size_type bucket_size(size_type n) const;
156227825Stheraven    size_type bucket(const key_type& k) const;
157227825Stheraven
158227825Stheraven    local_iterator       begin(size_type n);
159227825Stheraven    local_iterator       end(size_type n);
160227825Stheraven    const_local_iterator begin(size_type n) const;
161227825Stheraven    const_local_iterator end(size_type n) const;
162227825Stheraven    const_local_iterator cbegin(size_type n) const;
163227825Stheraven    const_local_iterator cend(size_type n) const;
164227825Stheraven
165227825Stheraven    float load_factor() const noexcept;
166227825Stheraven    float max_load_factor() const noexcept;
167227825Stheraven    void max_load_factor(float z);
168227825Stheraven    void rehash(size_type n);
169227825Stheraven    void reserve(size_type n);
170227825Stheraven};
171227825Stheraven
172227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
173227825Stheraven    void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
174227825Stheraven              unordered_map<Key, T, Hash, Pred, Alloc>& y)
175227825Stheraven              noexcept(noexcept(x.swap(y)));
176227825Stheraven
177227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
178227825Stheraven    bool
179227825Stheraven    operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
180227825Stheraven               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
181227825Stheraven
182227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
183227825Stheraven    bool
184227825Stheraven    operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
185227825Stheraven               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
186227825Stheraven
187227825Stheraventemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
188227825Stheraven          class Alloc = allocator<pair<const Key, T>>>
189227825Stheravenclass unordered_multimap
190227825Stheraven{
191227825Stheravenpublic:
192227825Stheraven    // types
193227825Stheraven    typedef Key                                                        key_type;
194227825Stheraven    typedef T                                                          mapped_type;
195227825Stheraven    typedef Hash                                                       hasher;
196227825Stheraven    typedef Pred                                                       key_equal;
197227825Stheraven    typedef Alloc                                                      allocator_type;
198227825Stheraven    typedef pair<const key_type, mapped_type>                          value_type;
199227825Stheraven    typedef value_type&                                                reference;
200227825Stheraven    typedef const value_type&                                          const_reference;
201227825Stheraven    typedef typename allocator_traits<allocator_type>::pointer         pointer;
202227825Stheraven    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
203227825Stheraven    typedef typename allocator_traits<allocator_type>::size_type       size_type;
204227825Stheraven    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
205227825Stheraven
206227825Stheraven    typedef /unspecified/ iterator;
207227825Stheraven    typedef /unspecified/ const_iterator;
208227825Stheraven    typedef /unspecified/ local_iterator;
209227825Stheraven    typedef /unspecified/ const_local_iterator;
210227825Stheraven
211227825Stheraven    unordered_multimap()
212227825Stheraven        noexcept(
213227825Stheraven            is_nothrow_default_constructible<hasher>::value &&
214227825Stheraven            is_nothrow_default_constructible<key_equal>::value &&
215227825Stheraven            is_nothrow_default_constructible<allocator_type>::value);
216227825Stheraven    explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
217227825Stheraven                           const key_equal& eql = key_equal(),
218227825Stheraven                           const allocator_type& a = allocator_type());
219227825Stheraven    template <class InputIterator>
220227825Stheraven        unordered_multimap(InputIterator f, InputIterator l,
221227825Stheraven                      size_type n = 0, const hasher& hf = hasher(),
222227825Stheraven                      const key_equal& eql = key_equal(),
223227825Stheraven                      const allocator_type& a = allocator_type());
224227825Stheraven    explicit unordered_multimap(const allocator_type&);
225227825Stheraven    unordered_multimap(const unordered_multimap&);
226227825Stheraven    unordered_multimap(const unordered_multimap&, const Allocator&);
227227825Stheraven    unordered_multimap(unordered_multimap&&)
228227825Stheraven        noexcept(
229227825Stheraven            is_nothrow_move_constructible<hasher>::value &&
230227825Stheraven            is_nothrow_move_constructible<key_equal>::value &&
231227825Stheraven            is_nothrow_move_constructible<allocator_type>::value);
232227825Stheraven    unordered_multimap(unordered_multimap&&, const Allocator&);
233227825Stheraven    unordered_multimap(initializer_list<value_type>, size_type n = 0,
234227825Stheraven                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
235227825Stheraven                  const allocator_type& a = allocator_type());
236261272Sdim    unordered_multimap(size_type n, const allocator_type& a)
237261272Sdim      : unordered_multimap(n, hasher(), key_equal(), a) {}  // C++14
238261272Sdim    unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
239261272Sdim      : unordered_multimap(n, hf, key_equal(), a) {}  // C++14
240261272Sdim    template <class InputIterator>
241261272Sdim      unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
242261272Sdim      : unordered_multimap(f, l, n, hasher(), key_equal(), a) {}  // C++14
243261272Sdim    template <class InputIterator>
244261272Sdim      unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, 
245261272Sdim        const allocator_type& a)
246261272Sdim      : unordered_multimap(f, l, n, hf, key_equal(), a) {}  // C++14
247261272Sdim    unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
248261272Sdim      : unordered_multimap(il, n, hasher(), key_equal(), a) {}  // C++14
249261272Sdim    unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf, 
250261272Sdim      const allocator_type& a)
251261272Sdim      : unordered_multimap(il, n, hf, key_equal(), a) {}  // C++14
252227825Stheraven    ~unordered_multimap();
253227825Stheraven    unordered_multimap& operator=(const unordered_multimap&);
254227825Stheraven    unordered_multimap& operator=(unordered_multimap&&)
255227825Stheraven        noexcept(
256227825Stheraven            allocator_type::propagate_on_container_move_assignment::value &&
257227825Stheraven            is_nothrow_move_assignable<allocator_type>::value &&
258227825Stheraven            is_nothrow_move_assignable<hasher>::value &&
259227825Stheraven            is_nothrow_move_assignable<key_equal>::value);
260227825Stheraven    unordered_multimap& operator=(initializer_list<value_type>);
261227825Stheraven
262227825Stheraven    allocator_type get_allocator() const noexcept;
263227825Stheraven
264227825Stheraven    bool      empty() const noexcept;
265227825Stheraven    size_type size() const noexcept;
266227825Stheraven    size_type max_size() const noexcept;
267227825Stheraven
268227825Stheraven    iterator       begin() noexcept;
269227825Stheraven    iterator       end() noexcept;
270227825Stheraven    const_iterator begin()  const noexcept;
271227825Stheraven    const_iterator end()    const noexcept;
272227825Stheraven    const_iterator cbegin() const noexcept;
273227825Stheraven    const_iterator cend()   const noexcept;
274227825Stheraven
275227825Stheraven    template <class... Args>
276227825Stheraven        iterator emplace(Args&&... args);
277227825Stheraven    template <class... Args>
278227825Stheraven        iterator emplace_hint(const_iterator position, Args&&... args);
279227825Stheraven    iterator insert(const value_type& obj);
280227825Stheraven    template <class P>
281227825Stheraven        iterator insert(P&& obj);
282227825Stheraven    iterator insert(const_iterator hint, const value_type& obj);
283227825Stheraven    template <class P>
284227825Stheraven        iterator insert(const_iterator hint, P&& obj);
285227825Stheraven    template <class InputIterator>
286227825Stheraven        void insert(InputIterator first, InputIterator last);
287227825Stheraven    void insert(initializer_list<value_type>);
288227825Stheraven
289227825Stheraven    iterator erase(const_iterator position);
290227825Stheraven    size_type erase(const key_type& k);
291227825Stheraven    iterator erase(const_iterator first, const_iterator last);
292227825Stheraven    void clear() noexcept;
293227825Stheraven
294227825Stheraven    void swap(unordered_multimap&)
295227825Stheraven        noexcept(
296227825Stheraven            (!allocator_type::propagate_on_container_swap::value ||
297227825Stheraven             __is_nothrow_swappable<allocator_type>::value) &&
298227825Stheraven            __is_nothrow_swappable<hasher>::value &&
299227825Stheraven            __is_nothrow_swappable<key_equal>::value);
300227825Stheraven
301227825Stheraven    hasher hash_function() const;
302227825Stheraven    key_equal key_eq() const;
303227825Stheraven
304227825Stheraven    iterator       find(const key_type& k);
305227825Stheraven    const_iterator find(const key_type& k) const;
306227825Stheraven    size_type count(const key_type& k) const;
307227825Stheraven    pair<iterator, iterator>             equal_range(const key_type& k);
308227825Stheraven    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
309227825Stheraven
310227825Stheraven    size_type bucket_count() const noexcept;
311227825Stheraven    size_type max_bucket_count() const noexcept;
312227825Stheraven
313227825Stheraven    size_type bucket_size(size_type n) const;
314227825Stheraven    size_type bucket(const key_type& k) const;
315227825Stheraven
316227825Stheraven    local_iterator       begin(size_type n);
317227825Stheraven    local_iterator       end(size_type n);
318227825Stheraven    const_local_iterator begin(size_type n) const;
319227825Stheraven    const_local_iterator end(size_type n) const;
320227825Stheraven    const_local_iterator cbegin(size_type n) const;
321227825Stheraven    const_local_iterator cend(size_type n) const;
322227825Stheraven
323227825Stheraven    float load_factor() const noexcept;
324227825Stheraven    float max_load_factor() const noexcept;
325227825Stheraven    void max_load_factor(float z);
326227825Stheraven    void rehash(size_type n);
327227825Stheraven    void reserve(size_type n);
328227825Stheraven};
329227825Stheraven
330227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
331227825Stheraven    void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
332227825Stheraven              unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
333227825Stheraven              noexcept(noexcept(x.swap(y)));
334227825Stheraven
335227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
336227825Stheraven    bool
337227825Stheraven    operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
338227825Stheraven               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
339227825Stheraven
340227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc>
341227825Stheraven    bool
342227825Stheraven    operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
343227825Stheraven               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
344227825Stheraven
345227825Stheraven}  // std
346227825Stheraven
347227825Stheraven*/
348227825Stheraven
349227825Stheraven#include <__config>
350227825Stheraven#include <__hash_table>
351227825Stheraven#include <functional>
352227825Stheraven#include <stdexcept>
353227825Stheraven
354227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
355227825Stheraven#pragma GCC system_header
356227825Stheraven#endif
357227825Stheraven
358227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
359227825Stheraven
360253146Stheraventemplate <class _Key, class _Cp, class _Hash, bool = is_empty<_Hash>::value
361232924Stheraven#if __has_feature(is_final)
362232924Stheraven                                         && !__is_final(_Hash)
363232924Stheraven#endif
364232924Stheraven         >
365227825Stheravenclass __unordered_map_hasher
366227825Stheraven    : private _Hash
367227825Stheraven{
368227825Stheravenpublic:
369227825Stheraven    _LIBCPP_INLINE_VISIBILITY
370227825Stheraven    __unordered_map_hasher()
371227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
372227825Stheraven        : _Hash() {}
373227825Stheraven    _LIBCPP_INLINE_VISIBILITY
374227825Stheraven    __unordered_map_hasher(const _Hash& __h)
375227825Stheraven        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
376227825Stheraven        : _Hash(__h) {}
377227825Stheraven    _LIBCPP_INLINE_VISIBILITY
378227825Stheraven    const _Hash& hash_function() const _NOEXCEPT {return *this;}
379227825Stheraven    _LIBCPP_INLINE_VISIBILITY
380232924Stheraven    size_t operator()(const _Cp& __x) const
381253146Stheraven        {return static_cast<const _Hash&>(*this)(__x.__cc.first);}
382232924Stheraven    _LIBCPP_INLINE_VISIBILITY
383232924Stheraven    size_t operator()(const _Key& __x) const
384227825Stheraven        {return static_cast<const _Hash&>(*this)(__x);}
385227825Stheraven};
386227825Stheraven
387253146Stheraventemplate <class _Key, class _Cp, class _Hash>
388253146Stheravenclass __unordered_map_hasher<_Key, _Cp, _Hash, false>
389227825Stheraven{
390227825Stheraven    _Hash __hash_;
391232924Stheraven
392227825Stheravenpublic:
393227825Stheraven    _LIBCPP_INLINE_VISIBILITY
394227825Stheraven    __unordered_map_hasher()
395227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
396227825Stheraven        : __hash_() {}
397227825Stheraven    _LIBCPP_INLINE_VISIBILITY
398227825Stheraven    __unordered_map_hasher(const _Hash& __h)
399227825Stheraven        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
400227825Stheraven        : __hash_(__h) {}
401227825Stheraven    _LIBCPP_INLINE_VISIBILITY
402227825Stheraven    const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
403227825Stheraven    _LIBCPP_INLINE_VISIBILITY
404232924Stheraven    size_t operator()(const _Cp& __x) const
405253146Stheraven        {return __hash_(__x.__cc.first);}
406232924Stheraven    _LIBCPP_INLINE_VISIBILITY
407232924Stheraven    size_t operator()(const _Key& __x) const
408227825Stheraven        {return __hash_(__x);}
409227825Stheraven};
410227825Stheraven
411253146Stheraventemplate <class _Key, class _Cp, class _Pred, bool = is_empty<_Pred>::value
412232924Stheraven#if __has_feature(is_final)
413232924Stheraven                                         && !__is_final(_Pred)
414232924Stheraven#endif
415232924Stheraven         >
416227825Stheravenclass __unordered_map_equal
417227825Stheraven    : private _Pred
418227825Stheraven{
419227825Stheravenpublic:
420227825Stheraven    _LIBCPP_INLINE_VISIBILITY
421227825Stheraven    __unordered_map_equal()
422227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
423227825Stheraven        : _Pred() {}
424227825Stheraven    _LIBCPP_INLINE_VISIBILITY
425227825Stheraven    __unordered_map_equal(const _Pred& __p)
426227825Stheraven        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
427227825Stheraven        : _Pred(__p) {}
428227825Stheraven    _LIBCPP_INLINE_VISIBILITY
429227825Stheraven    const _Pred& key_eq() const _NOEXCEPT {return *this;}
430227825Stheraven    _LIBCPP_INLINE_VISIBILITY
431232924Stheraven    bool operator()(const _Cp& __x, const _Cp& __y) const
432253146Stheraven        {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y.__cc.first);}
433232924Stheraven    _LIBCPP_INLINE_VISIBILITY
434232924Stheraven    bool operator()(const _Cp& __x, const _Key& __y) const
435253146Stheraven        {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y);}
436232924Stheraven    _LIBCPP_INLINE_VISIBILITY
437232924Stheraven    bool operator()(const _Key& __x, const _Cp& __y) const
438253146Stheraven        {return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);}
439227825Stheraven};
440227825Stheraven
441253146Stheraventemplate <class _Key, class _Cp, class _Pred>
442253146Stheravenclass __unordered_map_equal<_Key, _Cp, _Pred, false>
443227825Stheraven{
444227825Stheraven    _Pred __pred_;
445232924Stheraven
446227825Stheravenpublic:
447227825Stheraven    _LIBCPP_INLINE_VISIBILITY
448227825Stheraven    __unordered_map_equal()
449227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
450227825Stheraven        : __pred_() {}
451227825Stheraven    _LIBCPP_INLINE_VISIBILITY
452227825Stheraven    __unordered_map_equal(const _Pred& __p)
453227825Stheraven        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
454227825Stheraven        : __pred_(__p) {}
455227825Stheraven    _LIBCPP_INLINE_VISIBILITY
456227825Stheraven    const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
457227825Stheraven    _LIBCPP_INLINE_VISIBILITY
458232924Stheraven    bool operator()(const _Cp& __x, const _Cp& __y) const
459253146Stheraven        {return __pred_(__x.__cc.first, __y.__cc.first);}
460232924Stheraven    _LIBCPP_INLINE_VISIBILITY
461232924Stheraven    bool operator()(const _Cp& __x, const _Key& __y) const
462253146Stheraven        {return __pred_(__x.__cc.first, __y);}
463232924Stheraven    _LIBCPP_INLINE_VISIBILITY
464232924Stheraven    bool operator()(const _Key& __x, const _Cp& __y) const
465253146Stheraven        {return __pred_(__x, __y.__cc.first);}
466227825Stheraven};
467227825Stheraven
468227825Stheraventemplate <class _Alloc>
469227825Stheravenclass __hash_map_node_destructor
470227825Stheraven{
471227825Stheraven    typedef _Alloc                              allocator_type;
472227825Stheraven    typedef allocator_traits<allocator_type>    __alloc_traits;
473227825Stheraven    typedef typename __alloc_traits::value_type::value_type value_type;
474227825Stheravenpublic:
475227825Stheraven    typedef typename __alloc_traits::pointer    pointer;
476227825Stheravenprivate:
477253146Stheraven    typedef typename value_type::value_type::first_type     first_type;
478253146Stheraven    typedef typename value_type::value_type::second_type    second_type;
479227825Stheraven
480227825Stheraven    allocator_type& __na_;
481227825Stheraven
482227825Stheraven    __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
483227825Stheraven
484227825Stheravenpublic:
485227825Stheraven    bool __first_constructed;
486227825Stheraven    bool __second_constructed;
487227825Stheraven
488227825Stheraven    _LIBCPP_INLINE_VISIBILITY
489227825Stheraven    explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
490227825Stheraven        : __na_(__na),
491227825Stheraven          __first_constructed(false),
492227825Stheraven          __second_constructed(false)
493227825Stheraven        {}
494227825Stheraven
495227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
496227825Stheraven    _LIBCPP_INLINE_VISIBILITY
497227825Stheraven    __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
498227825Stheraven        _NOEXCEPT
499227825Stheraven        : __na_(__x.__na_),
500227825Stheraven          __first_constructed(__x.__value_constructed),
501227825Stheraven          __second_constructed(__x.__value_constructed)
502227825Stheraven        {
503227825Stheraven            __x.__value_constructed = false;
504227825Stheraven        }
505227825Stheraven#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
506227825Stheraven    _LIBCPP_INLINE_VISIBILITY
507227825Stheraven    __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
508227825Stheraven        : __na_(__x.__na_),
509227825Stheraven          __first_constructed(__x.__value_constructed),
510227825Stheraven          __second_constructed(__x.__value_constructed)
511227825Stheraven        {
512227825Stheraven            const_cast<bool&>(__x.__value_constructed) = false;
513227825Stheraven        }
514227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
515227825Stheraven
516227825Stheraven    _LIBCPP_INLINE_VISIBILITY
517227825Stheraven    void operator()(pointer __p) _NOEXCEPT
518227825Stheraven    {
519227825Stheraven        if (__second_constructed)
520253146Stheraven            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
521227825Stheraven        if (__first_constructed)
522253146Stheraven            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
523227825Stheraven        if (__p)
524227825Stheraven            __alloc_traits::deallocate(__na_, __p, 1);
525227825Stheraven    }
526227825Stheraven};
527227825Stheraven
528261272Sdim#if __cplusplus >= 201103L
529261272Sdim
530261272Sdimtemplate <class _Key, class _Tp>
531261272Sdimunion __hash_value_type
532261272Sdim{
533261272Sdim    typedef _Key                                     key_type;
534261272Sdim    typedef _Tp                                      mapped_type;
535261272Sdim    typedef pair<const key_type, mapped_type>        value_type;
536261272Sdim    typedef pair<key_type, mapped_type>              __nc_value_type;
537261272Sdim
538261272Sdim    value_type __cc;
539261272Sdim    __nc_value_type __nc;
540261272Sdim
541261272Sdim    template <class ..._Args>
542261272Sdim    _LIBCPP_INLINE_VISIBILITY
543261272Sdim    __hash_value_type(_Args&& ...__args)
544261272Sdim        : __cc(std::forward<_Args>(__args)...) {}
545261272Sdim
546261272Sdim    _LIBCPP_INLINE_VISIBILITY
547261272Sdim    __hash_value_type(const __hash_value_type& __v)
548261272Sdim        : __cc(__v.__cc) {}
549261272Sdim
550261272Sdim    _LIBCPP_INLINE_VISIBILITY
551261272Sdim    __hash_value_type(__hash_value_type&& __v)
552261272Sdim        : __nc(std::move(__v.__nc)) {}
553261272Sdim
554261272Sdim    _LIBCPP_INLINE_VISIBILITY
555261272Sdim    __hash_value_type& operator=(const __hash_value_type& __v)
556261272Sdim        {__nc = __v.__cc; return *this;}
557261272Sdim
558261272Sdim    _LIBCPP_INLINE_VISIBILITY
559261272Sdim    __hash_value_type& operator=(__hash_value_type&& __v)
560261272Sdim        {__nc = std::move(__v.__nc); return *this;}
561261272Sdim
562261272Sdim    _LIBCPP_INLINE_VISIBILITY
563261272Sdim    ~__hash_value_type() {__cc.~value_type();}
564261272Sdim};
565261272Sdim
566261272Sdim#else
567261272Sdim
568261272Sdimtemplate <class _Key, class _Tp>
569261272Sdimstruct __hash_value_type
570261272Sdim{
571261272Sdim    typedef _Key                                     key_type;
572261272Sdim    typedef _Tp                                      mapped_type;
573261272Sdim    typedef pair<const key_type, mapped_type>        value_type;
574261272Sdim
575261272Sdim    value_type __cc;
576261272Sdim
577261272Sdim    _LIBCPP_INLINE_VISIBILITY
578261272Sdim    __hash_value_type() {}
579261272Sdim
580261272Sdim    template <class _A0>
581261272Sdim    _LIBCPP_INLINE_VISIBILITY
582261272Sdim    __hash_value_type(const _A0& __a0)
583261272Sdim        : __cc(__a0) {}
584261272Sdim
585261272Sdim    template <class _A0, class _A1>
586261272Sdim    _LIBCPP_INLINE_VISIBILITY
587261272Sdim    __hash_value_type(const _A0& __a0, const _A1& __a1)
588261272Sdim        : __cc(__a0, __a1) {}
589261272Sdim};
590261272Sdim
591261272Sdim#endif
592261272Sdim
593227825Stheraventemplate <class _HashIterator>
594261272Sdimclass _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator
595227825Stheraven{
596227825Stheraven    _HashIterator __i_;
597227825Stheraven
598227825Stheraven    typedef pointer_traits<typename _HashIterator::pointer>      __pointer_traits;
599253146Stheraven    typedef const typename _HashIterator::value_type::value_type::first_type key_type;
600253146Stheraven    typedef typename _HashIterator::value_type::value_type::second_type      mapped_type;
601227825Stheravenpublic:
602227825Stheraven    typedef forward_iterator_tag                                 iterator_category;
603227825Stheraven    typedef pair<key_type, mapped_type>                          value_type;
604227825Stheraven    typedef typename _HashIterator::difference_type              difference_type;
605227825Stheraven    typedef value_type&                                          reference;
606227825Stheraven    typedef typename __pointer_traits::template
607227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
608227825Stheraven            rebind<value_type>
609227825Stheraven#else
610227825Stheraven            rebind<value_type>::other
611227825Stheraven#endif
612227825Stheraven                                                                 pointer;
613227825Stheraven
614227825Stheraven    _LIBCPP_INLINE_VISIBILITY
615227825Stheraven    __hash_map_iterator() _NOEXCEPT {}
616227825Stheraven
617227825Stheraven    _LIBCPP_INLINE_VISIBILITY
618227825Stheraven    __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
619227825Stheraven
620227825Stheraven    _LIBCPP_INLINE_VISIBILITY
621253146Stheraven    reference operator*() const {return __i_->__cc;}
622227825Stheraven    _LIBCPP_INLINE_VISIBILITY
623253146Stheraven    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
624227825Stheraven
625227825Stheraven    _LIBCPP_INLINE_VISIBILITY
626227825Stheraven    __hash_map_iterator& operator++() {++__i_; return *this;}
627227825Stheraven    _LIBCPP_INLINE_VISIBILITY
628227825Stheraven    __hash_map_iterator operator++(int)
629227825Stheraven    {
630227825Stheraven        __hash_map_iterator __t(*this);
631227825Stheraven        ++(*this);
632227825Stheraven        return __t;
633227825Stheraven    }
634227825Stheraven
635227825Stheraven    friend _LIBCPP_INLINE_VISIBILITY
636227825Stheraven        bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
637227825Stheraven        {return __x.__i_ == __y.__i_;}
638227825Stheraven    friend _LIBCPP_INLINE_VISIBILITY
639227825Stheraven        bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
640227825Stheraven        {return __x.__i_ != __y.__i_;}
641227825Stheraven
642261272Sdim    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
643261272Sdim    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
644261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
645261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
646261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
647227825Stheraven};
648227825Stheraven
649227825Stheraventemplate <class _HashIterator>
650261272Sdimclass _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator
651227825Stheraven{
652227825Stheraven    _HashIterator __i_;
653227825Stheraven
654227825Stheraven    typedef pointer_traits<typename _HashIterator::pointer>      __pointer_traits;
655253146Stheraven    typedef const typename _HashIterator::value_type::value_type::first_type key_type;
656253146Stheraven    typedef typename _HashIterator::value_type::value_type::second_type      mapped_type;
657227825Stheravenpublic:
658227825Stheraven    typedef forward_iterator_tag                                 iterator_category;
659227825Stheraven    typedef pair<key_type, mapped_type>                          value_type;
660227825Stheraven    typedef typename _HashIterator::difference_type              difference_type;
661227825Stheraven    typedef const value_type&                                    reference;
662227825Stheraven    typedef typename __pointer_traits::template
663227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
664227825Stheraven            rebind<const value_type>
665227825Stheraven#else
666227825Stheraven            rebind<const value_type>::other
667227825Stheraven#endif
668227825Stheraven                                                                 pointer;
669227825Stheraven
670227825Stheraven    _LIBCPP_INLINE_VISIBILITY
671227825Stheraven    __hash_map_const_iterator() _NOEXCEPT {}
672227825Stheraven
673227825Stheraven    _LIBCPP_INLINE_VISIBILITY
674227825Stheraven    __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
675227825Stheraven    _LIBCPP_INLINE_VISIBILITY
676227825Stheraven    __hash_map_const_iterator(
677227825Stheraven            __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
678227825Stheraven                 _NOEXCEPT
679227825Stheraven                : __i_(__i.__i_) {}
680227825Stheraven
681227825Stheraven    _LIBCPP_INLINE_VISIBILITY
682253146Stheraven    reference operator*() const {return __i_->__cc;}
683227825Stheraven    _LIBCPP_INLINE_VISIBILITY
684253146Stheraven    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
685227825Stheraven
686227825Stheraven    _LIBCPP_INLINE_VISIBILITY
687227825Stheraven    __hash_map_const_iterator& operator++() {++__i_; return *this;}
688227825Stheraven    _LIBCPP_INLINE_VISIBILITY
689227825Stheraven    __hash_map_const_iterator operator++(int)
690227825Stheraven    {
691227825Stheraven        __hash_map_const_iterator __t(*this);
692227825Stheraven        ++(*this);
693227825Stheraven        return __t;
694227825Stheraven    }
695227825Stheraven
696227825Stheraven    friend _LIBCPP_INLINE_VISIBILITY
697227825Stheraven        bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
698227825Stheraven        {return __x.__i_ == __y.__i_;}
699227825Stheraven    friend _LIBCPP_INLINE_VISIBILITY
700227825Stheraven        bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
701227825Stheraven        {return __x.__i_ != __y.__i_;}
702227825Stheraven
703261272Sdim    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
704261272Sdim    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
705261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
706261272Sdim    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
707227825Stheraven};
708227825Stheraven
709227825Stheraventemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
710227825Stheraven          class _Alloc = allocator<pair<const _Key, _Tp> > >
711261272Sdimclass _LIBCPP_TYPE_VIS_ONLY unordered_map
712227825Stheraven{
713227825Stheravenpublic:
714227825Stheraven    // types
715227825Stheraven    typedef _Key                                           key_type;
716227825Stheraven    typedef _Tp                                            mapped_type;
717227825Stheraven    typedef _Hash                                          hasher;
718227825Stheraven    typedef _Pred                                          key_equal;
719227825Stheraven    typedef _Alloc                                         allocator_type;
720227825Stheraven    typedef pair<const key_type, mapped_type>              value_type;
721253146Stheraven    typedef pair<key_type, mapped_type>                    __nc_value_type;
722227825Stheraven    typedef value_type&                                    reference;
723227825Stheraven    typedef const value_type&                              const_reference;
724261272Sdim    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
725261272Sdim                  "Invalid allocator::value_type");
726227825Stheraven
727227825Stheravenprivate:
728261272Sdim    typedef __hash_value_type<key_type, mapped_type>                 __value_type;
729253146Stheraven    typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
730253146Stheraven    typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
731227825Stheraven    typedef typename allocator_traits<allocator_type>::template
732227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
733227825Stheraven            rebind_alloc<__value_type>
734227825Stheraven#else
735227825Stheraven            rebind_alloc<__value_type>::other
736227825Stheraven#endif
737227825Stheraven                                                           __allocator_type;
738227825Stheraven
739227825Stheraven    typedef __hash_table<__value_type, __hasher,
740227825Stheraven                         __key_equal,  __allocator_type>   __table;
741227825Stheraven
742227825Stheraven    __table __table_;
743227825Stheraven
744227825Stheraven    typedef typename __table::__node_pointer               __node_pointer;
745227825Stheraven    typedef typename __table::__node_const_pointer         __node_const_pointer;
746227825Stheraven    typedef typename __table::__node_traits                __node_traits;
747227825Stheraven    typedef typename __table::__node_allocator             __node_allocator;
748227825Stheraven    typedef typename __table::__node                       __node;
749232924Stheraven    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
750232924Stheraven    typedef unique_ptr<__node, _Dp>                         __node_holder;
751227825Stheraven    typedef allocator_traits<allocator_type>               __alloc_traits;
752227825Stheravenpublic:
753227825Stheraven    typedef typename __alloc_traits::pointer         pointer;
754227825Stheraven    typedef typename __alloc_traits::const_pointer   const_pointer;
755227825Stheraven    typedef typename __alloc_traits::size_type       size_type;
756227825Stheraven    typedef typename __alloc_traits::difference_type difference_type;
757227825Stheraven
758227825Stheraven    typedef __hash_map_iterator<typename __table::iterator>       iterator;
759227825Stheraven    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
760227825Stheraven    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
761227825Stheraven    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
762227825Stheraven
763227825Stheraven    _LIBCPP_INLINE_VISIBILITY
764227825Stheraven    unordered_map()
765227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
766261272Sdim        {
767261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
768261272Sdim            __get_db()->__insert_c(this);
769261272Sdim#endif
770261272Sdim        }
771227825Stheraven    explicit unordered_map(size_type __n, const hasher& __hf = hasher(),
772227825Stheraven                           const key_equal& __eql = key_equal());
773227825Stheraven    unordered_map(size_type __n, const hasher& __hf,
774227825Stheraven                  const key_equal& __eql,
775227825Stheraven                  const allocator_type& __a);
776227825Stheraven    template <class _InputIterator>
777227825Stheraven        unordered_map(_InputIterator __first, _InputIterator __last);
778227825Stheraven    template <class _InputIterator>
779227825Stheraven        unordered_map(_InputIterator __first, _InputIterator __last,
780227825Stheraven                      size_type __n, const hasher& __hf = hasher(),
781227825Stheraven                      const key_equal& __eql = key_equal());
782227825Stheraven    template <class _InputIterator>
783227825Stheraven        unordered_map(_InputIterator __first, _InputIterator __last,
784227825Stheraven                      size_type __n, const hasher& __hf,
785227825Stheraven                      const key_equal& __eql,
786227825Stheraven                      const allocator_type& __a);
787227825Stheraven    explicit unordered_map(const allocator_type& __a);
788227825Stheraven    unordered_map(const unordered_map& __u);
789227825Stheraven    unordered_map(const unordered_map& __u, const allocator_type& __a);
790227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
791227825Stheraven    unordered_map(unordered_map&& __u)
792227825Stheraven        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
793227825Stheraven    unordered_map(unordered_map&& __u, const allocator_type& __a);
794227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
795227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
796227825Stheraven    unordered_map(initializer_list<value_type> __il);
797227825Stheraven    unordered_map(initializer_list<value_type> __il, size_type __n,
798227825Stheraven                  const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
799227825Stheraven    unordered_map(initializer_list<value_type> __il, size_type __n,
800227825Stheraven                  const hasher& __hf, const key_equal& __eql,
801227825Stheraven                  const allocator_type& __a);
802227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
803261272Sdim#if _LIBCPP_STD_VER > 11
804261272Sdim    _LIBCPP_INLINE_VISIBILITY
805261272Sdim    unordered_map(size_type __n, const allocator_type& __a)
806261272Sdim      : unordered_map(__n, hasher(), key_equal(), __a) {}
807261272Sdim    _LIBCPP_INLINE_VISIBILITY
808261272Sdim    unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
809261272Sdim      : unordered_map(__n, __hf, key_equal(), __a) {}
810261272Sdim    template <class _InputIterator>
811261272Sdim    _LIBCPP_INLINE_VISIBILITY
812261272Sdim      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
813261272Sdim      : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
814261272Sdim    template <class _InputIterator>
815261272Sdim    _LIBCPP_INLINE_VISIBILITY
816261272Sdim      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, 
817261272Sdim        const allocator_type& __a)
818261272Sdim      : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
819261272Sdim    _LIBCPP_INLINE_VISIBILITY
820261272Sdim    unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
821261272Sdim      : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
822261272Sdim    _LIBCPP_INLINE_VISIBILITY
823261272Sdim    unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, 
824261272Sdim      const allocator_type& __a)
825261272Sdim      : unordered_map(__il, __n, __hf, key_equal(), __a) {}
826261272Sdim#endif
827227825Stheraven    // ~unordered_map() = default;
828227825Stheraven    _LIBCPP_INLINE_VISIBILITY
829227825Stheraven    unordered_map& operator=(const unordered_map& __u)
830227825Stheraven    {
831253146Stheraven#if __cplusplus >= 201103L
832227825Stheraven        __table_ = __u.__table_;
833253146Stheraven#else
834253146Stheraven        __table_.clear();
835253146Stheraven        __table_.hash_function() = __u.__table_.hash_function();
836253146Stheraven        __table_.key_eq() = __u.__table_.key_eq();
837253146Stheraven        __table_.max_load_factor() = __u.__table_.max_load_factor();
838253146Stheraven        __table_.__copy_assign_alloc(__u.__table_);
839253146Stheraven        insert(__u.begin(), __u.end());
840253146Stheraven#endif
841227825Stheraven        return *this;
842227825Stheraven    }
843227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
844227825Stheraven    unordered_map& operator=(unordered_map&& __u)
845227825Stheraven        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
846227825Stheraven#endif
847227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
848227825Stheraven    unordered_map& operator=(initializer_list<value_type> __il);
849227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
850227825Stheraven
851227825Stheraven    _LIBCPP_INLINE_VISIBILITY
852227825Stheraven    allocator_type get_allocator() const _NOEXCEPT
853227825Stheraven        {return allocator_type(__table_.__node_alloc());}
854227825Stheraven
855227825Stheraven    _LIBCPP_INLINE_VISIBILITY
856227825Stheraven    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
857227825Stheraven    _LIBCPP_INLINE_VISIBILITY
858227825Stheraven    size_type size() const _NOEXCEPT  {return __table_.size();}
859227825Stheraven    _LIBCPP_INLINE_VISIBILITY
860227825Stheraven    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
861227825Stheraven
862227825Stheraven    _LIBCPP_INLINE_VISIBILITY
863227825Stheraven    iterator       begin() _NOEXCEPT        {return __table_.begin();}
864227825Stheraven    _LIBCPP_INLINE_VISIBILITY
865227825Stheraven    iterator       end() _NOEXCEPT          {return __table_.end();}
866227825Stheraven    _LIBCPP_INLINE_VISIBILITY
867227825Stheraven    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
868227825Stheraven    _LIBCPP_INLINE_VISIBILITY
869227825Stheraven    const_iterator end()    const _NOEXCEPT {return __table_.end();}
870227825Stheraven    _LIBCPP_INLINE_VISIBILITY
871227825Stheraven    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
872227825Stheraven    _LIBCPP_INLINE_VISIBILITY
873227825Stheraven    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
874227825Stheraven
875227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
876227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
877227825Stheraven
878241900Sdim    template <class... _Args>
879241900Sdim        pair<iterator, bool> emplace(_Args&&... __args);
880227825Stheraven
881241900Sdim    template <class... _Args>
882227825Stheraven        _LIBCPP_INLINE_VISIBILITY
883261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
884261272Sdim        iterator emplace_hint(const_iterator __p, _Args&&... __args)
885261272Sdim        {
886261272Sdim            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
887261272Sdim                "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
888261272Sdim                " referring to this unordered_map");
889261272Sdim            return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
890261272Sdim        }
891261272Sdim#else
892241900Sdim        iterator emplace_hint(const_iterator, _Args&&... __args)
893241900Sdim            {return emplace(_VSTD::forward<_Args>(__args)...).first;}
894261272Sdim#endif
895227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
896227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
897227825Stheraven    _LIBCPP_INLINE_VISIBILITY
898227825Stheraven    pair<iterator, bool> insert(const value_type& __x)
899227825Stheraven        {return __table_.__insert_unique(__x);}
900227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
901232924Stheraven    template <class _Pp,
902232924Stheraven              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
903227825Stheraven        _LIBCPP_INLINE_VISIBILITY
904232924Stheraven        pair<iterator, bool> insert(_Pp&& __x)
905232924Stheraven            {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));}
906227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
907227825Stheraven    _LIBCPP_INLINE_VISIBILITY
908261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
909261272Sdim    iterator insert(const_iterator __p, const value_type& __x)
910261272Sdim        {
911261272Sdim            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
912261272Sdim                "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
913261272Sdim                " referring to this unordered_map");
914261272Sdim            return insert(__x).first;
915261272Sdim        }
916261272Sdim#else
917227825Stheraven    iterator insert(const_iterator, const value_type& __x)
918227825Stheraven        {return insert(__x).first;}
919261272Sdim#endif
920227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
921232924Stheraven    template <class _Pp,
922232924Stheraven              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
923227825Stheraven        _LIBCPP_INLINE_VISIBILITY
924261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
925261272Sdim        iterator insert(const_iterator __p, _Pp&& __x)
926261272Sdim        {
927261272Sdim            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
928261272Sdim                "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
929261272Sdim                " referring to this unordered_map");
930261272Sdim            return insert(_VSTD::forward<_Pp>(__x)).first;
931261272Sdim        }
932261272Sdim#else
933232924Stheraven        iterator insert(const_iterator, _Pp&& __x)
934232924Stheraven            {return insert(_VSTD::forward<_Pp>(__x)).first;}
935261272Sdim#endif
936227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
937227825Stheraven    template <class _InputIterator>
938227825Stheraven        void insert(_InputIterator __first, _InputIterator __last);
939227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
940227825Stheraven    _LIBCPP_INLINE_VISIBILITY
941227825Stheraven    void insert(initializer_list<value_type> __il)
942227825Stheraven        {insert(__il.begin(), __il.end());}
943227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
944227825Stheraven
945227825Stheraven    _LIBCPP_INLINE_VISIBILITY
946227825Stheraven    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
947227825Stheraven    _LIBCPP_INLINE_VISIBILITY
948227825Stheraven    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
949227825Stheraven    _LIBCPP_INLINE_VISIBILITY
950227825Stheraven    iterator erase(const_iterator __first, const_iterator __last)
951227825Stheraven        {return __table_.erase(__first.__i_, __last.__i_);}
952227825Stheraven    _LIBCPP_INLINE_VISIBILITY
953227825Stheraven    void clear() _NOEXCEPT {__table_.clear();}
954227825Stheraven
955227825Stheraven    _LIBCPP_INLINE_VISIBILITY
956227825Stheraven    void swap(unordered_map& __u)
957227825Stheraven        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
958227825Stheraven        {__table_.swap(__u.__table_);}
959227825Stheraven
960227825Stheraven    _LIBCPP_INLINE_VISIBILITY
961227825Stheraven    hasher hash_function() const
962227825Stheraven        {return __table_.hash_function().hash_function();}
963227825Stheraven    _LIBCPP_INLINE_VISIBILITY
964227825Stheraven    key_equal key_eq() const
965227825Stheraven        {return __table_.key_eq().key_eq();}
966227825Stheraven
967227825Stheraven    _LIBCPP_INLINE_VISIBILITY
968227825Stheraven    iterator       find(const key_type& __k)       {return __table_.find(__k);}
969227825Stheraven    _LIBCPP_INLINE_VISIBILITY
970227825Stheraven    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
971227825Stheraven    _LIBCPP_INLINE_VISIBILITY
972227825Stheraven    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
973227825Stheraven    _LIBCPP_INLINE_VISIBILITY
974227825Stheraven    pair<iterator, iterator>             equal_range(const key_type& __k)
975227825Stheraven        {return __table_.__equal_range_unique(__k);}
976227825Stheraven    _LIBCPP_INLINE_VISIBILITY
977227825Stheraven    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
978227825Stheraven        {return __table_.__equal_range_unique(__k);}
979227825Stheraven
980227825Stheraven    mapped_type& operator[](const key_type& __k);
981227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
982227825Stheraven    mapped_type& operator[](key_type&& __k);
983227825Stheraven#endif
984227825Stheraven
985227825Stheraven    mapped_type&       at(const key_type& __k);
986227825Stheraven    const mapped_type& at(const key_type& __k) const;
987227825Stheraven
988227825Stheraven    _LIBCPP_INLINE_VISIBILITY
989227825Stheraven    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
990227825Stheraven    _LIBCPP_INLINE_VISIBILITY
991227825Stheraven    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
992227825Stheraven
993227825Stheraven    _LIBCPP_INLINE_VISIBILITY
994227825Stheraven    size_type bucket_size(size_type __n) const
995227825Stheraven        {return __table_.bucket_size(__n);}
996227825Stheraven    _LIBCPP_INLINE_VISIBILITY
997227825Stheraven    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
998227825Stheraven
999227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1000227825Stheraven    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
1001227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1002227825Stheraven    local_iterator       end(size_type __n)          {return __table_.end(__n);}
1003227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1004227825Stheraven    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
1005227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1006227825Stheraven    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
1007227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1008227825Stheraven    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
1009227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1010227825Stheraven    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
1011227825Stheraven
1012227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1013227825Stheraven    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
1014227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1015227825Stheraven    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
1016227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1017227825Stheraven    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
1018227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1019227825Stheraven    void rehash(size_type __n) {__table_.rehash(__n);}
1020227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1021227825Stheraven    void reserve(size_type __n) {__table_.reserve(__n);}
1022227825Stheraven
1023261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1024261272Sdim
1025261272Sdim    bool __dereferenceable(const const_iterator* __i) const
1026261272Sdim        {return __table_.__dereferenceable(&__i->__i_);}
1027261272Sdim    bool __decrementable(const const_iterator* __i) const
1028261272Sdim        {return __table_.__decrementable(&__i->__i_);}
1029261272Sdim    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1030261272Sdim        {return __table_.__addable(&__i->__i_, __n);}
1031261272Sdim    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1032261272Sdim        {return __table_.__addable(&__i->__i_, __n);}
1033261272Sdim
1034261272Sdim#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1035261272Sdim
1036227825Stheravenprivate:
1037227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1038241900Sdim    __node_holder __construct_node();
1039241900Sdim    template <class _A0>
1040253146Stheraven        __node_holder
1041241900Sdim         __construct_node(_A0&& __a0);
1042253146Stheraven    __node_holder __construct_node_with_key(key_type&& __k);
1043227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1044241900Sdim    template <class _A0, class _A1, class ..._Args>
1045241900Sdim        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
1046227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1047253146Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1048253146Stheraven    __node_holder __construct_node_with_key(const key_type& __k);
1049227825Stheraven};
1050227825Stheraven
1051227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1052227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1053227825Stheraven        size_type __n, const hasher& __hf, const key_equal& __eql)
1054227825Stheraven    : __table_(__hf, __eql)
1055227825Stheraven{
1056261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1057261272Sdim    __get_db()->__insert_c(this);
1058261272Sdim#endif
1059227825Stheraven    __table_.rehash(__n);
1060227825Stheraven}
1061227825Stheraven
1062227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1063227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1064227825Stheraven        size_type __n, const hasher& __hf, const key_equal& __eql,
1065227825Stheraven        const allocator_type& __a)
1066227825Stheraven    : __table_(__hf, __eql, __a)
1067227825Stheraven{
1068261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1069261272Sdim    __get_db()->__insert_c(this);
1070261272Sdim#endif
1071227825Stheraven    __table_.rehash(__n);
1072227825Stheraven}
1073227825Stheraven
1074227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1075227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1076227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1077227825Stheraven        const allocator_type& __a)
1078227825Stheraven    : __table_(__a)
1079227825Stheraven{
1080261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1081261272Sdim    __get_db()->__insert_c(this);
1082261272Sdim#endif
1083227825Stheraven}
1084227825Stheraven
1085227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1086227825Stheraventemplate <class _InputIterator>
1087227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1088227825Stheraven        _InputIterator __first, _InputIterator __last)
1089227825Stheraven{
1090261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1091261272Sdim    __get_db()->__insert_c(this);
1092261272Sdim#endif
1093227825Stheraven    insert(__first, __last);
1094227825Stheraven}
1095227825Stheraven
1096227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1097227825Stheraventemplate <class _InputIterator>
1098227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1099227825Stheraven        _InputIterator __first, _InputIterator __last, size_type __n,
1100227825Stheraven        const hasher& __hf, const key_equal& __eql)
1101227825Stheraven    : __table_(__hf, __eql)
1102227825Stheraven{
1103261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1104261272Sdim    __get_db()->__insert_c(this);
1105261272Sdim#endif
1106227825Stheraven    __table_.rehash(__n);
1107227825Stheraven    insert(__first, __last);
1108227825Stheraven}
1109227825Stheraven
1110227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1111227825Stheraventemplate <class _InputIterator>
1112227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1113227825Stheraven        _InputIterator __first, _InputIterator __last, size_type __n,
1114227825Stheraven        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1115227825Stheraven    : __table_(__hf, __eql, __a)
1116227825Stheraven{
1117261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1118261272Sdim    __get_db()->__insert_c(this);
1119261272Sdim#endif
1120227825Stheraven    __table_.rehash(__n);
1121227825Stheraven    insert(__first, __last);
1122227825Stheraven}
1123227825Stheraven
1124227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1125227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1126227825Stheraven        const unordered_map& __u)
1127227825Stheraven    : __table_(__u.__table_)
1128227825Stheraven{
1129261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1130261272Sdim    __get_db()->__insert_c(this);
1131261272Sdim#endif
1132227825Stheraven    __table_.rehash(__u.bucket_count());
1133227825Stheraven    insert(__u.begin(), __u.end());
1134227825Stheraven}
1135227825Stheraven
1136227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1137227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1138227825Stheraven        const unordered_map& __u, const allocator_type& __a)
1139227825Stheraven    : __table_(__u.__table_, __a)
1140227825Stheraven{
1141261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1142261272Sdim    __get_db()->__insert_c(this);
1143261272Sdim#endif
1144227825Stheraven    __table_.rehash(__u.bucket_count());
1145227825Stheraven    insert(__u.begin(), __u.end());
1146227825Stheraven}
1147227825Stheraven
1148227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1149227825Stheraven
1150227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1151227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1152227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1153227825Stheraven        unordered_map&& __u)
1154227825Stheraven    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1155227825Stheraven    : __table_(_VSTD::move(__u.__table_))
1156227825Stheraven{
1157261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1158261272Sdim    __get_db()->__insert_c(this);
1159261272Sdim    __get_db()->swap(this, &__u);
1160261272Sdim#endif
1161227825Stheraven}
1162227825Stheraven
1163227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1164227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1165227825Stheraven        unordered_map&& __u, const allocator_type& __a)
1166227825Stheraven    : __table_(_VSTD::move(__u.__table_), __a)
1167227825Stheraven{
1168261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1169261272Sdim    __get_db()->__insert_c(this);
1170261272Sdim#endif
1171227825Stheraven    if (__a != __u.get_allocator())
1172227825Stheraven    {
1173227825Stheraven        iterator __i = __u.begin();
1174227825Stheraven        while (__u.size() != 0)
1175227825Stheraven            __table_.__insert_unique(
1176227825Stheraven                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
1177227825Stheraven                                    );
1178227825Stheraven    }
1179261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1180261272Sdim    else
1181261272Sdim        __get_db()->swap(this, &__u);
1182261272Sdim#endif
1183227825Stheraven}
1184227825Stheraven
1185227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1186227825Stheraven
1187227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1188227825Stheraven
1189227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1190227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1191227825Stheraven        initializer_list<value_type> __il)
1192227825Stheraven{
1193261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1194261272Sdim    __get_db()->__insert_c(this);
1195261272Sdim#endif
1196227825Stheraven    insert(__il.begin(), __il.end());
1197227825Stheraven}
1198227825Stheraven
1199227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1200227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1201227825Stheraven        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1202227825Stheraven        const key_equal& __eql)
1203227825Stheraven    : __table_(__hf, __eql)
1204227825Stheraven{
1205261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1206261272Sdim    __get_db()->__insert_c(this);
1207261272Sdim#endif
1208227825Stheraven    __table_.rehash(__n);
1209227825Stheraven    insert(__il.begin(), __il.end());
1210227825Stheraven}
1211227825Stheraven
1212227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1213227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
1214227825Stheraven        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1215227825Stheraven        const key_equal& __eql, const allocator_type& __a)
1216227825Stheraven    : __table_(__hf, __eql, __a)
1217227825Stheraven{
1218261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1219261272Sdim    __get_db()->__insert_c(this);
1220261272Sdim#endif
1221227825Stheraven    __table_.rehash(__n);
1222227825Stheraven    insert(__il.begin(), __il.end());
1223227825Stheraven}
1224227825Stheraven
1225227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1226227825Stheraven
1227227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1228227825Stheraven
1229227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1230227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1231227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
1232227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u)
1233227825Stheraven    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
1234227825Stheraven{
1235227825Stheraven    __table_ = _VSTD::move(__u.__table_);
1236227825Stheraven    return *this;
1237227825Stheraven}
1238227825Stheraven
1239227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1240227825Stheraven
1241227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1242227825Stheraven
1243227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1244227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1245227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
1246227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
1247227825Stheraven        initializer_list<value_type> __il)
1248227825Stheraven{
1249227825Stheraven    __table_.__assign_unique(__il.begin(), __il.end());
1250227825Stheraven    return *this;
1251227825Stheraven}
1252227825Stheraven
1253227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1254227825Stheraven
1255227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1256227825Stheraven
1257227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1258227825Stheraventypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1259241900Sdimunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
1260227825Stheraven{
1261227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
1262232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1263241900Sdim    __node_traits::construct(__na, _VSTD::addressof(__h->__value_));
1264227825Stheraven    __h.get_deleter().__first_constructed = true;
1265227825Stheraven    __h.get_deleter().__second_constructed = true;
1266227825Stheraven    return __h;
1267227825Stheraven}
1268227825Stheraven
1269227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1270241900Sdimtemplate <class _A0>
1271253146Stheraventypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1272227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
1273227825Stheraven{
1274227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
1275232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1276227825Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
1277227825Stheraven                             _VSTD::forward<_A0>(__a0));
1278227825Stheraven    __h.get_deleter().__first_constructed = true;
1279227825Stheraven    __h.get_deleter().__second_constructed = true;
1280227825Stheraven    return __h;
1281227825Stheraven}
1282227825Stheraven
1283241900Sdimtemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1284253146Stheraventypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1285253146Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_type&& __k)
1286241900Sdim{
1287241900Sdim    __node_allocator& __na = __table_.__node_alloc();
1288241900Sdim    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1289253146Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
1290241900Sdim    __h.get_deleter().__first_constructed = true;
1291253146Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
1292241900Sdim    __h.get_deleter().__second_constructed = true;
1293261272Sdim    return __h;
1294241900Sdim}
1295241900Sdim
1296227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1297227825Stheraven
1298227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1299241900Sdimtemplate <class _A0, class _A1, class ..._Args>
1300241900Sdimtypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1301241900Sdimunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0,
1302241900Sdim                                                                 _A1&& __a1,
1303241900Sdim                                                                 _Args&&... __args)
1304241900Sdim{
1305241900Sdim    __node_allocator& __na = __table_.__node_alloc();
1306241900Sdim    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1307241900Sdim    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
1308241900Sdim                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
1309241900Sdim                             _VSTD::forward<_Args>(__args)...);
1310241900Sdim    __h.get_deleter().__first_constructed = true;
1311241900Sdim    __h.get_deleter().__second_constructed = true;
1312241900Sdim    return __h;
1313241900Sdim}
1314241900Sdim
1315241900Sdimtemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1316241900Sdimtemplate <class... _Args>
1317227825Stheravenpair<typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator, bool>
1318241900Sdimunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
1319227825Stheraven{
1320241900Sdim    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
1321227825Stheraven    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
1322227825Stheraven    if (__r.second)
1323227825Stheraven        __h.release();
1324227825Stheraven    return __r;
1325227825Stheraven}
1326227825Stheraven
1327227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1328253146Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1329227825Stheraven
1330227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1331227825Stheraventypename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1332253146Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
1333227825Stheraven{
1334227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
1335232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1336253146Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k);
1337227825Stheraven    __h.get_deleter().__first_constructed = true;
1338253146Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
1339227825Stheraven    __h.get_deleter().__second_constructed = true;
1340261272Sdim    return _VSTD::move(__h);  // explicitly moved for C++03
1341227825Stheraven}
1342227825Stheraven
1343227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1344227825Stheraventemplate <class _InputIterator>
1345227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1346227825Stheravenvoid
1347227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
1348227825Stheraven                                                       _InputIterator __last)
1349227825Stheraven{
1350227825Stheraven    for (; __first != __last; ++__first)
1351227825Stheraven        __table_.__insert_unique(*__first);
1352227825Stheraven}
1353227825Stheraven
1354227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1355227825Stheraven_Tp&
1356227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
1357227825Stheraven{
1358227825Stheraven    iterator __i = find(__k);
1359227825Stheraven    if (__i != end())
1360227825Stheraven        return __i->second;
1361253146Stheraven    __node_holder __h = __construct_node_with_key(__k);
1362227825Stheraven    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
1363227825Stheraven    __h.release();
1364227825Stheraven    return __r.first->second;
1365227825Stheraven}
1366227825Stheraven
1367227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1368227825Stheraven
1369227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1370227825Stheraven_Tp&
1371227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
1372227825Stheraven{
1373227825Stheraven    iterator __i = find(__k);
1374227825Stheraven    if (__i != end())
1375227825Stheraven        return __i->second;
1376253146Stheraven    __node_holder __h = __construct_node_with_key(_VSTD::move(__k));
1377227825Stheraven    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
1378227825Stheraven    __h.release();
1379227825Stheraven    return __r.first->second;
1380227825Stheraven}
1381227825Stheraven
1382227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1383227825Stheraven
1384227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1385227825Stheraven_Tp&
1386227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k)
1387227825Stheraven{
1388227825Stheraven    iterator __i = find(__k);
1389227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS
1390227825Stheraven    if (__i == end())
1391227825Stheraven        throw out_of_range("unordered_map::at: key not found");
1392227825Stheraven#endif  // _LIBCPP_NO_EXCEPTIONS
1393227825Stheraven    return __i->second;
1394227825Stheraven}
1395227825Stheraven
1396227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1397227825Stheravenconst _Tp&
1398227825Stheravenunordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const
1399227825Stheraven{
1400227825Stheraven    const_iterator __i = find(__k);
1401227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS
1402227825Stheraven    if (__i == end())
1403227825Stheraven        throw out_of_range("unordered_map::at: key not found");
1404227825Stheraven#endif  // _LIBCPP_NO_EXCEPTIONS
1405227825Stheraven    return __i->second;
1406227825Stheraven}
1407227825Stheraven
1408227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1409227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1410227825Stheravenvoid
1411227825Stheravenswap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1412227825Stheraven     unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1413227825Stheraven    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
1414227825Stheraven{
1415227825Stheraven    __x.swap(__y);
1416227825Stheraven}
1417227825Stheraven
1418227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1419227825Stheravenbool
1420227825Stheravenoperator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1421227825Stheraven           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1422227825Stheraven{
1423227825Stheraven    if (__x.size() != __y.size())
1424227825Stheraven        return false;
1425227825Stheraven    typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
1426227825Stheraven                                                                 const_iterator;
1427227825Stheraven    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
1428227825Stheraven            __i != __ex; ++__i)
1429227825Stheraven    {
1430227825Stheraven        const_iterator __j = __y.find(__i->first);
1431227825Stheraven        if (__j == __ey || !(*__i == *__j))
1432227825Stheraven            return false;
1433227825Stheraven    }
1434227825Stheraven    return true;
1435227825Stheraven}
1436227825Stheraven
1437227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1438227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1439227825Stheravenbool
1440227825Stheravenoperator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1441227825Stheraven           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1442227825Stheraven{
1443227825Stheraven    return !(__x == __y);
1444227825Stheraven}
1445227825Stheraven
1446227825Stheraventemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
1447227825Stheraven          class _Alloc = allocator<pair<const _Key, _Tp> > >
1448261272Sdimclass _LIBCPP_TYPE_VIS_ONLY unordered_multimap
1449227825Stheraven{
1450227825Stheravenpublic:
1451227825Stheraven    // types
1452227825Stheraven    typedef _Key                                           key_type;
1453227825Stheraven    typedef _Tp                                            mapped_type;
1454227825Stheraven    typedef _Hash                                          hasher;
1455227825Stheraven    typedef _Pred                                          key_equal;
1456227825Stheraven    typedef _Alloc                                         allocator_type;
1457227825Stheraven    typedef pair<const key_type, mapped_type>              value_type;
1458253146Stheraven    typedef pair<key_type, mapped_type>                    __nc_value_type;
1459227825Stheraven    typedef value_type&                                    reference;
1460227825Stheraven    typedef const value_type&                              const_reference;
1461261272Sdim    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1462261272Sdim                  "Invalid allocator::value_type");
1463227825Stheraven
1464227825Stheravenprivate:
1465261272Sdim    typedef __hash_value_type<key_type, mapped_type>                 __value_type;
1466253146Stheraven    typedef __unordered_map_hasher<key_type, __value_type, hasher>   __hasher;
1467253146Stheraven    typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
1468227825Stheraven    typedef typename allocator_traits<allocator_type>::template
1469227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
1470227825Stheraven            rebind_alloc<__value_type>
1471227825Stheraven#else
1472227825Stheraven            rebind_alloc<__value_type>::other
1473227825Stheraven#endif
1474227825Stheraven                                                           __allocator_type;
1475227825Stheraven
1476227825Stheraven    typedef __hash_table<__value_type, __hasher,
1477227825Stheraven                         __key_equal,  __allocator_type>   __table;
1478227825Stheraven
1479227825Stheraven    __table __table_;
1480227825Stheraven
1481227825Stheraven    typedef typename __table::__node_traits                __node_traits;
1482227825Stheraven    typedef typename __table::__node_allocator             __node_allocator;
1483227825Stheraven    typedef typename __table::__node                       __node;
1484232924Stheraven    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
1485232924Stheraven    typedef unique_ptr<__node, _Dp>                         __node_holder;
1486227825Stheraven    typedef allocator_traits<allocator_type>               __alloc_traits;
1487227825Stheravenpublic:
1488227825Stheraven    typedef typename __alloc_traits::pointer         pointer;
1489227825Stheraven    typedef typename __alloc_traits::const_pointer   const_pointer;
1490227825Stheraven    typedef typename __alloc_traits::size_type       size_type;
1491227825Stheraven    typedef typename __alloc_traits::difference_type difference_type;
1492227825Stheraven
1493227825Stheraven    typedef __hash_map_iterator<typename __table::iterator>       iterator;
1494227825Stheraven    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
1495227825Stheraven    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
1496227825Stheraven    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
1497227825Stheraven
1498227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1499227825Stheraven    unordered_multimap()
1500227825Stheraven        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
1501261272Sdim        {
1502261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1503261272Sdim            __get_db()->__insert_c(this);
1504261272Sdim#endif
1505261272Sdim        }
1506227825Stheraven    explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(),
1507227825Stheraven                                const key_equal& __eql = key_equal());
1508227825Stheraven    unordered_multimap(size_type __n, const hasher& __hf,
1509227825Stheraven                                const key_equal& __eql,
1510227825Stheraven                                const allocator_type& __a);
1511227825Stheraven    template <class _InputIterator>
1512227825Stheraven        unordered_multimap(_InputIterator __first, _InputIterator __last);
1513227825Stheraven    template <class _InputIterator>
1514227825Stheraven        unordered_multimap(_InputIterator __first, _InputIterator __last,
1515227825Stheraven                      size_type __n, const hasher& __hf = hasher(),
1516227825Stheraven                      const key_equal& __eql = key_equal());
1517227825Stheraven    template <class _InputIterator>
1518227825Stheraven        unordered_multimap(_InputIterator __first, _InputIterator __last,
1519227825Stheraven                      size_type __n, const hasher& __hf,
1520227825Stheraven                      const key_equal& __eql,
1521227825Stheraven                      const allocator_type& __a);
1522227825Stheraven    explicit unordered_multimap(const allocator_type& __a);
1523227825Stheraven    unordered_multimap(const unordered_multimap& __u);
1524227825Stheraven    unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
1525227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1526227825Stheraven    unordered_multimap(unordered_multimap&& __u)
1527227825Stheraven        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
1528227825Stheraven    unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
1529227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1530227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1531227825Stheraven    unordered_multimap(initializer_list<value_type> __il);
1532227825Stheraven    unordered_multimap(initializer_list<value_type> __il, size_type __n,
1533227825Stheraven                       const hasher& __hf = hasher(),
1534227825Stheraven                       const key_equal& __eql = key_equal());
1535227825Stheraven    unordered_multimap(initializer_list<value_type> __il, size_type __n,
1536227825Stheraven                       const hasher& __hf, const key_equal& __eql,
1537227825Stheraven                       const allocator_type& __a);
1538227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1539261272Sdim#if _LIBCPP_STD_VER > 11
1540261272Sdim    _LIBCPP_INLINE_VISIBILITY
1541261272Sdim    unordered_multimap(size_type __n, const allocator_type& __a)
1542261272Sdim      : unordered_multimap(__n, hasher(), key_equal(), __a) {}
1543261272Sdim    _LIBCPP_INLINE_VISIBILITY
1544261272Sdim    unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
1545261272Sdim      : unordered_multimap(__n, __hf, key_equal(), __a) {}
1546261272Sdim    template <class _InputIterator>
1547261272Sdim    _LIBCPP_INLINE_VISIBILITY
1548261272Sdim      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
1549261272Sdim      : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
1550261272Sdim    template <class _InputIterator>
1551261272Sdim    _LIBCPP_INLINE_VISIBILITY
1552261272Sdim      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, 
1553261272Sdim        const allocator_type& __a)
1554261272Sdim      : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
1555261272Sdim    _LIBCPP_INLINE_VISIBILITY
1556261272Sdim    unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1557261272Sdim      : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
1558261272Sdim    _LIBCPP_INLINE_VISIBILITY
1559261272Sdim    unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, 
1560261272Sdim      const allocator_type& __a)
1561261272Sdim      : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
1562261272Sdim#endif
1563227825Stheraven    // ~unordered_multimap() = default;
1564227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1565227825Stheraven    unordered_multimap& operator=(const unordered_multimap& __u)
1566227825Stheraven    {
1567253146Stheraven#if __cplusplus >= 201103L
1568227825Stheraven        __table_ = __u.__table_;
1569253146Stheraven#else
1570253146Stheraven        __table_.clear();
1571253146Stheraven        __table_.hash_function() = __u.__table_.hash_function();
1572253146Stheraven        __table_.key_eq() = __u.__table_.key_eq();
1573253146Stheraven        __table_.max_load_factor() = __u.__table_.max_load_factor();
1574253146Stheraven        __table_.__copy_assign_alloc(__u.__table_);
1575253146Stheraven        insert(__u.begin(), __u.end());
1576253146Stheraven#endif
1577227825Stheraven        return *this;
1578227825Stheraven    }
1579227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1580227825Stheraven    unordered_multimap& operator=(unordered_multimap&& __u)
1581227825Stheraven        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
1582227825Stheraven#endif
1583227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1584227825Stheraven    unordered_multimap& operator=(initializer_list<value_type> __il);
1585227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1586227825Stheraven
1587227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1588227825Stheraven    allocator_type get_allocator() const _NOEXCEPT
1589227825Stheraven        {return allocator_type(__table_.__node_alloc());}
1590227825Stheraven
1591227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1592227825Stheraven    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
1593227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1594227825Stheraven    size_type size() const _NOEXCEPT  {return __table_.size();}
1595227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1596227825Stheraven    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
1597227825Stheraven
1598227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1599227825Stheraven    iterator       begin() _NOEXCEPT        {return __table_.begin();}
1600227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1601227825Stheraven    iterator       end() _NOEXCEPT          {return __table_.end();}
1602227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1603227825Stheraven    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
1604227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1605227825Stheraven    const_iterator end()    const _NOEXCEPT {return __table_.end();}
1606227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1607227825Stheraven    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
1608227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1609227825Stheraven    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
1610227825Stheraven
1611227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1612227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1613227825Stheraven
1614241900Sdim    template <class... _Args>
1615241900Sdim        iterator emplace(_Args&&... __args);
1616227825Stheraven
1617241900Sdim    template <class... _Args>
1618241900Sdim        iterator emplace_hint(const_iterator __p, _Args&&... __args);
1619227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1620227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1621227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1622227825Stheraven    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
1623227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1624232924Stheraven    template <class _Pp,
1625232924Stheraven              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1626227825Stheraven        _LIBCPP_INLINE_VISIBILITY
1627232924Stheraven        iterator insert(_Pp&& __x)
1628232924Stheraven            {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));}
1629227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1630227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1631227825Stheraven    iterator insert(const_iterator __p, const value_type& __x)
1632227825Stheraven        {return __table_.__insert_multi(__p.__i_, __x);}
1633227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1634232924Stheraven    template <class _Pp,
1635232924Stheraven              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
1636227825Stheraven        _LIBCPP_INLINE_VISIBILITY
1637232924Stheraven        iterator insert(const_iterator __p, _Pp&& __x)
1638232924Stheraven            {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));}
1639227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1640227825Stheraven    template <class _InputIterator>
1641227825Stheraven        void insert(_InputIterator __first, _InputIterator __last);
1642227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1643227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1644227825Stheraven    void insert(initializer_list<value_type> __il)
1645227825Stheraven        {insert(__il.begin(), __il.end());}
1646227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1647227825Stheraven
1648227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1649227825Stheraven    iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
1650227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1651227825Stheraven    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
1652227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1653227825Stheraven    iterator erase(const_iterator __first, const_iterator __last)
1654227825Stheraven        {return __table_.erase(__first.__i_, __last.__i_);}
1655227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1656227825Stheraven    void clear() _NOEXCEPT {__table_.clear();}
1657227825Stheraven
1658227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1659227825Stheraven    void swap(unordered_multimap& __u)
1660227825Stheraven        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
1661227825Stheraven        {__table_.swap(__u.__table_);}
1662227825Stheraven
1663227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1664227825Stheraven    hasher hash_function() const
1665227825Stheraven        {return __table_.hash_function().hash_function();}
1666227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1667227825Stheraven    key_equal key_eq() const
1668227825Stheraven        {return __table_.key_eq().key_eq();}
1669227825Stheraven
1670227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1671227825Stheraven    iterator       find(const key_type& __k)       {return __table_.find(__k);}
1672227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1673227825Stheraven    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1674227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1675227825Stheraven    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
1676227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1677227825Stheraven    pair<iterator, iterator>             equal_range(const key_type& __k)
1678227825Stheraven        {return __table_.__equal_range_multi(__k);}
1679227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1680227825Stheraven    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
1681227825Stheraven        {return __table_.__equal_range_multi(__k);}
1682227825Stheraven
1683227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1684227825Stheraven    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
1685227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1686227825Stheraven    size_type max_bucket_count() const _NOEXCEPT
1687227825Stheraven        {return __table_.max_bucket_count();}
1688227825Stheraven
1689227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1690227825Stheraven    size_type bucket_size(size_type __n) const
1691227825Stheraven        {return __table_.bucket_size(__n);}
1692227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1693227825Stheraven    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
1694227825Stheraven
1695227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1696227825Stheraven    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
1697227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1698227825Stheraven    local_iterator       end(size_type __n)          {return __table_.end(__n);}
1699227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1700227825Stheraven    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
1701227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1702227825Stheraven    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
1703227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1704227825Stheraven    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
1705227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1706227825Stheraven    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
1707227825Stheraven
1708227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1709227825Stheraven    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
1710227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1711227825Stheraven    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
1712227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1713227825Stheraven    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
1714227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1715227825Stheraven    void rehash(size_type __n) {__table_.rehash(__n);}
1716227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1717227825Stheraven    void reserve(size_type __n) {__table_.reserve(__n);}
1718227825Stheraven
1719261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1720261272Sdim
1721261272Sdim    bool __dereferenceable(const const_iterator* __i) const
1722261272Sdim        {return __table_.__dereferenceable(&__i->__i_);}
1723261272Sdim    bool __decrementable(const const_iterator* __i) const
1724261272Sdim        {return __table_.__decrementable(&__i->__i_);}
1725261272Sdim    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1726261272Sdim        {return __table_.__addable(&__i->__i_, __n);}
1727261272Sdim    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1728261272Sdim        {return __table_.__addable(&__i->__i_, __n);}
1729261272Sdim
1730261272Sdim#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1731261272Sdim
1732227825Stheravenprivate:
1733241900Sdim#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1734241900Sdim    __node_holder __construct_node();
1735241900Sdim    template <class _A0>
1736253146Stheraven        __node_holder
1737241900Sdim         __construct_node(_A0&& __a0);
1738241900Sdim#ifndef _LIBCPP_HAS_NO_VARIADICS
1739241900Sdim    template <class _A0, class _A1, class ..._Args>
1740241900Sdim        __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
1741241900Sdim#endif  // _LIBCPP_HAS_NO_VARIADICS
1742241900Sdim#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1743227825Stheraven};
1744227825Stheraven
1745227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1746227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1747227825Stheraven        size_type __n, const hasher& __hf, const key_equal& __eql)
1748227825Stheraven    : __table_(__hf, __eql)
1749227825Stheraven{
1750261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1751261272Sdim    __get_db()->__insert_c(this);
1752261272Sdim#endif
1753227825Stheraven    __table_.rehash(__n);
1754227825Stheraven}
1755227825Stheraven
1756227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1757227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1758227825Stheraven        size_type __n, const hasher& __hf, const key_equal& __eql,
1759227825Stheraven        const allocator_type& __a)
1760227825Stheraven    : __table_(__hf, __eql, __a)
1761227825Stheraven{
1762261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1763261272Sdim    __get_db()->__insert_c(this);
1764261272Sdim#endif
1765227825Stheraven    __table_.rehash(__n);
1766227825Stheraven}
1767227825Stheraven
1768227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1769227825Stheraventemplate <class _InputIterator>
1770227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1771227825Stheraven        _InputIterator __first, _InputIterator __last)
1772227825Stheraven{
1773261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1774261272Sdim    __get_db()->__insert_c(this);
1775261272Sdim#endif
1776227825Stheraven    insert(__first, __last);
1777227825Stheraven}
1778227825Stheraven
1779227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1780227825Stheraventemplate <class _InputIterator>
1781227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1782227825Stheraven        _InputIterator __first, _InputIterator __last, size_type __n,
1783227825Stheraven        const hasher& __hf, const key_equal& __eql)
1784227825Stheraven    : __table_(__hf, __eql)
1785227825Stheraven{
1786261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1787261272Sdim    __get_db()->__insert_c(this);
1788261272Sdim#endif
1789227825Stheraven    __table_.rehash(__n);
1790227825Stheraven    insert(__first, __last);
1791227825Stheraven}
1792227825Stheraven
1793227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1794227825Stheraventemplate <class _InputIterator>
1795227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1796227825Stheraven        _InputIterator __first, _InputIterator __last, size_type __n,
1797227825Stheraven        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1798227825Stheraven    : __table_(__hf, __eql, __a)
1799227825Stheraven{
1800261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1801261272Sdim    __get_db()->__insert_c(this);
1802261272Sdim#endif
1803227825Stheraven    __table_.rehash(__n);
1804227825Stheraven    insert(__first, __last);
1805227825Stheraven}
1806227825Stheraven
1807227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1808227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1809227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1810227825Stheraven        const allocator_type& __a)
1811227825Stheraven    : __table_(__a)
1812227825Stheraven{
1813261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1814261272Sdim    __get_db()->__insert_c(this);
1815261272Sdim#endif
1816227825Stheraven}
1817227825Stheraven
1818227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1819227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1820227825Stheraven        const unordered_multimap& __u)
1821227825Stheraven    : __table_(__u.__table_)
1822227825Stheraven{
1823261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1824261272Sdim    __get_db()->__insert_c(this);
1825261272Sdim#endif
1826227825Stheraven    __table_.rehash(__u.bucket_count());
1827227825Stheraven    insert(__u.begin(), __u.end());
1828227825Stheraven}
1829227825Stheraven
1830227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1831227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1832227825Stheraven        const unordered_multimap& __u, const allocator_type& __a)
1833227825Stheraven    : __table_(__u.__table_, __a)
1834227825Stheraven{
1835261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1836261272Sdim    __get_db()->__insert_c(this);
1837261272Sdim#endif
1838227825Stheraven    __table_.rehash(__u.bucket_count());
1839227825Stheraven    insert(__u.begin(), __u.end());
1840227825Stheraven}
1841227825Stheraven
1842227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1843227825Stheraven
1844227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1845227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1846227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1847227825Stheraven        unordered_multimap&& __u)
1848227825Stheraven    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1849227825Stheraven    : __table_(_VSTD::move(__u.__table_))
1850227825Stheraven{
1851261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1852261272Sdim    __get_db()->__insert_c(this);
1853261272Sdim    __get_db()->swap(this, &__u);
1854261272Sdim#endif
1855227825Stheraven}
1856227825Stheraven
1857227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1858227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1859227825Stheraven        unordered_multimap&& __u, const allocator_type& __a)
1860227825Stheraven    : __table_(_VSTD::move(__u.__table_), __a)
1861227825Stheraven{
1862261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1863261272Sdim    __get_db()->__insert_c(this);
1864261272Sdim#endif
1865227825Stheraven    if (__a != __u.get_allocator())
1866227825Stheraven    {
1867227825Stheraven        iterator __i = __u.begin();
1868227825Stheraven        while (__u.size() != 0)
1869261272Sdim        {
1870227825Stheraven            __table_.__insert_multi(
1871227825Stheraven                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
1872227825Stheraven                                   );
1873261272Sdim        }
1874227825Stheraven    }
1875261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1876261272Sdim    else
1877261272Sdim        __get_db()->swap(this, &__u);
1878261272Sdim#endif
1879227825Stheraven}
1880227825Stheraven
1881227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1882227825Stheraven
1883227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1884227825Stheraven
1885227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1886227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1887227825Stheraven        initializer_list<value_type> __il)
1888227825Stheraven{
1889261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1890261272Sdim    __get_db()->__insert_c(this);
1891261272Sdim#endif
1892227825Stheraven    insert(__il.begin(), __il.end());
1893227825Stheraven}
1894227825Stheraven
1895227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1896227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1897227825Stheraven        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1898227825Stheraven        const key_equal& __eql)
1899227825Stheraven    : __table_(__hf, __eql)
1900227825Stheraven{
1901261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1902261272Sdim    __get_db()->__insert_c(this);
1903261272Sdim#endif
1904227825Stheraven    __table_.rehash(__n);
1905227825Stheraven    insert(__il.begin(), __il.end());
1906227825Stheraven}
1907227825Stheraven
1908227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1909227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
1910227825Stheraven        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1911227825Stheraven        const key_equal& __eql, const allocator_type& __a)
1912227825Stheraven    : __table_(__hf, __eql, __a)
1913227825Stheraven{
1914261272Sdim#if _LIBCPP_DEBUG_LEVEL >= 2
1915261272Sdim    __get_db()->__insert_c(this);
1916261272Sdim#endif
1917227825Stheraven    __table_.rehash(__n);
1918227825Stheraven    insert(__il.begin(), __il.end());
1919227825Stheraven}
1920227825Stheraven
1921227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1922227825Stheraven
1923227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1924227825Stheraven
1925227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1926227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1927227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
1928227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u)
1929227825Stheraven    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
1930227825Stheraven{
1931227825Stheraven    __table_ = _VSTD::move(__u.__table_);
1932227825Stheraven    return *this;
1933227825Stheraven}
1934227825Stheraven
1935227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1936227825Stheraven
1937227825Stheraven#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1938227825Stheraven
1939227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1940227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1941227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
1942227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
1943227825Stheraven        initializer_list<value_type> __il)
1944227825Stheraven{
1945227825Stheraven    __table_.__assign_multi(__il.begin(), __il.end());
1946227825Stheraven    return *this;
1947227825Stheraven}
1948227825Stheraven
1949227825Stheraven#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1950227825Stheraven
1951227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1952227825Stheraven
1953227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1954227825Stheraventypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1955241900Sdimunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
1956227825Stheraven{
1957227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
1958232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1959241900Sdim    __node_traits::construct(__na, _VSTD::addressof(__h->__value_));
1960227825Stheraven    __h.get_deleter().__first_constructed = true;
1961227825Stheraven    __h.get_deleter().__second_constructed = true;
1962227825Stheraven    return __h;
1963227825Stheraven}
1964227825Stheraven
1965227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1966241900Sdimtemplate <class _A0>
1967253146Stheraventypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1968227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
1969227825Stheraven{
1970227825Stheraven    __node_allocator& __na = __table_.__node_alloc();
1971232924Stheraven    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1972227825Stheraven    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
1973227825Stheraven                             _VSTD::forward<_A0>(__a0));
1974227825Stheraven    __h.get_deleter().__first_constructed = true;
1975227825Stheraven    __h.get_deleter().__second_constructed = true;
1976227825Stheraven    return __h;
1977227825Stheraven}
1978227825Stheraven
1979227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
1980227825Stheraven
1981227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1982241900Sdimtemplate <class _A0, class _A1, class ..._Args>
1983241900Sdimtypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1984241900Sdimunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(
1985241900Sdim        _A0&& __a0, _A1&& __a1, _Args&&... __args)
1986241900Sdim{
1987241900Sdim    __node_allocator& __na = __table_.__node_alloc();
1988241900Sdim    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1989241900Sdim    __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
1990241900Sdim                             _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
1991241900Sdim                             _VSTD::forward<_Args>(__args)...);
1992241900Sdim    __h.get_deleter().__first_constructed = true;
1993241900Sdim    __h.get_deleter().__second_constructed = true;
1994241900Sdim    return __h;
1995241900Sdim}
1996241900Sdim
1997241900Sdimtemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1998241900Sdimtemplate <class... _Args>
1999227825Stheraventypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator
2000241900Sdimunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
2001227825Stheraven{
2002241900Sdim    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
2003227825Stheraven    iterator __r = __table_.__node_insert_multi(__h.get());
2004227825Stheraven    __h.release();
2005227825Stheraven    return __r;
2006227825Stheraven}
2007227825Stheraven
2008227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2009241900Sdimtemplate <class... _Args>
2010227825Stheraventypename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator
2011227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace_hint(
2012241900Sdim        const_iterator __p, _Args&&... __args)
2013227825Stheraven{
2014241900Sdim    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
2015227825Stheraven    iterator __r = __table_.__node_insert_multi(__p.__i_, __h.get());
2016227825Stheraven    __h.release();
2017227825Stheraven    return __r;
2018227825Stheraven}
2019227825Stheraven
2020227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
2021227825Stheraven#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2022227825Stheraven
2023227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2024227825Stheraventemplate <class _InputIterator>
2025227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2026227825Stheravenvoid
2027227825Stheravenunordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
2028227825Stheraven                                                            _InputIterator __last)
2029227825Stheraven{
2030227825Stheraven    for (; __first != __last; ++__first)
2031227825Stheraven        __table_.__insert_multi(*__first);
2032227825Stheraven}
2033227825Stheraven
2034227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2035227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2036227825Stheravenvoid
2037227825Stheravenswap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2038227825Stheraven     unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2039227825Stheraven    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
2040227825Stheraven{
2041227825Stheraven    __x.swap(__y);
2042227825Stheraven}
2043227825Stheraven
2044227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2045227825Stheravenbool
2046227825Stheravenoperator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2047227825Stheraven           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2048227825Stheraven{
2049227825Stheraven    if (__x.size() != __y.size())
2050227825Stheraven        return false;
2051227825Stheraven    typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
2052227825Stheraven                                                                 const_iterator;
2053227825Stheraven    typedef pair<const_iterator, const_iterator> _EqRng;
2054227825Stheraven    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
2055227825Stheraven    {
2056227825Stheraven        _EqRng __xeq = __x.equal_range(__i->first);
2057227825Stheraven        _EqRng __yeq = __y.equal_range(__i->first);
2058227825Stheraven        if (_VSTD::distance(__xeq.first, __xeq.second) !=
2059227825Stheraven            _VSTD::distance(__yeq.first, __yeq.second) ||
2060227825Stheraven                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
2061227825Stheraven            return false;
2062227825Stheraven        __i = __xeq.second;
2063227825Stheraven    }
2064227825Stheraven    return true;
2065227825Stheraven}
2066227825Stheraven
2067227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2068227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
2069227825Stheravenbool
2070227825Stheravenoperator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2071227825Stheraven           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2072227825Stheraven{
2073227825Stheraven    return !(__x == __y);
2074227825Stheraven}
2075227825Stheraven
2076227825Stheraven_LIBCPP_END_NAMESPACE_STD
2077227825Stheraven
2078227825Stheraven#endif  // _LIBCPP_UNORDERED_MAP
2079