blob: adfb4cdb5e9ec5045ec1a93d29dd93e852e3db58 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===----------------------------- map ------------------------------------===//
3//
Howard Hinnantc566dc32010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantc51e1022010-05-11 19:42:16 +00005//
Howard Hinnantee11c312010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc51e1022010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_MAP
12#define _LIBCPP_MAP
13
14/*
15
16 map synopsis
17
18namespace std
19{
20
21template <class Key, class T, class Compare = less<Key>,
22 class Allocator = allocator<pair<const Key, T>>>
23class map
24{
25public:
26 // types:
27 typedef Key key_type;
28 typedef T mapped_type;
29 typedef pair<const key_type, mapped_type> value_type;
30 typedef Compare key_compare;
31 typedef Allocator allocator_type;
32 typedef typename allocator_type::reference reference;
33 typedef typename allocator_type::const_reference const_reference;
34 typedef typename allocator_type::pointer pointer;
35 typedef typename allocator_type::const_pointer const_pointer;
36 typedef typename allocator_type::size_type size_type;
37 typedef typename allocator_type::difference_type difference_type;
38
39 typedef implementation-defined iterator;
40 typedef implementation-defined const_iterator;
41 typedef std::reverse_iterator<iterator> reverse_iterator;
42 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
43
44 class value_compare
45 : public binary_function<value_type, value_type, bool>
46 {
47 friend class map;
48 protected:
49 key_compare comp;
50
51 value_compare(key_compare c);
52 public:
53 bool operator()(const value_type& x, const value_type& y) const;
54 };
55
56 // construct/copy/destroy:
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +000057 map()
58 noexcept(
59 is_nothrow_default_constructible<allocator_type>::value &&
60 is_nothrow_default_constructible<key_compare>::value &&
61 is_nothrow_copy_constructible<key_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +000062 explicit map(const key_compare& comp);
63 map(const key_compare& comp, const allocator_type& a);
64 template <class InputIterator>
65 map(InputIterator first, InputIterator last,
66 const key_compare& comp = key_compare());
67 template <class InputIterator>
68 map(InputIterator first, InputIterator last,
69 const key_compare& comp, const allocator_type& a);
70 map(const map& m);
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +000071 map(map&& m)
72 noexcept(
73 is_nothrow_move_constructible<allocator_type>::value &&
74 is_nothrow_move_constructible<key_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +000075 explicit map(const allocator_type& a);
76 map(const map& m, const allocator_type& a);
77 map(map&& m, const allocator_type& a);
78 map(initializer_list<value_type> il, const key_compare& comp = key_compare());
79 map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
Marshall Clow300abfb2013-09-11 01:15:47 +000080 template <class InputIterator>
81 map(InputIterator first, InputIterator last, const allocator_type& a)
82 : map(first, last, Compare(), a) {} // C++14
83 map(initializer_list<value_type> il, const allocator_type& a)
84 : map(il, Compare(), a) {} // C++14
85 ~map();
Howard Hinnantc51e1022010-05-11 19:42:16 +000086
87 map& operator=(const map& m);
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +000088 map& operator=(map&& m)
89 noexcept(
90 allocator_type::propagate_on_container_move_assignment::value &&
91 is_nothrow_move_assignable<allocator_type>::value &&
Howard Hinnantf95f4f52011-06-04 15:22:34 +000092 is_nothrow_move_assignable<key_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +000093 map& operator=(initializer_list<value_type> il);
94
95 // iterators:
Howard Hinnantf95f4f52011-06-04 15:22:34 +000096 iterator begin() noexcept;
97 const_iterator begin() const noexcept;
98 iterator end() noexcept;
99 const_iterator end() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000100
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000101 reverse_iterator rbegin() noexcept;
102 const_reverse_iterator rbegin() const noexcept;
103 reverse_iterator rend() noexcept;
104 const_reverse_iterator rend() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000105
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000106 const_iterator cbegin() const noexcept;
107 const_iterator cend() const noexcept;
108 const_reverse_iterator crbegin() const noexcept;
109 const_reverse_iterator crend() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000110
111 // capacity:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000112 bool empty() const noexcept;
113 size_type size() const noexcept;
114 size_type max_size() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000115
116 // element access:
117 mapped_type& operator[](const key_type& k);
118 mapped_type& operator[](key_type&& k);
119
120 mapped_type& at(const key_type& k);
121 const mapped_type& at(const key_type& k) const;
122
123 // modifiers:
124 template <class... Args>
125 pair<iterator, bool> emplace(Args&&... args);
126 template <class... Args>
127 iterator emplace_hint(const_iterator position, Args&&... args);
128 pair<iterator, bool> insert(const value_type& v);
129 template <class P>
130 pair<iterator, bool> insert(P&& p);
131 iterator insert(const_iterator position, const value_type& v);
132 template <class P>
133 iterator insert(const_iterator position, P&& p);
134 template <class InputIterator>
135 void insert(InputIterator first, InputIterator last);
136 void insert(initializer_list<value_type> il);
137
Marshall Clow3223db82015-07-07 03:37:33 +0000138 template <class... Args>
139 pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17
140 template <class... Args>
141 pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17
142 template <class... Args>
143 iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
144 template <class... Args>
145 iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
146 template <class M>
147 pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17
148 template <class M>
149 pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17
150 template <class M>
151 iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17
152 template <class M>
153 iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
154
Howard Hinnantc51e1022010-05-11 19:42:16 +0000155 iterator erase(const_iterator position);
Marshall Clow22ea5b82015-05-10 13:35:00 +0000156 iterator erase(iterator position); // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000157 size_type erase(const key_type& k);
158 iterator erase(const_iterator first, const_iterator last);
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000159 void clear() noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000160
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000161 void swap(map& m)
Marshall Clow8982dcd2015-07-13 20:04:56 +0000162 noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
163 __is_nothrow_swappable<key_compare>::value); // C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +0000164
165 // observers:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000166 allocator_type get_allocator() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000167 key_compare key_comp() const;
168 value_compare value_comp() const;
169
170 // map operations:
171 iterator find(const key_type& k);
172 const_iterator find(const key_type& k) const;
Marshall Clowebb57322013-08-13 22:18:47 +0000173 template<typename K>
174 iterator find(const K& x); // C++14
175 template<typename K>
176 const_iterator find(const K& x) const; // C++14
177 template<typename K>
Marshall Clowe6a5f522014-08-24 23:54:16 +0000178 size_type count(const K& x) const; // C++14
Marshall Clowebb57322013-08-13 22:18:47 +0000179
Howard Hinnantc51e1022010-05-11 19:42:16 +0000180 size_type count(const key_type& k) const;
181 iterator lower_bound(const key_type& k);
182 const_iterator lower_bound(const key_type& k) const;
Marshall Clowebb57322013-08-13 22:18:47 +0000183 template<typename K>
184 iterator lower_bound(const K& x); // C++14
185 template<typename K>
186 const_iterator lower_bound(const K& x) const; // C++14
187
Howard Hinnantc51e1022010-05-11 19:42:16 +0000188 iterator upper_bound(const key_type& k);
189 const_iterator upper_bound(const key_type& k) const;
Marshall Clowebb57322013-08-13 22:18:47 +0000190 template<typename K>
191 iterator upper_bound(const K& x); // C++14
192 template<typename K>
193 const_iterator upper_bound(const K& x) const; // C++14
194
Howard Hinnantc51e1022010-05-11 19:42:16 +0000195 pair<iterator,iterator> equal_range(const key_type& k);
196 pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
Marshall Clowebb57322013-08-13 22:18:47 +0000197 template<typename K>
198 pair<iterator,iterator> equal_range(const K& x); // C++14
199 template<typename K>
200 pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000201};
202
203template <class Key, class T, class Compare, class Allocator>
204bool
205operator==(const map<Key, T, Compare, Allocator>& x,
206 const map<Key, T, Compare, Allocator>& y);
207
208template <class Key, class T, class Compare, class Allocator>
209bool
210operator< (const map<Key, T, Compare, Allocator>& x,
211 const map<Key, T, Compare, Allocator>& y);
212
213template <class Key, class T, class Compare, class Allocator>
214bool
215operator!=(const map<Key, T, Compare, Allocator>& x,
216 const map<Key, T, Compare, Allocator>& y);
217
218template <class Key, class T, class Compare, class Allocator>
219bool
220operator> (const map<Key, T, Compare, Allocator>& x,
221 const map<Key, T, Compare, Allocator>& y);
222
223template <class Key, class T, class Compare, class Allocator>
224bool
225operator>=(const map<Key, T, Compare, Allocator>& x,
226 const map<Key, T, Compare, Allocator>& y);
227
228template <class Key, class T, class Compare, class Allocator>
229bool
230operator<=(const map<Key, T, Compare, Allocator>& x,
231 const map<Key, T, Compare, Allocator>& y);
232
233// specialized algorithms:
234template <class Key, class T, class Compare, class Allocator>
235void
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000236swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y)
237 noexcept(noexcept(x.swap(y)));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000238
239template <class Key, class T, class Compare = less<Key>,
240 class Allocator = allocator<pair<const Key, T>>>
241class multimap
242{
243public:
244 // types:
245 typedef Key key_type;
246 typedef T mapped_type;
247 typedef pair<const key_type,mapped_type> value_type;
248 typedef Compare key_compare;
249 typedef Allocator allocator_type;
250 typedef typename allocator_type::reference reference;
251 typedef typename allocator_type::const_reference const_reference;
252 typedef typename allocator_type::size_type size_type;
253 typedef typename allocator_type::difference_type difference_type;
254 typedef typename allocator_type::pointer pointer;
255 typedef typename allocator_type::const_pointer const_pointer;
256
257 typedef implementation-defined iterator;
258 typedef implementation-defined const_iterator;
259 typedef std::reverse_iterator<iterator> reverse_iterator;
260 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
261
262 class value_compare
263 : public binary_function<value_type,value_type,bool>
264 {
265 friend class multimap;
266 protected:
267 key_compare comp;
268 value_compare(key_compare c);
269 public:
270 bool operator()(const value_type& x, const value_type& y) const;
271 };
272
273 // construct/copy/destroy:
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000274 multimap()
275 noexcept(
276 is_nothrow_default_constructible<allocator_type>::value &&
277 is_nothrow_default_constructible<key_compare>::value &&
278 is_nothrow_copy_constructible<key_compare>::value);
279 explicit multimap(const key_compare& comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000280 multimap(const key_compare& comp, const allocator_type& a);
281 template <class InputIterator>
282 multimap(InputIterator first, InputIterator last, const key_compare& comp);
283 template <class InputIterator>
284 multimap(InputIterator first, InputIterator last, const key_compare& comp,
285 const allocator_type& a);
286 multimap(const multimap& m);
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000287 multimap(multimap&& m)
288 noexcept(
289 is_nothrow_move_constructible<allocator_type>::value &&
290 is_nothrow_move_constructible<key_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000291 explicit multimap(const allocator_type& a);
292 multimap(const multimap& m, const allocator_type& a);
293 multimap(multimap&& m, const allocator_type& a);
294 multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
295 multimap(initializer_list<value_type> il, const key_compare& comp,
296 const allocator_type& a);
Marshall Clow300abfb2013-09-11 01:15:47 +0000297 template <class InputIterator>
298 multimap(InputIterator first, InputIterator last, const allocator_type& a)
299 : multimap(first, last, Compare(), a) {} // C++14
300 multimap(initializer_list<value_type> il, const allocator_type& a)
301 : multimap(il, Compare(), a) {} // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000302 ~multimap();
303
304 multimap& operator=(const multimap& m);
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000305 multimap& operator=(multimap&& m)
306 noexcept(
307 allocator_type::propagate_on_container_move_assignment::value &&
308 is_nothrow_move_assignable<allocator_type>::value &&
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000309 is_nothrow_move_assignable<key_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000310 multimap& operator=(initializer_list<value_type> il);
311
312 // iterators:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000313 iterator begin() noexcept;
314 const_iterator begin() const noexcept;
315 iterator end() noexcept;
316 const_iterator end() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000317
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000318 reverse_iterator rbegin() noexcept;
319 const_reverse_iterator rbegin() const noexcept;
320 reverse_iterator rend() noexcept;
321 const_reverse_iterator rend() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000322
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000323 const_iterator cbegin() const noexcept;
324 const_iterator cend() const noexcept;
325 const_reverse_iterator crbegin() const noexcept;
326 const_reverse_iterator crend() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000327
328 // capacity:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000329 bool empty() const noexcept;
330 size_type size() const noexcept;
331 size_type max_size() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000332
333 // modifiers:
334 template <class... Args>
335 iterator emplace(Args&&... args);
336 template <class... Args>
337 iterator emplace_hint(const_iterator position, Args&&... args);
338 iterator insert(const value_type& v);
339 template <class P>
340 iterator insert(P&& p);
341 iterator insert(const_iterator position, const value_type& v);
342 template <class P>
343 iterator insert(const_iterator position, P&& p);
344 template <class InputIterator>
345 void insert(InputIterator first, InputIterator last);
346 void insert(initializer_list<value_type> il);
347
348 iterator erase(const_iterator position);
Marshall Clow22ea5b82015-05-10 13:35:00 +0000349 iterator erase(iterator position); // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000350 size_type erase(const key_type& k);
351 iterator erase(const_iterator first, const_iterator last);
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000352 void clear() noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000353
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000354 void swap(multimap& m)
Marshall Clow8982dcd2015-07-13 20:04:56 +0000355 noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
356 __is_nothrow_swappable<key_compare>::value); // C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +0000357
358 // observers:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000359 allocator_type get_allocator() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000360 key_compare key_comp() const;
361 value_compare value_comp() const;
362
363 // map operations:
364 iterator find(const key_type& k);
365 const_iterator find(const key_type& k) const;
Marshall Clowebb57322013-08-13 22:18:47 +0000366 template<typename K>
367 iterator find(const K& x); // C++14
368 template<typename K>
369 const_iterator find(const K& x) const; // C++14
370 template<typename K>
Marshall Clowe6a5f522014-08-24 23:54:16 +0000371 size_type count(const K& x) const; // C++14
Marshall Clowebb57322013-08-13 22:18:47 +0000372
Howard Hinnantc51e1022010-05-11 19:42:16 +0000373 size_type count(const key_type& k) const;
374 iterator lower_bound(const key_type& k);
375 const_iterator lower_bound(const key_type& k) const;
Marshall Clowebb57322013-08-13 22:18:47 +0000376 template<typename K>
377 iterator lower_bound(const K& x); // C++14
378 template<typename K>
379 const_iterator lower_bound(const K& x) const; // C++14
380
Howard Hinnantc51e1022010-05-11 19:42:16 +0000381 iterator upper_bound(const key_type& k);
382 const_iterator upper_bound(const key_type& k) const;
Marshall Clowebb57322013-08-13 22:18:47 +0000383 template<typename K>
384 iterator upper_bound(const K& x); // C++14
385 template<typename K>
386 const_iterator upper_bound(const K& x) const; // C++14
387
Howard Hinnantc51e1022010-05-11 19:42:16 +0000388 pair<iterator,iterator> equal_range(const key_type& k);
389 pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
Marshall Clowebb57322013-08-13 22:18:47 +0000390 template<typename K>
391 pair<iterator,iterator> equal_range(const K& x); // C++14
392 template<typename K>
393 pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000394};
395
396template <class Key, class T, class Compare, class Allocator>
397bool
398operator==(const multimap<Key, T, Compare, Allocator>& x,
399 const multimap<Key, T, Compare, Allocator>& y);
400
401template <class Key, class T, class Compare, class Allocator>
402bool
403operator< (const multimap<Key, T, Compare, Allocator>& x,
404 const multimap<Key, T, Compare, Allocator>& y);
405
406template <class Key, class T, class Compare, class Allocator>
407bool
408operator!=(const multimap<Key, T, Compare, Allocator>& x,
409 const multimap<Key, T, Compare, Allocator>& y);
410
411template <class Key, class T, class Compare, class Allocator>
412bool
413operator> (const multimap<Key, T, Compare, Allocator>& x,
414 const multimap<Key, T, Compare, Allocator>& y);
415
416template <class Key, class T, class Compare, class Allocator>
417bool
418operator>=(const multimap<Key, T, Compare, Allocator>& x,
419 const multimap<Key, T, Compare, Allocator>& y);
420
421template <class Key, class T, class Compare, class Allocator>
422bool
423operator<=(const multimap<Key, T, Compare, Allocator>& x,
424 const multimap<Key, T, Compare, Allocator>& y);
425
426// specialized algorithms:
427template <class Key, class T, class Compare, class Allocator>
428void
429swap(multimap<Key, T, Compare, Allocator>& x,
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000430 multimap<Key, T, Compare, Allocator>& y)
431 noexcept(noexcept(x.swap(y)));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000432
433} // std
434
435*/
436
437#include <__config>
438#include <__tree>
439#include <iterator>
440#include <memory>
441#include <utility>
442#include <functional>
443#include <initializer_list>
Eric Fiselierf7394302015-06-13 07:08:02 +0000444#include <type_traits>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000445
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000446#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000447#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000448#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000449
450_LIBCPP_BEGIN_NAMESPACE_STD
451
Eric Fiselierf7394302015-06-13 07:08:02 +0000452template <class _Key, class _CP, class _Compare,
453 bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value
Howard Hinnantd0aabf82011-12-11 20:31:33 +0000454 >
Howard Hinnantc51e1022010-05-11 19:42:16 +0000455class __map_value_compare
456 : private _Compare
457{
Howard Hinnantc51e1022010-05-11 19:42:16 +0000458public:
Howard Hinnant756c69b2010-09-22 16:48:34 +0000459 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000460 __map_value_compare()
461 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
462 : _Compare() {}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000463 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000464 __map_value_compare(_Compare c)
465 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
466 : _Compare(c) {}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000467 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000468 const _Compare& key_comp() const _NOEXCEPT {return *this;}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000469 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000470 bool operator()(const _CP& __x, const _CP& __y) const
Howard Hinnant90b91592013-07-05 18:06:00 +0000471 {return static_cast<const _Compare&>(*this)(__x.__cc.first, __y.__cc.first);}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000472 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000473 bool operator()(const _CP& __x, const _Key& __y) const
Howard Hinnant90b91592013-07-05 18:06:00 +0000474 {return static_cast<const _Compare&>(*this)(__x.__cc.first, __y);}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000475 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000476 bool operator()(const _Key& __x, const _CP& __y) const
Howard Hinnant90b91592013-07-05 18:06:00 +0000477 {return static_cast<const _Compare&>(*this)(__x, __y.__cc.first);}
Marshall Clow8982dcd2015-07-13 20:04:56 +0000478 void swap(__map_value_compare&__y)
479 _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
480 {
481 using _VSTD::swap;
482 swap(static_cast<const _Compare&>(*this), static_cast<const _Compare&>(__y));
483 }
Marshall Clowebb57322013-08-13 22:18:47 +0000484
485#if _LIBCPP_STD_VER > 11
486 template <typename _K2>
487 _LIBCPP_INLINE_VISIBILITY
488 typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
489 operator () ( const _K2& __x, const _CP& __y ) const
490 {return static_cast<const _Compare&>(*this) (__x, __y.__cc.first);}
491
492 template <typename _K2>
493 _LIBCPP_INLINE_VISIBILITY
494 typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
495 operator () (const _CP& __x, const _K2& __y) const
496 {return static_cast<const _Compare&>(*this) (__x.__cc.first, __y);}
497#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000498};
499
Howard Hinnant90b91592013-07-05 18:06:00 +0000500template <class _Key, class _CP, class _Compare>
501class __map_value_compare<_Key, _CP, _Compare, false>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000502{
503 _Compare comp;
504
Howard Hinnantc51e1022010-05-11 19:42:16 +0000505public:
Howard Hinnant756c69b2010-09-22 16:48:34 +0000506 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000507 __map_value_compare()
508 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
509 : comp() {}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000510 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000511 __map_value_compare(_Compare c)
512 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
513 : comp(c) {}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000514 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000515 const _Compare& key_comp() const _NOEXCEPT {return comp;}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000516
Howard Hinnant756c69b2010-09-22 16:48:34 +0000517 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000518 bool operator()(const _CP& __x, const _CP& __y) const
Howard Hinnant90b91592013-07-05 18:06:00 +0000519 {return comp(__x.__cc.first, __y.__cc.first);}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000520 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000521 bool operator()(const _CP& __x, const _Key& __y) const
Howard Hinnant90b91592013-07-05 18:06:00 +0000522 {return comp(__x.__cc.first, __y);}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000523 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000524 bool operator()(const _Key& __x, const _CP& __y) const
Howard Hinnant90b91592013-07-05 18:06:00 +0000525 {return comp(__x, __y.__cc.first);}
Marshall Clow8982dcd2015-07-13 20:04:56 +0000526 void swap(__map_value_compare&__y)
527 _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
528 {
529 using _VSTD::swap;
530 swap(comp, __y.comp);
531 }
532
Marshall Clowebb57322013-08-13 22:18:47 +0000533#if _LIBCPP_STD_VER > 11
534 template <typename _K2>
535 _LIBCPP_INLINE_VISIBILITY
536 typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
537 operator () ( const _K2& __x, const _CP& __y ) const
538 {return comp (__x, __y.__cc.first);}
539
540 template <typename _K2>
541 _LIBCPP_INLINE_VISIBILITY
542 typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
543 operator () (const _CP& __x, const _K2& __y) const
544 {return comp (__x.__cc.first, __y);}
545#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000546};
547
Marshall Clow8982dcd2015-07-13 20:04:56 +0000548template <class _Key, class _CP, class _Compare, bool __b>
549inline _LIBCPP_INLINE_VISIBILITY
550void
551swap(__map_value_compare<_Key, _CP, _Compare, __b>& __x,
552 __map_value_compare<_Key, _CP, _Compare, __b>& __y)
553 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
554{
555 __x.swap(__y);
556}
557
Howard Hinnantc51e1022010-05-11 19:42:16 +0000558template <class _Allocator>
559class __map_node_destructor
560{
561 typedef _Allocator allocator_type;
562 typedef allocator_traits<allocator_type> __alloc_traits;
563 typedef typename __alloc_traits::value_type::value_type value_type;
564public:
565 typedef typename __alloc_traits::pointer pointer;
566private:
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000567 typedef typename value_type::value_type::first_type first_type;
568 typedef typename value_type::value_type::second_type second_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000569
570 allocator_type& __na_;
571
572 __map_node_destructor& operator=(const __map_node_destructor&);
573
574public:
575 bool __first_constructed;
576 bool __second_constructed;
577
Howard Hinnant756c69b2010-09-22 16:48:34 +0000578 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000579 explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT
Howard Hinnantc51e1022010-05-11 19:42:16 +0000580 : __na_(__na),
581 __first_constructed(false),
582 __second_constructed(false)
583 {}
584
Howard Hinnant74279a52010-09-04 23:28:19 +0000585#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant756c69b2010-09-22 16:48:34 +0000586 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000587 __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT
Howard Hinnantc51e1022010-05-11 19:42:16 +0000588 : __na_(__x.__na_),
589 __first_constructed(__x.__value_constructed),
590 __second_constructed(__x.__value_constructed)
591 {
592 __x.__value_constructed = false;
593 }
Howard Hinnant5dc89112010-09-04 23:46:48 +0000594#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +0000595
Howard Hinnant756c69b2010-09-22 16:48:34 +0000596 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000597 void operator()(pointer __p) _NOEXCEPT
Howard Hinnantc51e1022010-05-11 19:42:16 +0000598 {
599 if (__second_constructed)
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000600 __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000601 if (__first_constructed)
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000602 __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000603 if (__p)
604 __alloc_traits::deallocate(__na_, __p, 1);
605 }
606};
607
Howard Hinnant944510a2011-06-14 19:58:17 +0000608template <class _Key, class _Tp, class _Compare, class _Allocator>
609 class map;
610template <class _Key, class _Tp, class _Compare, class _Allocator>
611 class multimap;
612template <class _TreeIterator> class __map_const_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000613
Howard Hinnant89f8b792013-09-30 19:08:22 +0000614#if __cplusplus >= 201103L
615
616template <class _Key, class _Tp>
617union __value_type
618{
619 typedef _Key key_type;
620 typedef _Tp mapped_type;
621 typedef pair<const key_type, mapped_type> value_type;
622 typedef pair<key_type, mapped_type> __nc_value_type;
623
624 value_type __cc;
625 __nc_value_type __nc;
626
627 template <class ..._Args>
628 _LIBCPP_INLINE_VISIBILITY
629 __value_type(_Args&& ...__args)
630 : __cc(std::forward<_Args>(__args)...) {}
631
632 _LIBCPP_INLINE_VISIBILITY
633 __value_type(const __value_type& __v)
634 : __cc(__v.__cc) {}
635
636 _LIBCPP_INLINE_VISIBILITY
637 __value_type(__value_type& __v)
638 : __cc(__v.__cc) {}
639
640 _LIBCPP_INLINE_VISIBILITY
641 __value_type(__value_type&& __v)
642 : __nc(std::move(__v.__nc)) {}
643
644 _LIBCPP_INLINE_VISIBILITY
645 __value_type& operator=(const __value_type& __v)
646 {__nc = __v.__cc; return *this;}
647
648 _LIBCPP_INLINE_VISIBILITY
649 __value_type& operator=(__value_type&& __v)
650 {__nc = std::move(__v.__nc); return *this;}
651
652 _LIBCPP_INLINE_VISIBILITY
653 ~__value_type() {__cc.~value_type();}
654};
655
656#else
657
658template <class _Key, class _Tp>
659struct __value_type
660{
661 typedef _Key key_type;
662 typedef _Tp mapped_type;
663 typedef pair<const key_type, mapped_type> value_type;
664
665 value_type __cc;
666
667 _LIBCPP_INLINE_VISIBILITY
668 __value_type() {}
669
670 template <class _A0>
671 _LIBCPP_INLINE_VISIBILITY
672 __value_type(const _A0& __a0)
673 : __cc(__a0) {}
674
675 template <class _A0, class _A1>
676 _LIBCPP_INLINE_VISIBILITY
677 __value_type(const _A0& __a0, const _A1& __a1)
678 : __cc(__a0, __a1) {}
679};
680
681#endif
682
Eric Fiselier44f9fd02015-03-03 20:10:01 +0000683template <class _Tp>
684struct __extract_key_value_types;
685
686template <class _Key, class _Tp>
687struct __extract_key_value_types<__value_type<_Key, _Tp> >
688{
689 typedef _Key const __key_type;
690 typedef _Tp __mapped_type;
691};
692
Howard Hinnantc51e1022010-05-11 19:42:16 +0000693template <class _TreeIterator>
Howard Hinnanta37d3cf2013-08-12 18:38:34 +0000694class _LIBCPP_TYPE_VIS_ONLY __map_iterator
Howard Hinnantc51e1022010-05-11 19:42:16 +0000695{
696 _TreeIterator __i_;
697
698 typedef typename _TreeIterator::__pointer_traits __pointer_traits;
Eric Fiselier44f9fd02015-03-03 20:10:01 +0000699 typedef typename _TreeIterator::value_type __value_type;
700 typedef typename __extract_key_value_types<__value_type>::__key_type __key_type;
701 typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000702public:
703 typedef bidirectional_iterator_tag iterator_category;
Howard Hinnantb2e8a422011-02-27 18:02:02 +0000704 typedef pair<__key_type, __mapped_type> value_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000705 typedef typename _TreeIterator::difference_type difference_type;
706 typedef value_type& reference;
707 typedef typename __pointer_traits::template
708#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
709 rebind<value_type>
710#else
711 rebind<value_type>::other
712#endif
713 pointer;
714
Howard Hinnant756c69b2010-09-22 16:48:34 +0000715 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000716 __map_iterator() _NOEXCEPT {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000717
Howard Hinnant756c69b2010-09-22 16:48:34 +0000718 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000719 __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000720
Howard Hinnant756c69b2010-09-22 16:48:34 +0000721 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000722 reference operator*() const {return __i_->__cc;}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000723 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000724 pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000725
Howard Hinnant756c69b2010-09-22 16:48:34 +0000726 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000727 __map_iterator& operator++() {++__i_; return *this;}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000728 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000729 __map_iterator operator++(int)
730 {
731 __map_iterator __t(*this);
732 ++(*this);
733 return __t;
734 }
735
Howard Hinnant756c69b2010-09-22 16:48:34 +0000736 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000737 __map_iterator& operator--() {--__i_; return *this;}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000738 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000739 __map_iterator operator--(int)
740 {
741 __map_iterator __t(*this);
742 --(*this);
743 return __t;
744 }
745
Howard Hinnant756c69b2010-09-22 16:48:34 +0000746 friend _LIBCPP_INLINE_VISIBILITY
747 bool operator==(const __map_iterator& __x, const __map_iterator& __y)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000748 {return __x.__i_ == __y.__i_;}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000749 friend
750 _LIBCPP_INLINE_VISIBILITY
751 bool operator!=(const __map_iterator& __x, const __map_iterator& __y)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000752 {return __x.__i_ != __y.__i_;}
753
Howard Hinnanta37d3cf2013-08-12 18:38:34 +0000754 template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
755 template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
756 template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000757};
758
759template <class _TreeIterator>
Howard Hinnanta37d3cf2013-08-12 18:38:34 +0000760class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator
Howard Hinnantc51e1022010-05-11 19:42:16 +0000761{
762 _TreeIterator __i_;
763
764 typedef typename _TreeIterator::__pointer_traits __pointer_traits;
Eric Fiselier44f9fd02015-03-03 20:10:01 +0000765 typedef typename _TreeIterator::value_type __value_type;
766 typedef typename __extract_key_value_types<__value_type>::__key_type __key_type;
767 typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000768public:
769 typedef bidirectional_iterator_tag iterator_category;
Howard Hinnantb2e8a422011-02-27 18:02:02 +0000770 typedef pair<__key_type, __mapped_type> value_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000771 typedef typename _TreeIterator::difference_type difference_type;
772 typedef const value_type& reference;
773 typedef typename __pointer_traits::template
774#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Howard Hinnant73f3c8a2011-04-11 02:18:41 +0000775 rebind<const value_type>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000776#else
Howard Hinnant73f3c8a2011-04-11 02:18:41 +0000777 rebind<const value_type>::other
Howard Hinnantc51e1022010-05-11 19:42:16 +0000778#endif
779 pointer;
780
Howard Hinnant756c69b2010-09-22 16:48:34 +0000781 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000782 __map_const_iterator() _NOEXCEPT {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000783
Howard Hinnant756c69b2010-09-22 16:48:34 +0000784 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000785 __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000786 _LIBCPP_INLINE_VISIBILITY
Eric Fiselier44f9fd02015-03-03 20:10:01 +0000787 __map_const_iterator(__map_iterator<
788 typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT
789 : __i_(__i.__i_) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000790
Howard Hinnant756c69b2010-09-22 16:48:34 +0000791 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000792 reference operator*() const {return __i_->__cc;}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000793 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000794 pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000795
Howard Hinnant756c69b2010-09-22 16:48:34 +0000796 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000797 __map_const_iterator& operator++() {++__i_; return *this;}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000798 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000799 __map_const_iterator operator++(int)
800 {
801 __map_const_iterator __t(*this);
802 ++(*this);
803 return __t;
804 }
805
Howard Hinnant756c69b2010-09-22 16:48:34 +0000806 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000807 __map_const_iterator& operator--() {--__i_; return *this;}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000808 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000809 __map_const_iterator operator--(int)
810 {
811 __map_const_iterator __t(*this);
812 --(*this);
813 return __t;
814 }
815
Howard Hinnant756c69b2010-09-22 16:48:34 +0000816 friend _LIBCPP_INLINE_VISIBILITY
817 bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000818 {return __x.__i_ == __y.__i_;}
Howard Hinnant756c69b2010-09-22 16:48:34 +0000819 friend _LIBCPP_INLINE_VISIBILITY
820 bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000821 {return __x.__i_ != __y.__i_;}
822
Howard Hinnanta37d3cf2013-08-12 18:38:34 +0000823 template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
824 template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
825 template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000826};
827
828template <class _Key, class _Tp, class _Compare = less<_Key>,
829 class _Allocator = allocator<pair<const _Key, _Tp> > >
Howard Hinnanta37d3cf2013-08-12 18:38:34 +0000830class _LIBCPP_TYPE_VIS_ONLY map
Howard Hinnantc51e1022010-05-11 19:42:16 +0000831{
832public:
833 // types:
834 typedef _Key key_type;
835 typedef _Tp mapped_type;
836 typedef pair<const key_type, mapped_type> value_type;
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000837 typedef pair<key_type, mapped_type> __nc_value_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000838 typedef _Compare key_compare;
839 typedef _Allocator allocator_type;
840 typedef value_type& reference;
841 typedef const value_type& const_reference;
842
Marshall Clow5128cf32015-11-26 01:24:04 +0000843 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
844 "Allocator::value_type must be same type as value_type");
845
Howard Hinnanta37d3cf2013-08-12 18:38:34 +0000846 class _LIBCPP_TYPE_VIS_ONLY value_compare
Howard Hinnantc51e1022010-05-11 19:42:16 +0000847 : public binary_function<value_type, value_type, bool>
848 {
849 friend class map;
850 protected:
851 key_compare comp;
852
Howard Hinnant756c69b2010-09-22 16:48:34 +0000853 _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000854 public:
Howard Hinnant756c69b2010-09-22 16:48:34 +0000855 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000856 bool operator()(const value_type& __x, const value_type& __y) const
857 {return comp(__x.first, __y.first);}
858 };
859
860private:
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000861
Howard Hinnant89f8b792013-09-30 19:08:22 +0000862 typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
Howard Hinnant90b91592013-07-05 18:06:00 +0000863 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
Marshall Clow940e01c2015-04-07 05:21:38 +0000864 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
865 __value_type>::type __allocator_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000866 typedef __tree<__value_type, __vc, __allocator_type> __base;
867 typedef typename __base::__node_traits __node_traits;
868 typedef allocator_traits<allocator_type> __alloc_traits;
869
870 __base __tree_;
871
872public:
873 typedef typename __alloc_traits::pointer pointer;
874 typedef typename __alloc_traits::const_pointer const_pointer;
875 typedef typename __alloc_traits::size_type size_type;
876 typedef typename __alloc_traits::difference_type difference_type;
Eric Fiselier44f9fd02015-03-03 20:10:01 +0000877 typedef __map_iterator<typename __base::iterator> iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000878 typedef __map_const_iterator<typename __base::const_iterator> const_iterator;
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000879 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
880 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000881
Howard Hinnant756c69b2010-09-22 16:48:34 +0000882 _LIBCPP_INLINE_VISIBILITY
Marshall Clow7086a5a2014-03-10 04:50:10 +0000883 map()
884 _NOEXCEPT_(
885 is_nothrow_default_constructible<allocator_type>::value &&
886 is_nothrow_default_constructible<key_compare>::value &&
887 is_nothrow_copy_constructible<key_compare>::value)
888 : __tree_(__vc(key_compare())) {}
889
890 _LIBCPP_INLINE_VISIBILITY
891 explicit map(const key_compare& __comp)
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000892 _NOEXCEPT_(
893 is_nothrow_default_constructible<allocator_type>::value &&
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000894 is_nothrow_copy_constructible<key_compare>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000895 : __tree_(__vc(__comp)) {}
896
Howard Hinnant756c69b2010-09-22 16:48:34 +0000897 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000898 explicit map(const key_compare& __comp, const allocator_type& __a)
899 : __tree_(__vc(__comp), __a) {}
900
901 template <class _InputIterator>
Howard Hinnant756c69b2010-09-22 16:48:34 +0000902 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000903 map(_InputIterator __f, _InputIterator __l,
904 const key_compare& __comp = key_compare())
905 : __tree_(__vc(__comp))
906 {
907 insert(__f, __l);
908 }
909
910 template <class _InputIterator>
Howard Hinnant756c69b2010-09-22 16:48:34 +0000911 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000912 map(_InputIterator __f, _InputIterator __l,
913 const key_compare& __comp, const allocator_type& __a)
914 : __tree_(__vc(__comp), __a)
915 {
916 insert(__f, __l);
917 }
918
Marshall Clow300abfb2013-09-11 01:15:47 +0000919#if _LIBCPP_STD_VER > 11
920 template <class _InputIterator>
921 _LIBCPP_INLINE_VISIBILITY
922 map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
923 : map(__f, __l, key_compare(), __a) {}
924#endif
925
Howard Hinnant756c69b2010-09-22 16:48:34 +0000926 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000927 map(const map& __m)
928 : __tree_(__m.__tree_)
929 {
930 insert(__m.begin(), __m.end());
931 }
932
Howard Hinnantd3a657f2011-07-01 19:24:36 +0000933 _LIBCPP_INLINE_VISIBILITY
934 map& operator=(const map& __m)
935 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000936#if __cplusplus >= 201103L
Howard Hinnantd3a657f2011-07-01 19:24:36 +0000937 __tree_ = __m.__tree_;
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000938#else
Marshall Clowdb3cfcb2014-02-08 04:03:14 +0000939 if (this != &__m) {
940 __tree_.clear();
941 __tree_.value_comp() = __m.__tree_.value_comp();
942 __tree_.__copy_assign_alloc(__m.__tree_);
943 insert(__m.begin(), __m.end());
944 }
Howard Hinnant2d0046b2013-06-19 21:29:40 +0000945#endif
Howard Hinnantd3a657f2011-07-01 19:24:36 +0000946 return *this;
947 }
948
Howard Hinnant74279a52010-09-04 23:28:19 +0000949#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +0000950
Howard Hinnant756c69b2010-09-22 16:48:34 +0000951 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000952 map(map&& __m)
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +0000953 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000954 : __tree_(_VSTD::move(__m.__tree_))
Howard Hinnantc51e1022010-05-11 19:42:16 +0000955 {
956 }
957
958 map(map&& __m, const allocator_type& __a);
959
Howard Hinnant756c69b2010-09-22 16:48:34 +0000960 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant33711792011-08-12 21:56:02 +0000961 map& operator=(map&& __m)
962 _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
963 {
964 __tree_ = _VSTD::move(__m.__tree_);
965 return *this;
966 }
967
968#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
969
970#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
971
972 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000973 map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
974 : __tree_(__vc(__comp))
975 {
976 insert(__il.begin(), __il.end());
977 }
978
Howard Hinnant756c69b2010-09-22 16:48:34 +0000979 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000980 map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
981 : __tree_(__vc(__comp), __a)
982 {
983 insert(__il.begin(), __il.end());
984 }
985
Marshall Clow300abfb2013-09-11 01:15:47 +0000986#if _LIBCPP_STD_VER > 11
987 _LIBCPP_INLINE_VISIBILITY
988 map(initializer_list<value_type> __il, const allocator_type& __a)
989 : map(__il, key_compare(), __a) {}
990#endif
991
Howard Hinnant756c69b2010-09-22 16:48:34 +0000992 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000993 map& operator=(initializer_list<value_type> __il)
994 {
995 __tree_.__assign_unique(__il.begin(), __il.end());
996 return *this;
997 }
998
Howard Hinnant33711792011-08-12 21:56:02 +0000999#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantc51e1022010-05-11 19:42:16 +00001000
Howard Hinnant756c69b2010-09-22 16:48:34 +00001001 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001002 explicit map(const allocator_type& __a)
1003 : __tree_(__a)
1004 {
1005 }
1006
Howard Hinnant756c69b2010-09-22 16:48:34 +00001007 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001008 map(const map& __m, const allocator_type& __a)
1009 : __tree_(__m.__tree_.value_comp(), __a)
1010 {
1011 insert(__m.begin(), __m.end());
1012 }
1013
Howard Hinnant756c69b2010-09-22 16:48:34 +00001014 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001015 iterator begin() _NOEXCEPT {return __tree_.begin();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001016 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001017 const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001018 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001019 iterator end() _NOEXCEPT {return __tree_.end();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001020 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001021 const_iterator end() const _NOEXCEPT {return __tree_.end();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001022
Howard Hinnant756c69b2010-09-22 16:48:34 +00001023 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001024 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001025 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001026 const_reverse_iterator rbegin() const _NOEXCEPT
1027 {return const_reverse_iterator(end());}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001028 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001029 reverse_iterator rend() _NOEXCEPT
1030 {return reverse_iterator(begin());}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001031 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001032 const_reverse_iterator rend() const _NOEXCEPT
1033 {return const_reverse_iterator(begin());}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001034
Howard Hinnant756c69b2010-09-22 16:48:34 +00001035 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001036 const_iterator cbegin() const _NOEXCEPT {return begin();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001037 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001038 const_iterator cend() const _NOEXCEPT {return end();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001039 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001040 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001041 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001042 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001043
Howard Hinnant756c69b2010-09-22 16:48:34 +00001044 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001045 bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001046 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001047 size_type size() const _NOEXCEPT {return __tree_.size();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001048 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001049 size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001050
1051 mapped_type& operator[](const key_type& __k);
Howard Hinnant74279a52010-09-04 23:28:19 +00001052#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00001053 mapped_type& operator[](key_type&& __k);
1054#endif
1055
1056 mapped_type& at(const key_type& __k);
1057 const mapped_type& at(const key_type& __k) const;
1058
Howard Hinnant756c69b2010-09-22 16:48:34 +00001059 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001060 allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001061 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001062 key_compare key_comp() const {return __tree_.value_comp().key_comp();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001063 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001064 value_compare value_comp() const {return value_compare(__tree_.value_comp().key_comp());}
1065
Howard Hinnant74279a52010-09-04 23:28:19 +00001066#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant74279a52010-09-04 23:28:19 +00001067#ifndef _LIBCPP_HAS_NO_VARIADICS
1068
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001069 template <class ..._Args>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001070 pair<iterator, bool>
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001071 emplace(_Args&& ...__args);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001072
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001073 template <class ..._Args>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001074 iterator
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001075 emplace_hint(const_iterator __p, _Args&& ...__args);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001076
Howard Hinnant74279a52010-09-04 23:28:19 +00001077#endif // _LIBCPP_HAS_NO_VARIADICS
1078
Howard Hinnantc834c512011-11-29 18:15:50 +00001079 template <class _Pp,
1080 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001081 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc834c512011-11-29 18:15:50 +00001082 pair<iterator, bool> insert(_Pp&& __p)
1083 {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001084
Howard Hinnantc834c512011-11-29 18:15:50 +00001085 template <class _Pp,
1086 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001087 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc834c512011-11-29 18:15:50 +00001088 iterator insert(const_iterator __pos, _Pp&& __p)
1089 {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001090
Howard Hinnant74279a52010-09-04 23:28:19 +00001091#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00001092
Howard Hinnant756c69b2010-09-22 16:48:34 +00001093 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001094 pair<iterator, bool>
1095 insert(const value_type& __v) {return __tree_.__insert_unique(__v);}
1096
Howard Hinnant756c69b2010-09-22 16:48:34 +00001097 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001098 iterator
1099 insert(const_iterator __p, const value_type& __v)
1100 {return __tree_.__insert_unique(__p.__i_, __v);}
1101
1102 template <class _InputIterator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001103 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001104 void insert(_InputIterator __f, _InputIterator __l)
1105 {
1106 for (const_iterator __e = cend(); __f != __l; ++__f)
1107 insert(__e.__i_, *__f);
1108 }
1109
Howard Hinnant33711792011-08-12 21:56:02 +00001110#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1111
Howard Hinnant756c69b2010-09-22 16:48:34 +00001112 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001113 void insert(initializer_list<value_type> __il)
1114 {insert(__il.begin(), __il.end());}
1115
Howard Hinnant33711792011-08-12 21:56:02 +00001116#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1117
Marshall Clow3223db82015-07-07 03:37:33 +00001118#if _LIBCPP_STD_VER > 14
1119#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1120#ifndef _LIBCPP_HAS_NO_VARIADICS
1121 template <class... _Args>
1122 _LIBCPP_INLINE_VISIBILITY
1123 pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
1124 {
1125 iterator __p = lower_bound(__k);
1126 if ( __p != end() && !key_comp()(__k, __p->first))
1127 return _VSTD::make_pair(__p, false);
1128 else
1129 return _VSTD::make_pair(
1130 emplace_hint(__p,
1131 _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
1132 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
1133 true);
1134 }
1135
1136 template <class... _Args>
1137 _LIBCPP_INLINE_VISIBILITY
1138 pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
1139 {
1140 iterator __p = lower_bound(__k);
1141 if ( __p != end() && !key_comp()(__k, __p->first))
1142 return _VSTD::make_pair(__p, false);
1143 else
1144 return _VSTD::make_pair(
1145 emplace_hint(__p,
1146 _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
1147 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
1148 true);
1149 }
1150
1151 template <class... _Args>
1152 _LIBCPP_INLINE_VISIBILITY
1153 iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
1154 {
1155 iterator __p = lower_bound(__k);
1156 if ( __p != end() && !key_comp()(__k, __p->first))
1157 return __p;
1158 else
1159 return emplace_hint(__p,
1160 _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
1161 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
1162 }
1163
1164 template <class... _Args>
1165 _LIBCPP_INLINE_VISIBILITY
1166 iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
1167 {
1168 iterator __p = lower_bound(__k);
1169 if ( __p != end() && !key_comp()(__k, __p->first))
1170 return __p;
1171 else
1172 return emplace_hint(__p,
1173 _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
1174 _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
1175 }
1176
1177 template <class _Vp>
1178 _LIBCPP_INLINE_VISIBILITY
1179 pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
1180 {
1181 iterator __p = lower_bound(__k);
1182 if ( __p != end() && !key_comp()(__k, __p->first))
1183 {
1184 __p->second = _VSTD::forward<_Vp>(__v);
1185 return _VSTD::make_pair(__p, false);
1186 }
1187 return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
1188 }
1189
1190 template <class _Vp>
1191 _LIBCPP_INLINE_VISIBILITY
1192 pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
1193 {
1194 iterator __p = lower_bound(__k);
1195 if ( __p != end() && !key_comp()(__k, __p->first))
1196 {
1197 __p->second = _VSTD::forward<_Vp>(__v);
1198 return _VSTD::make_pair(__p, false);
1199 }
1200 return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true);
1201 }
1202
1203 template <class _Vp>
1204 _LIBCPP_INLINE_VISIBILITY
1205 iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
1206 {
1207 iterator __p = lower_bound(__k);
1208 if ( __p != end() && !key_comp()(__k, __p->first))
1209 {
1210 __p->second = _VSTD::forward<_Vp>(__v);
1211 return __p;
1212 }
1213 return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v));
1214 }
1215
1216 template <class _Vp>
1217 _LIBCPP_INLINE_VISIBILITY
1218 iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
1219 {
1220 iterator __p = lower_bound(__k);
1221 if ( __p != end() && !key_comp()(__k, __p->first))
1222 {
1223 __p->second = _VSTD::forward<_Vp>(__v);
1224 return __p;
1225 }
1226 return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
1227 }
1228#endif
1229#endif
1230#endif
1231
Howard Hinnant756c69b2010-09-22 16:48:34 +00001232 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001233 iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001234 _LIBCPP_INLINE_VISIBILITY
Marshall Clow22ea5b82015-05-10 13:35:00 +00001235 iterator erase(iterator __p) {return __tree_.erase(__p.__i_);}
1236 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001237 size_type erase(const key_type& __k)
1238 {return __tree_.__erase_unique(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001239 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001240 iterator erase(const_iterator __f, const_iterator __l)
1241 {return __tree_.erase(__f.__i_, __l.__i_);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001242 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001243 void clear() _NOEXCEPT {__tree_.clear();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001244
Howard Hinnant756c69b2010-09-22 16:48:34 +00001245 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001246 void swap(map& __m)
1247 _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
1248 {__tree_.swap(__m.__tree_);}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001249
Howard Hinnant756c69b2010-09-22 16:48:34 +00001250 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001251 iterator find(const key_type& __k) {return __tree_.find(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001252 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001253 const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
Marshall Clowebb57322013-08-13 22:18:47 +00001254#if _LIBCPP_STD_VER > 11
1255 template <typename _K2>
1256 _LIBCPP_INLINE_VISIBILITY
1257 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
1258 find(const _K2& __k) {return __tree_.find(__k);}
1259 template <typename _K2>
1260 _LIBCPP_INLINE_VISIBILITY
1261 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
1262 find(const _K2& __k) const {return __tree_.find(__k);}
1263#endif
1264
Howard Hinnant756c69b2010-09-22 16:48:34 +00001265 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001266 size_type count(const key_type& __k) const
1267 {return __tree_.__count_unique(__k);}
Marshall Clowe6a5f522014-08-24 23:54:16 +00001268#if _LIBCPP_STD_VER > 11
1269 template <typename _K2>
1270 _LIBCPP_INLINE_VISIBILITY
1271 typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
Marshall Clow141e47b2015-06-30 18:15:41 +00001272 count(const _K2& __k) const {return __tree_.__count_unique(__k);}
Marshall Clowe6a5f522014-08-24 23:54:16 +00001273#endif
Howard Hinnant756c69b2010-09-22 16:48:34 +00001274 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001275 iterator lower_bound(const key_type& __k)
1276 {return __tree_.lower_bound(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001277 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001278 const_iterator lower_bound(const key_type& __k) const
1279 {return __tree_.lower_bound(__k);}
Marshall Clowebb57322013-08-13 22:18:47 +00001280#if _LIBCPP_STD_VER > 11
1281 template <typename _K2>
1282 _LIBCPP_INLINE_VISIBILITY
1283 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
1284 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
1285
1286 template <typename _K2>
1287 _LIBCPP_INLINE_VISIBILITY
1288 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
1289 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
1290#endif
1291
Howard Hinnant756c69b2010-09-22 16:48:34 +00001292 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001293 iterator upper_bound(const key_type& __k)
1294 {return __tree_.upper_bound(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001295 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001296 const_iterator upper_bound(const key_type& __k) const
1297 {return __tree_.upper_bound(__k);}
Marshall Clowebb57322013-08-13 22:18:47 +00001298#if _LIBCPP_STD_VER > 11
1299 template <typename _K2>
1300 _LIBCPP_INLINE_VISIBILITY
1301 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
1302 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
1303 template <typename _K2>
1304 _LIBCPP_INLINE_VISIBILITY
1305 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
1306 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
1307#endif
1308
Howard Hinnant756c69b2010-09-22 16:48:34 +00001309 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001310 pair<iterator,iterator> equal_range(const key_type& __k)
1311 {return __tree_.__equal_range_unique(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001312 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001313 pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
1314 {return __tree_.__equal_range_unique(__k);}
Marshall Clowebb57322013-08-13 22:18:47 +00001315#if _LIBCPP_STD_VER > 11
1316 template <typename _K2>
1317 _LIBCPP_INLINE_VISIBILITY
1318 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
1319 equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);}
1320 template <typename _K2>
1321 _LIBCPP_INLINE_VISIBILITY
1322 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
1323 equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);}
1324#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +00001325
1326private:
1327 typedef typename __base::__node __node;
1328 typedef typename __base::__node_allocator __node_allocator;
1329 typedef typename __base::__node_pointer __node_pointer;
1330 typedef typename __base::__node_const_pointer __node_const_pointer;
1331 typedef typename __base::__node_base_pointer __node_base_pointer;
1332 typedef typename __base::__node_base_const_pointer __node_base_const_pointer;
Howard Hinnantc834c512011-11-29 18:15:50 +00001333 typedef __map_node_destructor<__node_allocator> _Dp;
1334 typedef unique_ptr<__node, _Dp> __node_holder;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001335
Howard Hinnant74279a52010-09-04 23:28:19 +00001336#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00001337 __node_holder __construct_node();
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001338 template <class _A0>
Howard Hinnantac7e7482013-07-04 20:59:16 +00001339 __node_holder __construct_node(_A0&& __a0);
1340 __node_holder __construct_node_with_key(key_type&& __k);
Howard Hinnant74279a52010-09-04 23:28:19 +00001341#ifndef _LIBCPP_HAS_NO_VARIADICS
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001342 template <class _A0, class _A1, class ..._Args>
1343 __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
Howard Hinnant74279a52010-09-04 23:28:19 +00001344#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantc51e1022010-05-11 19:42:16 +00001345#endif
Howard Hinnantac7e7482013-07-04 20:59:16 +00001346 __node_holder __construct_node_with_key(const key_type& __k);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001347
1348 __node_base_pointer&
1349 __find_equal_key(__node_base_pointer& __parent, const key_type& __k);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001350 __node_base_const_pointer
1351 __find_equal_key(__node_base_const_pointer& __parent, const key_type& __k) const;
1352};
1353
1354// Find place to insert if __k doesn't exist
1355// Set __parent to parent of null leaf
1356// Return reference to null leaf
1357// If __k exists, set parent to node of __k and return reference to node of __k
1358template <class _Key, class _Tp, class _Compare, class _Allocator>
1359typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer&
1360map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent,
1361 const key_type& __k)
1362{
1363 __node_pointer __nd = __tree_.__root();
1364 if (__nd != nullptr)
1365 {
1366 while (true)
1367 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001368 if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
Howard Hinnantc51e1022010-05-11 19:42:16 +00001369 {
1370 if (__nd->__left_ != nullptr)
1371 __nd = static_cast<__node_pointer>(__nd->__left_);
1372 else
1373 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001374 __parent = static_cast<__node_base_pointer>(__nd);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001375 return __parent->__left_;
1376 }
1377 }
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001378 else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
Howard Hinnantc51e1022010-05-11 19:42:16 +00001379 {
1380 if (__nd->__right_ != nullptr)
1381 __nd = static_cast<__node_pointer>(__nd->__right_);
1382 else
1383 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001384 __parent = static_cast<__node_base_pointer>(__nd);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001385 return __parent->__right_;
1386 }
1387 }
1388 else
1389 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001390 __parent = static_cast<__node_base_pointer>(__nd);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001391 return __parent;
1392 }
1393 }
1394 }
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001395 __parent = static_cast<__node_base_pointer>(__tree_.__end_node());
Howard Hinnantc51e1022010-05-11 19:42:16 +00001396 return __parent->__left_;
1397}
1398
Howard Hinnantc51e1022010-05-11 19:42:16 +00001399// Find __k
1400// Set __parent to parent of null leaf and
1401// return reference to null leaf iv __k does not exist.
1402// If __k exists, set parent to node of __k and return reference to node of __k
1403template <class _Key, class _Tp, class _Compare, class _Allocator>
1404typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_const_pointer
1405map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer& __parent,
1406 const key_type& __k) const
1407{
1408 __node_const_pointer __nd = __tree_.__root();
1409 if (__nd != nullptr)
1410 {
1411 while (true)
1412 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001413 if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
Howard Hinnantc51e1022010-05-11 19:42:16 +00001414 {
1415 if (__nd->__left_ != nullptr)
1416 __nd = static_cast<__node_pointer>(__nd->__left_);
1417 else
1418 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001419 __parent = static_cast<__node_base_pointer>(__nd);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001420 return const_cast<const __node_base_const_pointer&>(__parent->__left_);
1421 }
1422 }
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001423 else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
Howard Hinnantc51e1022010-05-11 19:42:16 +00001424 {
1425 if (__nd->__right_ != nullptr)
1426 __nd = static_cast<__node_pointer>(__nd->__right_);
1427 else
1428 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001429 __parent = static_cast<__node_base_pointer>(__nd);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001430 return const_cast<const __node_base_const_pointer&>(__parent->__right_);
1431 }
1432 }
1433 else
1434 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001435 __parent = static_cast<__node_base_pointer>(__nd);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001436 return __parent;
1437 }
1438 }
1439 }
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001440 __parent = static_cast<__node_base_pointer>(__tree_.__end_node());
Howard Hinnantc51e1022010-05-11 19:42:16 +00001441 return const_cast<const __node_base_const_pointer&>(__parent->__left_);
1442}
1443
Howard Hinnant74279a52010-09-04 23:28:19 +00001444#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00001445
1446template <class _Key, class _Tp, class _Compare, class _Allocator>
1447map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001448 : __tree_(_VSTD::move(__m.__tree_), __a)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001449{
1450 if (__a != __m.get_allocator())
1451 {
1452 const_iterator __e = cend();
1453 while (!__m.empty())
1454 __tree_.__insert_unique(__e.__i_,
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001455 _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
Howard Hinnantc51e1022010-05-11 19:42:16 +00001456 }
1457}
1458
1459template <class _Key, class _Tp, class _Compare, class _Allocator>
1460typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
1461map<_Key, _Tp, _Compare, _Allocator>::__construct_node()
1462{
1463 __node_allocator& __na = __tree_.__node_alloc();
Howard Hinnantc834c512011-11-29 18:15:50 +00001464 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001465 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
Howard Hinnantc51e1022010-05-11 19:42:16 +00001466 __h.get_deleter().__first_constructed = true;
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001467 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
Howard Hinnantc51e1022010-05-11 19:42:16 +00001468 __h.get_deleter().__second_constructed = true;
1469 return __h;
1470}
1471
1472template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001473template <class _A0>
Howard Hinnantac7e7482013-07-04 20:59:16 +00001474typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
Howard Hinnantc51e1022010-05-11 19:42:16 +00001475map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
1476{
1477 __node_allocator& __na = __tree_.__node_alloc();
Howard Hinnantc834c512011-11-29 18:15:50 +00001478 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001479 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_A0>(__a0));
Howard Hinnantc51e1022010-05-11 19:42:16 +00001480 __h.get_deleter().__first_constructed = true;
1481 __h.get_deleter().__second_constructed = true;
1482 return __h;
1483}
1484
1485template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnantac7e7482013-07-04 20:59:16 +00001486typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
1487map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001488{
1489 __node_allocator& __na = __tree_.__node_alloc();
Howard Hinnantc834c512011-11-29 18:15:50 +00001490 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
Howard Hinnantac7e7482013-07-04 20:59:16 +00001491 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
Howard Hinnantc51e1022010-05-11 19:42:16 +00001492 __h.get_deleter().__first_constructed = true;
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001493 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001494 __h.get_deleter().__second_constructed = true;
Howard Hinnanta31e9682013-08-22 18:29:50 +00001495 return __h;
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001496}
1497
1498#ifndef _LIBCPP_HAS_NO_VARIADICS
1499
1500template <class _Key, class _Tp, class _Compare, class _Allocator>
1501template <class _A0, class _A1, class ..._Args>
1502typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
1503map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args)
1504{
1505 __node_allocator& __na = __tree_.__node_alloc();
1506 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1507 __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
1508 _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
1509 _VSTD::forward<_Args>(__args)...);
1510 __h.get_deleter().__first_constructed = true;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001511 __h.get_deleter().__second_constructed = true;
1512 return __h;
1513}
1514
Howard Hinnant74279a52010-09-04 23:28:19 +00001515#endif // _LIBCPP_HAS_NO_VARIADICS
1516
Howard Hinnantac7e7482013-07-04 20:59:16 +00001517#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00001518
1519template <class _Key, class _Tp, class _Compare, class _Allocator>
1520typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
Howard Hinnantac7e7482013-07-04 20:59:16 +00001521map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001522{
1523 __node_allocator& __na = __tree_.__node_alloc();
Howard Hinnantc834c512011-11-29 18:15:50 +00001524 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001525 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001526 __h.get_deleter().__first_constructed = true;
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001527 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
Howard Hinnantc51e1022010-05-11 19:42:16 +00001528 __h.get_deleter().__second_constructed = true;
Dimitry Andric830fb602015-08-19 06:43:33 +00001529 return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03
Howard Hinnantc51e1022010-05-11 19:42:16 +00001530}
1531
Howard Hinnantc51e1022010-05-11 19:42:16 +00001532template <class _Key, class _Tp, class _Compare, class _Allocator>
1533_Tp&
1534map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
1535{
1536 __node_base_pointer __parent;
1537 __node_base_pointer& __child = __find_equal_key(__parent, __k);
1538 __node_pointer __r = static_cast<__node_pointer>(__child);
1539 if (__child == nullptr)
1540 {
Howard Hinnantac7e7482013-07-04 20:59:16 +00001541 __node_holder __h = __construct_node_with_key(__k);
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001542 __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
Howard Hinnantc51e1022010-05-11 19:42:16 +00001543 __r = __h.release();
1544 }
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001545 return __r->__value_.__cc.second;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001546}
1547
Howard Hinnant74279a52010-09-04 23:28:19 +00001548#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00001549
1550template <class _Key, class _Tp, class _Compare, class _Allocator>
1551_Tp&
1552map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k)
1553{
1554 __node_base_pointer __parent;
1555 __node_base_pointer& __child = __find_equal_key(__parent, __k);
1556 __node_pointer __r = static_cast<__node_pointer>(__child);
1557 if (__child == nullptr)
1558 {
Howard Hinnantac7e7482013-07-04 20:59:16 +00001559 __node_holder __h = __construct_node_with_key(_VSTD::move(__k));
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001560 __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
Howard Hinnantc51e1022010-05-11 19:42:16 +00001561 __r = __h.release();
1562 }
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001563 return __r->__value_.__cc.second;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001564}
1565
Howard Hinnant74279a52010-09-04 23:28:19 +00001566#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00001567
1568template <class _Key, class _Tp, class _Compare, class _Allocator>
1569_Tp&
1570map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
1571{
1572 __node_base_pointer __parent;
1573 __node_base_pointer& __child = __find_equal_key(__parent, __k);
Howard Hinnant72f73582010-08-11 17:04:31 +00001574#ifndef _LIBCPP_NO_EXCEPTIONS
Howard Hinnantc51e1022010-05-11 19:42:16 +00001575 if (__child == nullptr)
1576 throw out_of_range("map::at: key not found");
Howard Hinnant3b6579a2010-08-22 00:02:43 +00001577#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001578 return static_cast<__node_pointer>(__child)->__value_.__cc.second;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001579}
1580
1581template <class _Key, class _Tp, class _Compare, class _Allocator>
1582const _Tp&
1583map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
1584{
1585 __node_base_const_pointer __parent;
1586 __node_base_const_pointer __child = __find_equal_key(__parent, __k);
Howard Hinnant72f73582010-08-11 17:04:31 +00001587#ifndef _LIBCPP_NO_EXCEPTIONS
Howard Hinnantc51e1022010-05-11 19:42:16 +00001588 if (__child == nullptr)
1589 throw out_of_range("map::at: key not found");
Howard Hinnant3b6579a2010-08-22 00:02:43 +00001590#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001591 return static_cast<__node_const_pointer>(__child)->__value_.__cc.second;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001592}
1593
Howard Hinnant74279a52010-09-04 23:28:19 +00001594#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001595
1596template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001597template <class ..._Args>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001598pair<typename map<_Key, _Tp, _Compare, _Allocator>::iterator, bool>
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001599map<_Key, _Tp, _Compare, _Allocator>::emplace(_Args&& ...__args)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001600{
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001601 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001602 pair<iterator, bool> __r = __tree_.__node_insert_unique(__h.get());
1603 if (__r.second)
1604 __h.release();
1605 return __r;
1606}
1607
1608template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001609template <class ..._Args>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001610typename map<_Key, _Tp, _Compare, _Allocator>::iterator
1611map<_Key, _Tp, _Compare, _Allocator>::emplace_hint(const_iterator __p,
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001612 _Args&& ...__args)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001613{
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001614 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001615 iterator __r = __tree_.__node_insert_unique(__p.__i_, __h.get());
1616 if (__r.__i_.__ptr_ == __h.get())
1617 __h.release();
1618 return __r;
1619}
1620
Howard Hinnant74279a52010-09-04 23:28:19 +00001621#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001622
1623template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001624inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001625bool
1626operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x,
1627 const map<_Key, _Tp, _Compare, _Allocator>& __y)
1628{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001629 return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
Howard Hinnantc51e1022010-05-11 19:42:16 +00001630}
1631
1632template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001633inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001634bool
1635operator< (const map<_Key, _Tp, _Compare, _Allocator>& __x,
1636 const map<_Key, _Tp, _Compare, _Allocator>& __y)
1637{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001638 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
Howard Hinnantc51e1022010-05-11 19:42:16 +00001639}
1640
1641template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001642inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001643bool
1644operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
1645 const map<_Key, _Tp, _Compare, _Allocator>& __y)
1646{
1647 return !(__x == __y);
1648}
1649
1650template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001651inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001652bool
1653operator> (const map<_Key, _Tp, _Compare, _Allocator>& __x,
1654 const map<_Key, _Tp, _Compare, _Allocator>& __y)
1655{
1656 return __y < __x;
1657}
1658
1659template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001660inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001661bool
1662operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
1663 const map<_Key, _Tp, _Compare, _Allocator>& __y)
1664{
1665 return !(__x < __y);
1666}
1667
1668template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001669inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001670bool
1671operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
1672 const map<_Key, _Tp, _Compare, _Allocator>& __y)
1673{
1674 return !(__y < __x);
1675}
1676
1677template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001678inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001679void
1680swap(map<_Key, _Tp, _Compare, _Allocator>& __x,
1681 map<_Key, _Tp, _Compare, _Allocator>& __y)
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001682 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantc51e1022010-05-11 19:42:16 +00001683{
1684 __x.swap(__y);
1685}
1686
1687template <class _Key, class _Tp, class _Compare = less<_Key>,
1688 class _Allocator = allocator<pair<const _Key, _Tp> > >
Howard Hinnanta37d3cf2013-08-12 18:38:34 +00001689class _LIBCPP_TYPE_VIS_ONLY multimap
Howard Hinnantc51e1022010-05-11 19:42:16 +00001690{
1691public:
1692 // types:
1693 typedef _Key key_type;
1694 typedef _Tp mapped_type;
1695 typedef pair<const key_type, mapped_type> value_type;
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001696 typedef pair<key_type, mapped_type> __nc_value_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001697 typedef _Compare key_compare;
1698 typedef _Allocator allocator_type;
1699 typedef value_type& reference;
1700 typedef const value_type& const_reference;
1701
Marshall Clow5128cf32015-11-26 01:24:04 +00001702 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
1703 "Allocator::value_type must be same type as value_type");
1704
Howard Hinnanta37d3cf2013-08-12 18:38:34 +00001705 class _LIBCPP_TYPE_VIS_ONLY value_compare
Howard Hinnantc51e1022010-05-11 19:42:16 +00001706 : public binary_function<value_type, value_type, bool>
1707 {
1708 friend class multimap;
1709 protected:
1710 key_compare comp;
1711
Howard Hinnant756c69b2010-09-22 16:48:34 +00001712 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001713 value_compare(key_compare c) : comp(c) {}
1714 public:
Howard Hinnant756c69b2010-09-22 16:48:34 +00001715 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001716 bool operator()(const value_type& __x, const value_type& __y) const
1717 {return comp(__x.first, __y.first);}
1718 };
1719
1720private:
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001721
Howard Hinnant89f8b792013-09-30 19:08:22 +00001722 typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
Howard Hinnant90b91592013-07-05 18:06:00 +00001723 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
Marshall Clow940e01c2015-04-07 05:21:38 +00001724 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
1725 __value_type>::type __allocator_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001726 typedef __tree<__value_type, __vc, __allocator_type> __base;
1727 typedef typename __base::__node_traits __node_traits;
1728 typedef allocator_traits<allocator_type> __alloc_traits;
1729
1730 __base __tree_;
1731
1732public:
1733 typedef typename __alloc_traits::pointer pointer;
1734 typedef typename __alloc_traits::const_pointer const_pointer;
1735 typedef typename __alloc_traits::size_type size_type;
1736 typedef typename __alloc_traits::difference_type difference_type;
1737 typedef __map_iterator<typename __base::iterator> iterator;
1738 typedef __map_const_iterator<typename __base::const_iterator> const_iterator;
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001739 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
1740 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001741
Howard Hinnant756c69b2010-09-22 16:48:34 +00001742 _LIBCPP_INLINE_VISIBILITY
Marshall Clow7086a5a2014-03-10 04:50:10 +00001743 multimap()
1744 _NOEXCEPT_(
1745 is_nothrow_default_constructible<allocator_type>::value &&
1746 is_nothrow_default_constructible<key_compare>::value &&
1747 is_nothrow_copy_constructible<key_compare>::value)
1748 : __tree_(__vc(key_compare())) {}
1749
1750 _LIBCPP_INLINE_VISIBILITY
1751 explicit multimap(const key_compare& __comp)
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001752 _NOEXCEPT_(
1753 is_nothrow_default_constructible<allocator_type>::value &&
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001754 is_nothrow_copy_constructible<key_compare>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001755 : __tree_(__vc(__comp)) {}
1756
Howard Hinnant756c69b2010-09-22 16:48:34 +00001757 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001758 explicit multimap(const key_compare& __comp, const allocator_type& __a)
1759 : __tree_(__vc(__comp), __a) {}
1760
1761 template <class _InputIterator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001762 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001763 multimap(_InputIterator __f, _InputIterator __l,
1764 const key_compare& __comp = key_compare())
1765 : __tree_(__vc(__comp))
1766 {
1767 insert(__f, __l);
1768 }
1769
1770 template <class _InputIterator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001771 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001772 multimap(_InputIterator __f, _InputIterator __l,
1773 const key_compare& __comp, const allocator_type& __a)
1774 : __tree_(__vc(__comp), __a)
1775 {
1776 insert(__f, __l);
1777 }
1778
Marshall Clow300abfb2013-09-11 01:15:47 +00001779#if _LIBCPP_STD_VER > 11
1780 template <class _InputIterator>
1781 _LIBCPP_INLINE_VISIBILITY
1782 multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
1783 : multimap(__f, __l, key_compare(), __a) {}
1784#endif
1785
Howard Hinnant756c69b2010-09-22 16:48:34 +00001786 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001787 multimap(const multimap& __m)
1788 : __tree_(__m.__tree_.value_comp(),
1789 __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc()))
1790 {
1791 insert(__m.begin(), __m.end());
1792 }
1793
Howard Hinnantd3a657f2011-07-01 19:24:36 +00001794 _LIBCPP_INLINE_VISIBILITY
1795 multimap& operator=(const multimap& __m)
1796 {
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001797#if __cplusplus >= 201103L
Howard Hinnantd3a657f2011-07-01 19:24:36 +00001798 __tree_ = __m.__tree_;
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001799#else
Marshall Clowdb3cfcb2014-02-08 04:03:14 +00001800 if (this != &__m) {
1801 __tree_.clear();
1802 __tree_.value_comp() = __m.__tree_.value_comp();
1803 __tree_.__copy_assign_alloc(__m.__tree_);
1804 insert(__m.begin(), __m.end());
1805 }
Howard Hinnant2d0046b2013-06-19 21:29:40 +00001806#endif
Howard Hinnantd3a657f2011-07-01 19:24:36 +00001807 return *this;
1808 }
1809
Howard Hinnant74279a52010-09-04 23:28:19 +00001810#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00001811
Howard Hinnant756c69b2010-09-22 16:48:34 +00001812 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001813 multimap(multimap&& __m)
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001814 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001815 : __tree_(_VSTD::move(__m.__tree_))
Howard Hinnantc51e1022010-05-11 19:42:16 +00001816 {
1817 }
1818
1819 multimap(multimap&& __m, const allocator_type& __a);
1820
Howard Hinnant756c69b2010-09-22 16:48:34 +00001821 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant33711792011-08-12 21:56:02 +00001822 multimap& operator=(multimap&& __m)
1823 _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
1824 {
1825 __tree_ = _VSTD::move(__m.__tree_);
1826 return *this;
1827 }
1828
1829#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1830
1831#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1832
1833 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001834 multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
1835 : __tree_(__vc(__comp))
1836 {
1837 insert(__il.begin(), __il.end());
1838 }
1839
Howard Hinnant756c69b2010-09-22 16:48:34 +00001840 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001841 multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
1842 : __tree_(__vc(__comp), __a)
1843 {
1844 insert(__il.begin(), __il.end());
1845 }
1846
Marshall Clow300abfb2013-09-11 01:15:47 +00001847#if _LIBCPP_STD_VER > 11
1848 _LIBCPP_INLINE_VISIBILITY
1849 multimap(initializer_list<value_type> __il, const allocator_type& __a)
1850 : multimap(__il, key_compare(), __a) {}
1851#endif
1852
Howard Hinnant756c69b2010-09-22 16:48:34 +00001853 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001854 multimap& operator=(initializer_list<value_type> __il)
1855 {
1856 __tree_.__assign_multi(__il.begin(), __il.end());
1857 return *this;
1858 }
Howard Hinnant33711792011-08-12 21:56:02 +00001859
1860#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantc51e1022010-05-11 19:42:16 +00001861
Howard Hinnant756c69b2010-09-22 16:48:34 +00001862 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001863 explicit multimap(const allocator_type& __a)
1864 : __tree_(__a)
1865 {
1866 }
1867
Howard Hinnant756c69b2010-09-22 16:48:34 +00001868 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001869 multimap(const multimap& __m, const allocator_type& __a)
1870 : __tree_(__m.__tree_.value_comp(), __a)
1871 {
1872 insert(__m.begin(), __m.end());
1873 }
1874
Howard Hinnant756c69b2010-09-22 16:48:34 +00001875 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001876 iterator begin() _NOEXCEPT {return __tree_.begin();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001877 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001878 const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001879 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001880 iterator end() _NOEXCEPT {return __tree_.end();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001881 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001882 const_iterator end() const _NOEXCEPT {return __tree_.end();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001883
Howard Hinnant756c69b2010-09-22 16:48:34 +00001884 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001885 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001886 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001887 const_reverse_iterator rbegin() const _NOEXCEPT
1888 {return const_reverse_iterator(end());}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001889 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001890 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001891 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001892 const_reverse_iterator rend() const _NOEXCEPT
1893 {return const_reverse_iterator(begin());}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001894
Howard Hinnant756c69b2010-09-22 16:48:34 +00001895 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001896 const_iterator cbegin() const _NOEXCEPT {return begin();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001897 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001898 const_iterator cend() const _NOEXCEPT {return end();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001899 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001900 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001901 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001902 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001903
Howard Hinnant756c69b2010-09-22 16:48:34 +00001904 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001905 bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001906 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001907 size_type size() const _NOEXCEPT {return __tree_.size();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001908 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001909 size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001910
Howard Hinnant756c69b2010-09-22 16:48:34 +00001911 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001912 allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001913 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001914 key_compare key_comp() const {return __tree_.value_comp().key_comp();}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001915 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001916 value_compare value_comp() const
1917 {return value_compare(__tree_.value_comp().key_comp());}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001918
Howard Hinnant74279a52010-09-04 23:28:19 +00001919#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant74279a52010-09-04 23:28:19 +00001920#ifndef _LIBCPP_HAS_NO_VARIADICS
1921
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001922 template <class ..._Args>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001923 iterator
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001924 emplace(_Args&& ...__args);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001925
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001926 template <class ..._Args>
Howard Hinnantc51e1022010-05-11 19:42:16 +00001927 iterator
Howard Hinnant29eb9b82012-05-25 22:04:21 +00001928 emplace_hint(const_iterator __p, _Args&& ...__args);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001929
Howard Hinnant74279a52010-09-04 23:28:19 +00001930#endif // _LIBCPP_HAS_NO_VARIADICS
1931
Howard Hinnantc834c512011-11-29 18:15:50 +00001932 template <class _Pp,
1933 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001934 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc834c512011-11-29 18:15:50 +00001935 iterator insert(_Pp&& __p)
1936 {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001937
Howard Hinnantc834c512011-11-29 18:15:50 +00001938 template <class _Pp,
1939 class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001940 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc834c512011-11-29 18:15:50 +00001941 iterator insert(const_iterator __pos, _Pp&& __p)
1942 {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001943
Howard Hinnant74279a52010-09-04 23:28:19 +00001944#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00001945
Howard Hinnant756c69b2010-09-22 16:48:34 +00001946 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001947 iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);}
1948
Howard Hinnant756c69b2010-09-22 16:48:34 +00001949 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001950 iterator insert(const_iterator __p, const value_type& __v)
1951 {return __tree_.__insert_multi(__p.__i_, __v);}
1952
1953 template <class _InputIterator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00001954 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001955 void insert(_InputIterator __f, _InputIterator __l)
1956 {
1957 for (const_iterator __e = cend(); __f != __l; ++__f)
1958 __tree_.__insert_multi(__e.__i_, *__f);
1959 }
1960
Howard Hinnant33711792011-08-12 21:56:02 +00001961#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1962
Howard Hinnant756c69b2010-09-22 16:48:34 +00001963 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001964 void insert(initializer_list<value_type> __il)
1965 {insert(__il.begin(), __il.end());}
1966
Howard Hinnant33711792011-08-12 21:56:02 +00001967#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1968
Howard Hinnant756c69b2010-09-22 16:48:34 +00001969 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001970 iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001971 _LIBCPP_INLINE_VISIBILITY
Marshall Clow22ea5b82015-05-10 13:35:00 +00001972 iterator erase(iterator __p) {return __tree_.erase(__p.__i_);}
1973 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001974 size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001975 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001976 iterator erase(const_iterator __f, const_iterator __l)
1977 {return __tree_.erase(__f.__i_, __l.__i_);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001978 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001979 void clear() {__tree_.clear();}
1980
Howard Hinnant756c69b2010-09-22 16:48:34 +00001981 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00001982 void swap(multimap& __m)
1983 _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
1984 {__tree_.swap(__m.__tree_);}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001985
Howard Hinnant756c69b2010-09-22 16:48:34 +00001986 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001987 iterator find(const key_type& __k) {return __tree_.find(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00001988 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001989 const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
Marshall Clowebb57322013-08-13 22:18:47 +00001990#if _LIBCPP_STD_VER > 11
1991 template <typename _K2>
1992 _LIBCPP_INLINE_VISIBILITY
1993 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
1994 find(const _K2& __k) {return __tree_.find(__k);}
1995 template <typename _K2>
1996 _LIBCPP_INLINE_VISIBILITY
1997 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
1998 find(const _K2& __k) const {return __tree_.find(__k);}
1999#endif
2000
Howard Hinnant756c69b2010-09-22 16:48:34 +00002001 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002002 size_type count(const key_type& __k) const
2003 {return __tree_.__count_multi(__k);}
Marshall Clowe6a5f522014-08-24 23:54:16 +00002004#if _LIBCPP_STD_VER > 11
2005 template <typename _K2>
2006 _LIBCPP_INLINE_VISIBILITY
2007 typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
Marshall Clow141e47b2015-06-30 18:15:41 +00002008 count(const _K2& __k) const {return __tree_.__count_multi(__k);}
Marshall Clowe6a5f522014-08-24 23:54:16 +00002009#endif
Howard Hinnant756c69b2010-09-22 16:48:34 +00002010 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002011 iterator lower_bound(const key_type& __k)
2012 {return __tree_.lower_bound(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00002013 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002014 const_iterator lower_bound(const key_type& __k) const
2015 {return __tree_.lower_bound(__k);}
Marshall Clowebb57322013-08-13 22:18:47 +00002016#if _LIBCPP_STD_VER > 11
2017 template <typename _K2>
2018 _LIBCPP_INLINE_VISIBILITY
2019 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
2020 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
2021
2022 template <typename _K2>
2023 _LIBCPP_INLINE_VISIBILITY
2024 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
2025 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
2026#endif
2027
Howard Hinnant756c69b2010-09-22 16:48:34 +00002028 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002029 iterator upper_bound(const key_type& __k)
2030 {return __tree_.upper_bound(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00002031 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002032 const_iterator upper_bound(const key_type& __k) const
2033 {return __tree_.upper_bound(__k);}
Marshall Clowebb57322013-08-13 22:18:47 +00002034#if _LIBCPP_STD_VER > 11
2035 template <typename _K2>
2036 _LIBCPP_INLINE_VISIBILITY
2037 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
2038 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
2039 template <typename _K2>
2040 _LIBCPP_INLINE_VISIBILITY
2041 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
2042 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
2043#endif
2044
Howard Hinnant756c69b2010-09-22 16:48:34 +00002045 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002046 pair<iterator,iterator> equal_range(const key_type& __k)
2047 {return __tree_.__equal_range_multi(__k);}
Howard Hinnant756c69b2010-09-22 16:48:34 +00002048 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002049 pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
2050 {return __tree_.__equal_range_multi(__k);}
Marshall Clowebb57322013-08-13 22:18:47 +00002051#if _LIBCPP_STD_VER > 11
2052 template <typename _K2>
2053 _LIBCPP_INLINE_VISIBILITY
2054 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
2055 equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
2056 template <typename _K2>
2057 _LIBCPP_INLINE_VISIBILITY
2058 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
2059 equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
2060#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +00002061
2062private:
2063 typedef typename __base::__node __node;
2064 typedef typename __base::__node_allocator __node_allocator;
2065 typedef typename __base::__node_pointer __node_pointer;
2066 typedef typename __base::__node_const_pointer __node_const_pointer;
Howard Hinnantc834c512011-11-29 18:15:50 +00002067 typedef __map_node_destructor<__node_allocator> _Dp;
2068 typedef unique_ptr<__node, _Dp> __node_holder;
Howard Hinnantc51e1022010-05-11 19:42:16 +00002069
Howard Hinnant74279a52010-09-04 23:28:19 +00002070#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00002071 __node_holder __construct_node();
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002072 template <class _A0>
Howard Hinnantac7e7482013-07-04 20:59:16 +00002073 __node_holder
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002074 __construct_node(_A0&& __a0);
Howard Hinnant74279a52010-09-04 23:28:19 +00002075#ifndef _LIBCPP_HAS_NO_VARIADICS
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002076 template <class _A0, class _A1, class ..._Args>
2077 __node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
Howard Hinnant74279a52010-09-04 23:28:19 +00002078#endif // _LIBCPP_HAS_NO_VARIADICS
2079#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00002080};
2081
Howard Hinnant74279a52010-09-04 23:28:19 +00002082#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00002083
2084template <class _Key, class _Tp, class _Compare, class _Allocator>
2085multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00002086 : __tree_(_VSTD::move(__m.__tree_), __a)
Howard Hinnantc51e1022010-05-11 19:42:16 +00002087{
2088 if (__a != __m.get_allocator())
2089 {
2090 const_iterator __e = cend();
2091 while (!__m.empty())
2092 __tree_.__insert_multi(__e.__i_,
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00002093 _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
Howard Hinnantc51e1022010-05-11 19:42:16 +00002094 }
2095}
2096
2097template <class _Key, class _Tp, class _Compare, class _Allocator>
2098typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
2099multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node()
2100{
2101 __node_allocator& __na = __tree_.__node_alloc();
Howard Hinnantc834c512011-11-29 18:15:50 +00002102 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
Howard Hinnant2d0046b2013-06-19 21:29:40 +00002103 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
Howard Hinnantc51e1022010-05-11 19:42:16 +00002104 __h.get_deleter().__first_constructed = true;
Howard Hinnant2d0046b2013-06-19 21:29:40 +00002105 __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
Howard Hinnantc51e1022010-05-11 19:42:16 +00002106 __h.get_deleter().__second_constructed = true;
2107 return __h;
2108}
2109
2110template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002111template <class _A0>
Howard Hinnantac7e7482013-07-04 20:59:16 +00002112typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
Howard Hinnantc51e1022010-05-11 19:42:16 +00002113multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
2114{
2115 __node_allocator& __na = __tree_.__node_alloc();
Howard Hinnantc834c512011-11-29 18:15:50 +00002116 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00002117 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_A0>(__a0));
Howard Hinnantc51e1022010-05-11 19:42:16 +00002118 __h.get_deleter().__first_constructed = true;
2119 __h.get_deleter().__second_constructed = true;
2120 return __h;
2121}
2122
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002123#ifndef _LIBCPP_HAS_NO_VARIADICS
2124
2125template <class _Key, class _Tp, class _Compare, class _Allocator>
2126template <class _A0, class _A1, class ..._Args>
2127typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
2128multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args)
2129{
2130 __node_allocator& __na = __tree_.__node_alloc();
2131 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2132 __node_traits::construct(__na, _VSTD::addressof(__h->__value_),
2133 _VSTD::forward<_A0>(__a0), _VSTD::forward<_A1>(__a1),
2134 _VSTD::forward<_Args>(__args)...);
2135 __h.get_deleter().__first_constructed = true;
Howard Hinnantc51e1022010-05-11 19:42:16 +00002136 __h.get_deleter().__second_constructed = true;
2137 return __h;
2138}
2139
Howard Hinnant74279a52010-09-04 23:28:19 +00002140#endif // _LIBCPP_HAS_NO_VARIADICS
2141#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantc51e1022010-05-11 19:42:16 +00002142
Howard Hinnant74279a52010-09-04 23:28:19 +00002143#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantc51e1022010-05-11 19:42:16 +00002144
2145template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002146template <class ..._Args>
Howard Hinnantc51e1022010-05-11 19:42:16 +00002147typename multimap<_Key, _Tp, _Compare, _Allocator>::iterator
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002148multimap<_Key, _Tp, _Compare, _Allocator>::emplace(_Args&& ...__args)
Howard Hinnantc51e1022010-05-11 19:42:16 +00002149{
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002150 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
Howard Hinnantc51e1022010-05-11 19:42:16 +00002151 iterator __r = __tree_.__node_insert_multi(__h.get());
2152 __h.release();
2153 return __r;
2154}
2155
2156template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002157template <class ..._Args>
Howard Hinnantc51e1022010-05-11 19:42:16 +00002158typename multimap<_Key, _Tp, _Compare, _Allocator>::iterator
2159multimap<_Key, _Tp, _Compare, _Allocator>::emplace_hint(const_iterator __p,
Howard Hinnantc51e1022010-05-11 19:42:16 +00002160 _Args&& ...__args)
2161{
Howard Hinnant29eb9b82012-05-25 22:04:21 +00002162 __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
Howard Hinnantc51e1022010-05-11 19:42:16 +00002163 iterator __r = __tree_.__node_insert_multi(__p.__i_, __h.get());
2164 __h.release();
2165 return __r;
2166}
2167
Howard Hinnant74279a52010-09-04 23:28:19 +00002168#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantc51e1022010-05-11 19:42:16 +00002169
2170template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00002171inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002172bool
2173operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
2174 const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
2175{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00002176 return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
Howard Hinnantc51e1022010-05-11 19:42:16 +00002177}
2178
2179template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00002180inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002181bool
2182operator< (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
2183 const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
2184{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00002185 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
Howard Hinnantc51e1022010-05-11 19:42:16 +00002186}
2187
2188template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00002189inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002190bool
2191operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
2192 const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
2193{
2194 return !(__x == __y);
2195}
2196
2197template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00002198inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002199bool
2200operator> (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
2201 const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
2202{
2203 return __y < __x;
2204}
2205
2206template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00002207inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002208bool
2209operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
2210 const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
2211{
2212 return !(__x < __y);
2213}
2214
2215template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00002216inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002217bool
2218operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
2219 const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
2220{
2221 return !(__y < __x);
2222}
2223
2224template <class _Key, class _Tp, class _Compare, class _Allocator>
Howard Hinnant756c69b2010-09-22 16:48:34 +00002225inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00002226void
2227swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x,
2228 multimap<_Key, _Tp, _Compare, _Allocator>& __y)
Howard Hinnant2f1ea9c2011-06-04 14:31:57 +00002229 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantc51e1022010-05-11 19:42:16 +00002230{
2231 __x.swap(__y);
2232}
2233
2234_LIBCPP_END_NAMESPACE_STD
2235
2236#endif // _LIBCPP_MAP