blob: ac69e085241f7e03fb96ce95cdfd655fd76a89af [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:161// -*- C++ -*-
2//===---------------------------- set -------------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:014// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:165//
Howard Hinnantb64f8b02010-11-16 22:09:026// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:168//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_SET
12#define _LIBCPP_SET
13
14/*
15
16 set synopsis
17
18namespace std
19{
20
21template <class Key, class Compare = less<Key>,
22 class Allocator = allocator<Key>>
23class set
24{
25public:
26 // types:
27 typedef Key key_type;
28 typedef key_type value_type;
29 typedef Compare key_compare;
30 typedef key_compare value_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::size_type size_type;
35 typedef typename allocator_type::difference_type difference_type;
36 typedef typename allocator_type::pointer pointer;
37 typedef typename allocator_type::const_pointer const_pointer;
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 // construct/copy/destroy:
Howard Hinnantb2e2a8f2011-06-04 15:22:3445 set()
46 noexcept(
47 is_nothrow_default_constructible<allocator_type>::value &&
48 is_nothrow_default_constructible<key_compare>::value &&
49 is_nothrow_copy_constructible<key_compare>::value);
50 explicit set(const value_compare& comp);
Howard Hinnantbc8d3f92010-05-11 19:42:1651 set(const value_compare& comp, const allocator_type& a);
52 template <class InputIterator>
53 set(InputIterator first, InputIterator last,
54 const value_compare& comp = value_compare());
55 template <class InputIterator>
56 set(InputIterator first, InputIterator last, const value_compare& comp,
57 const allocator_type& a);
58 set(const set& s);
Howard Hinnantb2e2a8f2011-06-04 15:22:3459 set(set&& s)
60 noexcept(
61 is_nothrow_move_constructible<allocator_type>::value &&
62 is_nothrow_move_constructible<key_compare>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:1663 explicit set(const allocator_type& a);
64 set(const set& s, const allocator_type& a);
65 set(set&& s, const allocator_type& a);
66 set(initializer_list<value_type> il, const value_compare& comp = value_compare());
67 set(initializer_list<value_type> il, const value_compare& comp,
68 const allocator_type& a);
Marshall Clow24a7e332013-09-11 00:06:4569 template <class InputIterator>
70 set(InputIterator first, InputIterator last, const allocator_type& a)
71 : set(first, last, Compare(), a) {} // C++14
72 set(initializer_list<value_type> il, const allocator_type& a)
73 : set(il, Compare(), a) {} // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1674 ~set();
75
76 set& operator=(const set& s);
Howard Hinnantb2e2a8f2011-06-04 15:22:3477 set& operator=(set&& s)
78 noexcept(
79 allocator_type::propagate_on_container_move_assignment::value &&
80 is_nothrow_move_assignable<allocator_type>::value &&
81 is_nothrow_move_assignable<key_compare>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:1682 set& operator=(initializer_list<value_type> il);
83
84 // iterators:
Howard Hinnantb2e2a8f2011-06-04 15:22:3485 iterator begin() noexcept;
86 const_iterator begin() const noexcept;
87 iterator end() noexcept;
88 const_iterator end() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1689
Howard Hinnantb2e2a8f2011-06-04 15:22:3490 reverse_iterator rbegin() noexcept;
91 const_reverse_iterator rbegin() const noexcept;
92 reverse_iterator rend() noexcept;
93 const_reverse_iterator rend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1694
Howard Hinnantb2e2a8f2011-06-04 15:22:3495 const_iterator cbegin() const noexcept;
96 const_iterator cend() const noexcept;
97 const_reverse_iterator crbegin() const noexcept;
98 const_reverse_iterator crend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1699
100 // capacity:
Howard Hinnantb2e2a8f2011-06-04 15:22:34101 bool empty() const noexcept;
102 size_type size() const noexcept;
103 size_type max_size() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16104
105 // modifiers:
106 template <class... Args>
107 pair<iterator, bool> emplace(Args&&... args);
108 template <class... Args>
109 iterator emplace_hint(const_iterator position, Args&&... args);
110 pair<iterator,bool> insert(const value_type& v);
111 pair<iterator,bool> insert(value_type&& v);
112 iterator insert(const_iterator position, const value_type& v);
113 iterator insert(const_iterator position, value_type&& v);
114 template <class InputIterator>
115 void insert(InputIterator first, InputIterator last);
116 void insert(initializer_list<value_type> il);
117
118 iterator erase(const_iterator position);
Marshall Clow488025c2015-05-10 13:35:00119 iterator erase(iterator position); // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16120 size_type erase(const key_type& k);
121 iterator erase(const_iterator first, const_iterator last);
Howard Hinnantb2e2a8f2011-06-04 15:22:34122 void clear() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16123
Howard Hinnantb2e2a8f2011-06-04 15:22:34124 void swap(set& s)
125 noexcept(
126 __is_nothrow_swappable<key_compare>::value &&
127 (!allocator_type::propagate_on_container_swap::value ||
128 __is_nothrow_swappable<allocator_type>::value));
Howard Hinnantbc8d3f92010-05-11 19:42:16129
130 // observers:
Howard Hinnantb2e2a8f2011-06-04 15:22:34131 allocator_type get_allocator() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16132 key_compare key_comp() const;
133 value_compare value_comp() const;
134
135 // set operations:
136 iterator find(const key_type& k);
137 const_iterator find(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06138 template<typename K>
139 iterator find(const K& x);
140 template<typename K>
141 const_iterator find(const K& x) const; // C++14
142 template<typename K>
143 size_type count(const K& x) const; // C++14
144
Howard Hinnantbc8d3f92010-05-11 19:42:16145 size_type count(const key_type& k) const;
146 iterator lower_bound(const key_type& k);
147 const_iterator lower_bound(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06148 template<typename K>
149 iterator lower_bound(const K& x); // C++14
150 template<typename K>
151 const_iterator lower_bound(const K& x) const; // C++14
152
Howard Hinnantbc8d3f92010-05-11 19:42:16153 iterator upper_bound(const key_type& k);
154 const_iterator upper_bound(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06155 template<typename K>
156 iterator upper_bound(const K& x); // C++14
157 template<typename K>
158 const_iterator upper_bound(const K& x) const; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16159 pair<iterator,iterator> equal_range(const key_type& k);
160 pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06161 template<typename K>
162 pair<iterator,iterator> equal_range(const K& x); // C++14
163 template<typename K>
164 pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16165};
166
167template <class Key, class Compare, class Allocator>
168bool
169operator==(const set<Key, Compare, Allocator>& x,
170 const set<Key, Compare, Allocator>& y);
171
172template <class Key, class Compare, class Allocator>
173bool
174operator< (const set<Key, Compare, Allocator>& x,
175 const set<Key, Compare, Allocator>& y);
176
177template <class Key, class Compare, class Allocator>
178bool
179operator!=(const set<Key, Compare, Allocator>& x,
180 const set<Key, Compare, Allocator>& y);
181
182template <class Key, class Compare, class Allocator>
183bool
184operator> (const set<Key, Compare, Allocator>& x,
185 const set<Key, Compare, Allocator>& y);
186
187template <class Key, class Compare, class Allocator>
188bool
189operator>=(const set<Key, Compare, Allocator>& x,
190 const set<Key, Compare, Allocator>& y);
191
192template <class Key, class Compare, class Allocator>
193bool
194operator<=(const set<Key, Compare, Allocator>& x,
195 const set<Key, Compare, Allocator>& y);
196
197// specialized algorithms:
198template <class Key, class Compare, class Allocator>
199void
Howard Hinnantb2e2a8f2011-06-04 15:22:34200swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
201 noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16202
Howard Hinnantbc8d3f92010-05-11 19:42:16203template <class Key, class Compare = less<Key>,
204 class Allocator = allocator<Key>>
205class multiset
206{
207public:
208 // types:
209 typedef Key key_type;
210 typedef key_type value_type;
211 typedef Compare key_compare;
212 typedef key_compare value_compare;
213 typedef Allocator allocator_type;
214 typedef typename allocator_type::reference reference;
215 typedef typename allocator_type::const_reference const_reference;
216 typedef typename allocator_type::size_type size_type;
217 typedef typename allocator_type::difference_type difference_type;
218 typedef typename allocator_type::pointer pointer;
219 typedef typename allocator_type::const_pointer const_pointer;
220
221 typedef implementation-defined iterator;
222 typedef implementation-defined const_iterator;
223 typedef std::reverse_iterator<iterator> reverse_iterator;
224 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
225
226 // construct/copy/destroy:
Howard Hinnantb2e2a8f2011-06-04 15:22:34227 multiset()
228 noexcept(
229 is_nothrow_default_constructible<allocator_type>::value &&
230 is_nothrow_default_constructible<key_compare>::value &&
231 is_nothrow_copy_constructible<key_compare>::value);
232 explicit multiset(const value_compare& comp);
Howard Hinnantbc8d3f92010-05-11 19:42:16233 multiset(const value_compare& comp, const allocator_type& a);
234 template <class InputIterator>
235 multiset(InputIterator first, InputIterator last,
236 const value_compare& comp = value_compare());
237 template <class InputIterator>
238 multiset(InputIterator first, InputIterator last,
239 const value_compare& comp, const allocator_type& a);
240 multiset(const multiset& s);
Howard Hinnantb2e2a8f2011-06-04 15:22:34241 multiset(multiset&& s)
242 noexcept(
243 is_nothrow_move_constructible<allocator_type>::value &&
244 is_nothrow_move_constructible<key_compare>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16245 explicit multiset(const allocator_type& a);
246 multiset(const multiset& s, const allocator_type& a);
247 multiset(multiset&& s, const allocator_type& a);
248 multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
249 multiset(initializer_list<value_type> il, const value_compare& comp,
250 const allocator_type& a);
Marshall Clow24a7e332013-09-11 00:06:45251 template <class InputIterator>
252 multiset(InputIterator first, InputIterator last, const allocator_type& a)
253 : set(first, last, Compare(), a) {} // C++14
254 multiset(initializer_list<value_type> il, const allocator_type& a)
255 : set(il, Compare(), a) {} // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16256 ~multiset();
257
258 multiset& operator=(const multiset& s);
Howard Hinnantb2e2a8f2011-06-04 15:22:34259 multiset& operator=(multiset&& s)
260 noexcept(
261 allocator_type::propagate_on_container_move_assignment::value &&
262 is_nothrow_move_assignable<allocator_type>::value &&
263 is_nothrow_move_assignable<key_compare>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16264 multiset& operator=(initializer_list<value_type> il);
265
266 // iterators:
Howard Hinnantb2e2a8f2011-06-04 15:22:34267 iterator begin() noexcept;
268 const_iterator begin() const noexcept;
269 iterator end() noexcept;
270 const_iterator end() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16271
Howard Hinnantb2e2a8f2011-06-04 15:22:34272 reverse_iterator rbegin() noexcept;
273 const_reverse_iterator rbegin() const noexcept;
274 reverse_iterator rend() noexcept;
275 const_reverse_iterator rend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16276
Howard Hinnantb2e2a8f2011-06-04 15:22:34277 const_iterator cbegin() const noexcept;
278 const_iterator cend() const noexcept;
279 const_reverse_iterator crbegin() const noexcept;
280 const_reverse_iterator crend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16281
282 // capacity:
Howard Hinnantb2e2a8f2011-06-04 15:22:34283 bool empty() const noexcept;
284 size_type size() const noexcept;
285 size_type max_size() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16286
287 // modifiers:
288 template <class... Args>
289 iterator emplace(Args&&... args);
290 template <class... Args>
291 iterator emplace_hint(const_iterator position, Args&&... args);
292 iterator insert(const value_type& v);
293 iterator insert(value_type&& v);
294 iterator insert(const_iterator position, const value_type& v);
295 iterator insert(const_iterator position, value_type&& v);
296 template <class InputIterator>
297 void insert(InputIterator first, InputIterator last);
298 void insert(initializer_list<value_type> il);
299
300 iterator erase(const_iterator position);
Marshall Clow488025c2015-05-10 13:35:00301 iterator erase(iterator position); // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16302 size_type erase(const key_type& k);
303 iterator erase(const_iterator first, const_iterator last);
Howard Hinnantb2e2a8f2011-06-04 15:22:34304 void clear() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16305
Howard Hinnantb2e2a8f2011-06-04 15:22:34306 void swap(multiset& s)
307 noexcept(
308 __is_nothrow_swappable<key_compare>::value &&
309 (!allocator_type::propagate_on_container_swap::value ||
310 __is_nothrow_swappable<allocator_type>::value));
Howard Hinnantbc8d3f92010-05-11 19:42:16311
312 // observers:
Howard Hinnantb2e2a8f2011-06-04 15:22:34313 allocator_type get_allocator() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16314 key_compare key_comp() const;
315 value_compare value_comp() const;
316
317 // set operations:
318 iterator find(const key_type& k);
319 const_iterator find(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06320 template<typename K>
321 iterator find(const K& x);
322 template<typename K>
323 const_iterator find(const K& x) const; // C++14
324
Howard Hinnantbc8d3f92010-05-11 19:42:16325 size_type count(const key_type& k) const;
326 iterator lower_bound(const key_type& k);
327 const_iterator lower_bound(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06328 template<typename K>
329 iterator lower_bound(const K& x); // C++14
330 template<typename K>
331 const_iterator lower_bound(const K& x) const; // C++14
332
Howard Hinnantbc8d3f92010-05-11 19:42:16333 iterator upper_bound(const key_type& k);
334 const_iterator upper_bound(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06335 template<typename K>
336 iterator upper_bound(const K& x); // C++14
337 template<typename K>
338 const_iterator upper_bound(const K& x) const; // C++14
339
Howard Hinnantbc8d3f92010-05-11 19:42:16340 pair<iterator,iterator> equal_range(const key_type& k);
341 pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06342 template<typename K>
343 pair<iterator,iterator> equal_range(const K& x); // C++14
344 template<typename K>
345 pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16346};
347
348template <class Key, class Compare, class Allocator>
349bool
350operator==(const multiset<Key, Compare, Allocator>& x,
351 const multiset<Key, Compare, Allocator>& y);
352
353template <class Key, class Compare, class Allocator>
354bool
355operator< (const multiset<Key, Compare, Allocator>& x,
356 const multiset<Key, Compare, Allocator>& y);
357
358template <class Key, class Compare, class Allocator>
359bool
360operator!=(const multiset<Key, Compare, Allocator>& x,
361 const multiset<Key, Compare, Allocator>& y);
362
363template <class Key, class Compare, class Allocator>
364bool
365operator> (const multiset<Key, Compare, Allocator>& x,
366 const multiset<Key, Compare, Allocator>& y);
367
368template <class Key, class Compare, class Allocator>
369bool
370operator>=(const multiset<Key, Compare, Allocator>& x,
371 const multiset<Key, Compare, Allocator>& y);
372
373template <class Key, class Compare, class Allocator>
374bool
375operator<=(const multiset<Key, Compare, Allocator>& x,
376 const multiset<Key, Compare, Allocator>& y);
377
378// specialized algorithms:
379template <class Key, class Compare, class Allocator>
380void
Howard Hinnantb2e2a8f2011-06-04 15:22:34381swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
382 noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16383
384} // std
385
386*/
387
388#include <__config>
389#include <__tree>
390#include <functional>
391
Howard Hinnant08e17472011-10-17 20:05:10392#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16393#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10394#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16395
396_LIBCPP_BEGIN_NAMESPACE_STD
397
398template <class _Key, class _Compare = less<_Key>,
399 class _Allocator = allocator<_Key> >
Howard Hinnant0f678bd2013-08-12 18:38:34400class _LIBCPP_TYPE_VIS_ONLY set
Howard Hinnantbc8d3f92010-05-11 19:42:16401{
402public:
403 // types:
404 typedef _Key key_type;
405 typedef key_type value_type;
406 typedef _Compare key_compare;
407 typedef key_compare value_compare;
408 typedef _Allocator allocator_type;
409 typedef value_type& reference;
410 typedef const value_type& const_reference;
411
Marshall Clow14ba0ad2015-11-26 01:24:04412 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
413 "Allocator::value_type must be same type as value_type");
414
Howard Hinnantbc8d3f92010-05-11 19:42:16415private:
416 typedef __tree<value_type, value_compare, allocator_type> __base;
417 typedef allocator_traits<allocator_type> __alloc_traits;
418 typedef typename __base::__node_holder __node_holder;
419
420 __base __tree_;
421
422public:
423 typedef typename __base::pointer pointer;
424 typedef typename __base::const_pointer const_pointer;
425 typedef typename __base::size_type size_type;
426 typedef typename __base::difference_type difference_type;
427 typedef typename __base::const_iterator iterator;
428 typedef typename __base::const_iterator const_iterator;
Howard Hinnant0949eed2011-06-30 21:18:19429 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
430 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantbc8d3f92010-05-11 19:42:16431
Howard Hinnant28c97e62010-09-23 16:27:36432 _LIBCPP_INLINE_VISIBILITY
Marshall Clowcaaa1412014-03-10 04:50:10433 set()
434 _NOEXCEPT_(
435 is_nothrow_default_constructible<allocator_type>::value &&
436 is_nothrow_default_constructible<key_compare>::value &&
437 is_nothrow_copy_constructible<key_compare>::value)
438 : __tree_(value_compare()) {}
439
440 _LIBCPP_INLINE_VISIBILITY
441 explicit set(const value_compare& __comp)
Howard Hinnantb2e2a8f2011-06-04 15:22:34442 _NOEXCEPT_(
443 is_nothrow_default_constructible<allocator_type>::value &&
Howard Hinnantb2e2a8f2011-06-04 15:22:34444 is_nothrow_copy_constructible<key_compare>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16445 : __tree_(__comp) {}
Marshall Clowcaaa1412014-03-10 04:50:10446
Howard Hinnant28c97e62010-09-23 16:27:36447 _LIBCPP_INLINE_VISIBILITY
Marshall Clow48c74702014-03-05 19:06:20448 explicit set(const value_compare& __comp, const allocator_type& __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16449 : __tree_(__comp, __a) {}
450 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36451 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16452 set(_InputIterator __f, _InputIterator __l,
453 const value_compare& __comp = value_compare())
454 : __tree_(__comp)
455 {
456 insert(__f, __l);
457 }
458
459 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36460 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16461 set(_InputIterator __f, _InputIterator __l, const value_compare& __comp,
462 const allocator_type& __a)
463 : __tree_(__comp, __a)
464 {
465 insert(__f, __l);
466 }
467
Marshall Clow24a7e332013-09-11 00:06:45468#if _LIBCPP_STD_VER > 11
469 template <class _InputIterator>
470 _LIBCPP_INLINE_VISIBILITY
471 set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
472 : set(__f, __l, key_compare(), __a) {}
473#endif
474
Howard Hinnant28c97e62010-09-23 16:27:36475 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16476 set(const set& __s)
477 : __tree_(__s.__tree_)
478 {
479 insert(__s.begin(), __s.end());
480 }
481
Howard Hinnant61aa6012011-07-01 19:24:36482 _LIBCPP_INLINE_VISIBILITY
483 set& operator=(const set& __s)
484 {
485 __tree_ = __s.__tree_;
486 return *this;
487 }
488
Howard Hinnant73d21a42010-09-04 23:28:19489#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36490 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16491 set(set&& __s)
Howard Hinnantb2e2a8f2011-06-04 15:22:34492 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
Howard Hinnant0949eed2011-06-30 21:18:19493 : __tree_(_VSTD::move(__s.__tree_)) {}
Howard Hinnant73d21a42010-09-04 23:28:19494#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16495
Howard Hinnant28c97e62010-09-23 16:27:36496 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16497 explicit set(const allocator_type& __a)
498 : __tree_(__a) {}
499
Howard Hinnant28c97e62010-09-23 16:27:36500 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16501 set(const set& __s, const allocator_type& __a)
502 : __tree_(__s.__tree_.value_comp(), __a)
503 {
504 insert(__s.begin(), __s.end());
505 }
506
Howard Hinnant73d21a42010-09-04 23:28:19507#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16508 set(set&& __s, const allocator_type& __a);
509#endif
510
Howard Hinnante3e32912011-08-12 21:56:02511#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnant28c97e62010-09-23 16:27:36512 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16513 set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
514 : __tree_(__comp)
515 {
516 insert(__il.begin(), __il.end());
517 }
518
Howard Hinnant28c97e62010-09-23 16:27:36519 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16520 set(initializer_list<value_type> __il, const value_compare& __comp,
521 const allocator_type& __a)
522 : __tree_(__comp, __a)
523 {
524 insert(__il.begin(), __il.end());
525 }
526
Marshall Clow24a7e332013-09-11 00:06:45527#if _LIBCPP_STD_VER > 11
528 _LIBCPP_INLINE_VISIBILITY
529 set(initializer_list<value_type> __il, const allocator_type& __a)
530 : set(__il, key_compare(), __a) {}
531#endif
532
Howard Hinnant28c97e62010-09-23 16:27:36533 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16534 set& operator=(initializer_list<value_type> __il)
535 {
536 __tree_.__assign_unique(__il.begin(), __il.end());
537 return *this;
538 }
Howard Hinnante3e32912011-08-12 21:56:02539#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16540
Howard Hinnant73d21a42010-09-04 23:28:19541#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36542 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16543 set& operator=(set&& __s)
Howard Hinnantb2e2a8f2011-06-04 15:22:34544 _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16545 {
Howard Hinnant0949eed2011-06-30 21:18:19546 __tree_ = _VSTD::move(__s.__tree_);
Howard Hinnantbc8d3f92010-05-11 19:42:16547 return *this;
548 }
Howard Hinnant73d21a42010-09-04 23:28:19549#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16550
Howard Hinnant28c97e62010-09-23 16:27:36551 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34552 iterator begin() _NOEXCEPT {return __tree_.begin();}
Howard Hinnant28c97e62010-09-23 16:27:36553 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34554 const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
Howard Hinnant28c97e62010-09-23 16:27:36555 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34556 iterator end() _NOEXCEPT {return __tree_.end();}
Howard Hinnant28c97e62010-09-23 16:27:36557 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34558 const_iterator end() const _NOEXCEPT {return __tree_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:16559
Howard Hinnant28c97e62010-09-23 16:27:36560 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34561 reverse_iterator rbegin() _NOEXCEPT
562 {return reverse_iterator(end());}
Howard Hinnant28c97e62010-09-23 16:27:36563 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34564 const_reverse_iterator rbegin() const _NOEXCEPT
565 {return const_reverse_iterator(end());}
Howard Hinnant28c97e62010-09-23 16:27:36566 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34567 reverse_iterator rend() _NOEXCEPT
568 {return reverse_iterator(begin());}
Howard Hinnant28c97e62010-09-23 16:27:36569 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34570 const_reverse_iterator rend() const _NOEXCEPT
571 {return const_reverse_iterator(begin());}
Howard Hinnantbc8d3f92010-05-11 19:42:16572
Howard Hinnant28c97e62010-09-23 16:27:36573 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34574 const_iterator cbegin() const _NOEXCEPT {return begin();}
Howard Hinnant28c97e62010-09-23 16:27:36575 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34576 const_iterator cend() const _NOEXCEPT {return end();}
Howard Hinnant28c97e62010-09-23 16:27:36577 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34578 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
Howard Hinnant28c97e62010-09-23 16:27:36579 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34580 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
Howard Hinnantbc8d3f92010-05-11 19:42:16581
Howard Hinnant28c97e62010-09-23 16:27:36582 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34583 bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
Howard Hinnant28c97e62010-09-23 16:27:36584 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34585 size_type size() const _NOEXCEPT {return __tree_.size();}
Howard Hinnant28c97e62010-09-23 16:27:36586 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34587 size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:16588
589 // modifiers:
Howard Hinnant73d21a42010-09-04 23:28:19590#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:16591 template <class... _Args>
Howard Hinnant28c97e62010-09-23 16:27:36592 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16593 pair<iterator, bool> emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19594 {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:16595 template <class... _Args>
Howard Hinnant28c97e62010-09-23 16:27:36596 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16597 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19598 {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);}
Howard Hinnant73d21a42010-09-04 23:28:19599#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnant28c97e62010-09-23 16:27:36600 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16601 pair<iterator,bool> insert(const value_type& __v)
602 {return __tree_.__insert_unique(__v);}
Howard Hinnant73d21a42010-09-04 23:28:19603#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36604 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16605 pair<iterator,bool> insert(value_type&& __v)
Howard Hinnant0949eed2011-06-30 21:18:19606 {return __tree_.__insert_unique(_VSTD::move(__v));}
Howard Hinnant73d21a42010-09-04 23:28:19607#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36608 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16609 iterator insert(const_iterator __p, const value_type& __v)
610 {return __tree_.__insert_unique(__p, __v);}
Howard Hinnant73d21a42010-09-04 23:28:19611#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36612 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16613 iterator insert(const_iterator __p, value_type&& __v)
Howard Hinnant0949eed2011-06-30 21:18:19614 {return __tree_.__insert_unique(__p, _VSTD::move(__v));}
Howard Hinnant73d21a42010-09-04 23:28:19615#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16616 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36617 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16618 void insert(_InputIterator __f, _InputIterator __l)
619 {
620 for (const_iterator __e = cend(); __f != __l; ++__f)
621 __tree_.__insert_unique(__e, *__f);
622 }
623
Howard Hinnante3e32912011-08-12 21:56:02624#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnant28c97e62010-09-23 16:27:36625 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16626 void insert(initializer_list<value_type> __il)
627 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:02628#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16629
Howard Hinnant28c97e62010-09-23 16:27:36630 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16631 iterator erase(const_iterator __p) {return __tree_.erase(__p);}
Howard Hinnant28c97e62010-09-23 16:27:36632 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16633 size_type erase(const key_type& __k)
634 {return __tree_.__erase_unique(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36635 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16636 iterator erase(const_iterator __f, const_iterator __l)
637 {return __tree_.erase(__f, __l);}
Howard Hinnant28c97e62010-09-23 16:27:36638 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34639 void clear() _NOEXCEPT {__tree_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:16640
Howard Hinnant28c97e62010-09-23 16:27:36641 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34642 void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
643 {__tree_.swap(__s.__tree_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16644
Howard Hinnant28c97e62010-09-23 16:27:36645 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34646 allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
Howard Hinnant28c97e62010-09-23 16:27:36647 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16648 key_compare key_comp() const {return __tree_.value_comp();}
Howard Hinnant28c97e62010-09-23 16:27:36649 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16650 value_compare value_comp() const {return __tree_.value_comp();}
651
652 // set operations:
Howard Hinnant28c97e62010-09-23 16:27:36653 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16654 iterator find(const key_type& __k) {return __tree_.find(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36655 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16656 const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06657#if _LIBCPP_STD_VER > 11
658 template <typename _K2>
659 _LIBCPP_INLINE_VISIBILITY
660 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
661 find(const _K2& __k) {return __tree_.find(__k);}
662 template <typename _K2>
663 _LIBCPP_INLINE_VISIBILITY
664 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
665 find(const _K2& __k) const {return __tree_.find(__k);}
666#endif
667
Howard Hinnant28c97e62010-09-23 16:27:36668 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16669 size_type count(const key_type& __k) const
670 {return __tree_.__count_unique(__k);}
Marshall Clow4de32042014-08-24 23:54:16671#if _LIBCPP_STD_VER > 11
672 template <typename _K2>
673 _LIBCPP_INLINE_VISIBILITY
674 typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
675 count(const _K2& __k) {return __tree_.__count_unique(__k);}
676#endif
Howard Hinnant28c97e62010-09-23 16:27:36677 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16678 iterator lower_bound(const key_type& __k)
679 {return __tree_.lower_bound(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36680 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16681 const_iterator lower_bound(const key_type& __k) const
682 {return __tree_.lower_bound(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06683#if _LIBCPP_STD_VER > 11
684 template <typename _K2>
685 _LIBCPP_INLINE_VISIBILITY
686 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
687 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
688
689 template <typename _K2>
690 _LIBCPP_INLINE_VISIBILITY
691 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
692 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
693#endif
694
Howard Hinnant28c97e62010-09-23 16:27:36695 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16696 iterator upper_bound(const key_type& __k)
697 {return __tree_.upper_bound(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36698 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16699 const_iterator upper_bound(const key_type& __k) const
700 {return __tree_.upper_bound(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06701#if _LIBCPP_STD_VER > 11
702 template <typename _K2>
703 _LIBCPP_INLINE_VISIBILITY
704 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
705 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
706 template <typename _K2>
707 _LIBCPP_INLINE_VISIBILITY
708 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
709 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
710#endif
711
Howard Hinnant28c97e62010-09-23 16:27:36712 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16713 pair<iterator,iterator> equal_range(const key_type& __k)
714 {return __tree_.__equal_range_unique(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36715 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16716 pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
717 {return __tree_.__equal_range_unique(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06718#if _LIBCPP_STD_VER > 11
719 template <typename _K2>
720 _LIBCPP_INLINE_VISIBILITY
721 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
722 equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);}
723 template <typename _K2>
724 _LIBCPP_INLINE_VISIBILITY
725 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
726 equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);}
727#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16728};
729
Howard Hinnant73d21a42010-09-04 23:28:19730#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16731
732template <class _Key, class _Compare, class _Allocator>
733set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:19734 : __tree_(_VSTD::move(__s.__tree_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16735{
736 if (__a != __s.get_allocator())
737 {
738 const_iterator __e = cend();
739 while (!__s.empty())
Howard Hinnant0949eed2011-06-30 21:18:19740 insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:16741 }
742}
743
Howard Hinnant73d21a42010-09-04 23:28:19744#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16745
746template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36747inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16748bool
749operator==(const set<_Key, _Compare, _Allocator>& __x,
750 const set<_Key, _Compare, _Allocator>& __y)
751{
Howard Hinnant0949eed2011-06-30 21:18:19752 return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
Howard Hinnantbc8d3f92010-05-11 19:42:16753}
754
755template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36756inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16757bool
758operator< (const set<_Key, _Compare, _Allocator>& __x,
759 const set<_Key, _Compare, _Allocator>& __y)
760{
Howard Hinnant0949eed2011-06-30 21:18:19761 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
Howard Hinnantbc8d3f92010-05-11 19:42:16762}
763
764template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36765inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16766bool
767operator!=(const set<_Key, _Compare, _Allocator>& __x,
768 const set<_Key, _Compare, _Allocator>& __y)
769{
770 return !(__x == __y);
771}
772
773template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36774inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16775bool
776operator> (const set<_Key, _Compare, _Allocator>& __x,
777 const set<_Key, _Compare, _Allocator>& __y)
778{
779 return __y < __x;
780}
781
782template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36783inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16784bool
785operator>=(const set<_Key, _Compare, _Allocator>& __x,
786 const set<_Key, _Compare, _Allocator>& __y)
787{
788 return !(__x < __y);
789}
790
791template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36792inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16793bool
794operator<=(const set<_Key, _Compare, _Allocator>& __x,
795 const set<_Key, _Compare, _Allocator>& __y)
796{
797 return !(__y < __x);
798}
799
800// specialized algorithms:
801template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36802inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16803void
804swap(set<_Key, _Compare, _Allocator>& __x,
805 set<_Key, _Compare, _Allocator>& __y)
Howard Hinnantb2e2a8f2011-06-04 15:22:34806 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:16807{
808 __x.swap(__y);
809}
810
Howard Hinnantbc8d3f92010-05-11 19:42:16811template <class _Key, class _Compare = less<_Key>,
812 class _Allocator = allocator<_Key> >
Howard Hinnant0f678bd2013-08-12 18:38:34813class _LIBCPP_TYPE_VIS_ONLY multiset
Howard Hinnantbc8d3f92010-05-11 19:42:16814{
815public:
816 // types:
817 typedef _Key key_type;
818 typedef key_type value_type;
819 typedef _Compare key_compare;
820 typedef key_compare value_compare;
821 typedef _Allocator allocator_type;
822 typedef value_type& reference;
823 typedef const value_type& const_reference;
824
Marshall Clow14ba0ad2015-11-26 01:24:04825 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
826 "Allocator::value_type must be same type as value_type");
827
Howard Hinnantbc8d3f92010-05-11 19:42:16828private:
829 typedef __tree<value_type, value_compare, allocator_type> __base;
830 typedef allocator_traits<allocator_type> __alloc_traits;
831 typedef typename __base::__node_holder __node_holder;
832
833 __base __tree_;
834
835public:
836 typedef typename __base::pointer pointer;
837 typedef typename __base::const_pointer const_pointer;
838 typedef typename __base::size_type size_type;
839 typedef typename __base::difference_type difference_type;
840 typedef typename __base::const_iterator iterator;
841 typedef typename __base::const_iterator const_iterator;
Howard Hinnant0949eed2011-06-30 21:18:19842 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
843 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantbc8d3f92010-05-11 19:42:16844
845 // construct/copy/destroy:
Howard Hinnant28c97e62010-09-23 16:27:36846 _LIBCPP_INLINE_VISIBILITY
Marshall Clowcaaa1412014-03-10 04:50:10847 multiset()
848 _NOEXCEPT_(
849 is_nothrow_default_constructible<allocator_type>::value &&
850 is_nothrow_default_constructible<key_compare>::value &&
851 is_nothrow_copy_constructible<key_compare>::value)
852 : __tree_(value_compare()) {}
853
854 _LIBCPP_INLINE_VISIBILITY
855 explicit multiset(const value_compare& __comp)
Howard Hinnantb2e2a8f2011-06-04 15:22:34856 _NOEXCEPT_(
857 is_nothrow_default_constructible<allocator_type>::value &&
Howard Hinnantb2e2a8f2011-06-04 15:22:34858 is_nothrow_copy_constructible<key_compare>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16859 : __tree_(__comp) {}
Marshall Clowcaaa1412014-03-10 04:50:10860
Howard Hinnant28c97e62010-09-23 16:27:36861 _LIBCPP_INLINE_VISIBILITY
Marshall Clow48c74702014-03-05 19:06:20862 explicit multiset(const value_compare& __comp, const allocator_type& __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16863 : __tree_(__comp, __a) {}
864 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36865 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16866 multiset(_InputIterator __f, _InputIterator __l,
867 const value_compare& __comp = value_compare())
868 : __tree_(__comp)
869 {
870 insert(__f, __l);
871 }
872
Marshall Clow24a7e332013-09-11 00:06:45873#if _LIBCPP_STD_VER > 11
874 template <class _InputIterator>
875 _LIBCPP_INLINE_VISIBILITY
876 multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
877 : multiset(__f, __l, key_compare(), __a) {}
878#endif
879
Howard Hinnantbc8d3f92010-05-11 19:42:16880 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36881 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16882 multiset(_InputIterator __f, _InputIterator __l,
883 const value_compare& __comp, const allocator_type& __a)
884 : __tree_(__comp, __a)
885 {
886 insert(__f, __l);
887 }
888
Howard Hinnant28c97e62010-09-23 16:27:36889 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16890 multiset(const multiset& __s)
891 : __tree_(__s.__tree_.value_comp(),
892 __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc()))
893 {
894 insert(__s.begin(), __s.end());
895 }
896
Howard Hinnant61aa6012011-07-01 19:24:36897 _LIBCPP_INLINE_VISIBILITY
898 multiset& operator=(const multiset& __s)
899 {
900 __tree_ = __s.__tree_;
901 return *this;
902 }
903
Howard Hinnant73d21a42010-09-04 23:28:19904#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36905 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16906 multiset(multiset&& __s)
Howard Hinnantb2e2a8f2011-06-04 15:22:34907 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
Howard Hinnant0949eed2011-06-30 21:18:19908 : __tree_(_VSTD::move(__s.__tree_)) {}
Howard Hinnant73d21a42010-09-04 23:28:19909#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36910 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16911 explicit multiset(const allocator_type& __a)
912 : __tree_(__a) {}
Howard Hinnant28c97e62010-09-23 16:27:36913 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16914 multiset(const multiset& __s, const allocator_type& __a)
915 : __tree_(__s.__tree_.value_comp(), __a)
916 {
917 insert(__s.begin(), __s.end());
918 }
Howard Hinnant73d21a42010-09-04 23:28:19919#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16920 multiset(multiset&& __s, const allocator_type& __a);
921#endif
922
Howard Hinnante3e32912011-08-12 21:56:02923#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnant28c97e62010-09-23 16:27:36924 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16925 multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
926 : __tree_(__comp)
927 {
928 insert(__il.begin(), __il.end());
929 }
930
Howard Hinnant28c97e62010-09-23 16:27:36931 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16932 multiset(initializer_list<value_type> __il, const value_compare& __comp,
933 const allocator_type& __a)
934 : __tree_(__comp, __a)
935 {
936 insert(__il.begin(), __il.end());
937 }
938
Marshall Clow24a7e332013-09-11 00:06:45939#if _LIBCPP_STD_VER > 11
940 _LIBCPP_INLINE_VISIBILITY
941 multiset(initializer_list<value_type> __il, const allocator_type& __a)
942 : multiset(__il, key_compare(), __a) {}
943#endif
944
Howard Hinnant28c97e62010-09-23 16:27:36945 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16946 multiset& operator=(initializer_list<value_type> __il)
947 {
948 __tree_.__assign_multi(__il.begin(), __il.end());
949 return *this;
950 }
Howard Hinnante3e32912011-08-12 21:56:02951#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16952
Howard Hinnant73d21a42010-09-04 23:28:19953#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36954 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16955 multiset& operator=(multiset&& __s)
Howard Hinnantb2e2a8f2011-06-04 15:22:34956 _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16957 {
Howard Hinnant0949eed2011-06-30 21:18:19958 __tree_ = _VSTD::move(__s.__tree_);
Howard Hinnantbc8d3f92010-05-11 19:42:16959 return *this;
960 }
Howard Hinnant73d21a42010-09-04 23:28:19961#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16962
Howard Hinnant28c97e62010-09-23 16:27:36963 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34964 iterator begin() _NOEXCEPT {return __tree_.begin();}
Howard Hinnant28c97e62010-09-23 16:27:36965 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34966 const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
Howard Hinnant28c97e62010-09-23 16:27:36967 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34968 iterator end() _NOEXCEPT {return __tree_.end();}
Howard Hinnant28c97e62010-09-23 16:27:36969 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34970 const_iterator end() const _NOEXCEPT {return __tree_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:16971
Howard Hinnant28c97e62010-09-23 16:27:36972 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34973 reverse_iterator rbegin() _NOEXCEPT
974 {return reverse_iterator(end());}
Howard Hinnant28c97e62010-09-23 16:27:36975 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34976 const_reverse_iterator rbegin() const _NOEXCEPT
977 {return const_reverse_iterator(end());}
Howard Hinnant28c97e62010-09-23 16:27:36978 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34979 reverse_iterator rend() _NOEXCEPT
980 {return reverse_iterator(begin());}
Howard Hinnant28c97e62010-09-23 16:27:36981 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34982 const_reverse_iterator rend() const _NOEXCEPT
983 {return const_reverse_iterator(begin());}
Howard Hinnantbc8d3f92010-05-11 19:42:16984
Howard Hinnant28c97e62010-09-23 16:27:36985 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34986 const_iterator cbegin() const _NOEXCEPT {return begin();}
Howard Hinnant28c97e62010-09-23 16:27:36987 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34988 const_iterator cend() const _NOEXCEPT {return end();}
Howard Hinnant28c97e62010-09-23 16:27:36989 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34990 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
Howard Hinnant28c97e62010-09-23 16:27:36991 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34992 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
Howard Hinnantbc8d3f92010-05-11 19:42:16993
Howard Hinnant28c97e62010-09-23 16:27:36994 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34995 bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
Howard Hinnant28c97e62010-09-23 16:27:36996 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34997 size_type size() const _NOEXCEPT {return __tree_.size();}
Howard Hinnant28c97e62010-09-23 16:27:36998 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34999 size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:161000
1001 // modifiers:
Howard Hinnant73d21a42010-09-04 23:28:191002#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:161003 template <class... _Args>
Howard Hinnant28c97e62010-09-23 16:27:361004 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161005 iterator emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:191006 {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:161007 template <class... _Args>
Howard Hinnant28c97e62010-09-23 16:27:361008 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161009 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:191010 {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
Howard Hinnant73d21a42010-09-04 23:28:191011#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnant28c97e62010-09-23 16:27:361012 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161013 iterator insert(const value_type& __v)
1014 {return __tree_.__insert_multi(__v);}
Howard Hinnant73d21a42010-09-04 23:28:191015#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:361016 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161017 iterator insert(value_type&& __v)
Howard Hinnant0949eed2011-06-30 21:18:191018 {return __tree_.__insert_multi(_VSTD::move(__v));}
Howard Hinnant73d21a42010-09-04 23:28:191019#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:361020 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161021 iterator insert(const_iterator __p, const value_type& __v)
1022 {return __tree_.__insert_multi(__p, __v);}
Howard Hinnant73d21a42010-09-04 23:28:191023#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:361024 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161025 iterator insert(const_iterator __p, value_type&& __v)
Howard Hinnant0949eed2011-06-30 21:18:191026 {return __tree_.__insert_multi(_VSTD::move(__v));}
Howard Hinnant73d21a42010-09-04 23:28:191027#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:161028 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:361029 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161030 void insert(_InputIterator __f, _InputIterator __l)
1031 {
1032 for (const_iterator __e = cend(); __f != __l; ++__f)
1033 __tree_.__insert_multi(__e, *__f);
1034 }
1035
Howard Hinnante3e32912011-08-12 21:56:021036#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnant28c97e62010-09-23 16:27:361037 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161038 void insert(initializer_list<value_type> __il)
1039 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:021040#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:161041
Howard Hinnant28c97e62010-09-23 16:27:361042 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161043 iterator erase(const_iterator __p) {return __tree_.erase(__p);}
Howard Hinnant28c97e62010-09-23 16:27:361044 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161045 size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
Howard Hinnant28c97e62010-09-23 16:27:361046 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161047 iterator erase(const_iterator __f, const_iterator __l)
1048 {return __tree_.erase(__f, __l);}
Howard Hinnant28c97e62010-09-23 16:27:361049 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:341050 void clear() _NOEXCEPT {__tree_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:161051
Howard Hinnant28c97e62010-09-23 16:27:361052 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:341053 void swap(multiset& __s)
1054 _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
1055 {__tree_.swap(__s.__tree_);}
Howard Hinnantbc8d3f92010-05-11 19:42:161056
Howard Hinnant28c97e62010-09-23 16:27:361057 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:341058 allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
Howard Hinnant28c97e62010-09-23 16:27:361059 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161060 key_compare key_comp() const {return __tree_.value_comp();}
Howard Hinnant28c97e62010-09-23 16:27:361061 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161062 value_compare value_comp() const {return __tree_.value_comp();}
1063
1064 // set operations:
Howard Hinnant28c97e62010-09-23 16:27:361065 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161066 iterator find(const key_type& __k) {return __tree_.find(__k);}
Howard Hinnant28c97e62010-09-23 16:27:361067 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161068 const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
Marshall Clow4a0a9812013-08-13 01:11:061069#if _LIBCPP_STD_VER > 11
1070 template <typename _K2>
1071 _LIBCPP_INLINE_VISIBILITY
1072 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
1073 find(const _K2& __k) {return __tree_.find(__k);}
1074 template <typename _K2>
1075 _LIBCPP_INLINE_VISIBILITY
1076 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
1077 find(const _K2& __k) const {return __tree_.find(__k);}
1078#endif
1079
Howard Hinnant28c97e62010-09-23 16:27:361080 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161081 size_type count(const key_type& __k) const
1082 {return __tree_.__count_multi(__k);}
Marshall Clow4de32042014-08-24 23:54:161083#if _LIBCPP_STD_VER > 11
1084 template <typename _K2>
1085 _LIBCPP_INLINE_VISIBILITY
1086 typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
1087 count(const _K2& __k) {return __tree_.__count_multi(__k);}
1088#endif
Marshall Clow4a0a9812013-08-13 01:11:061089
Howard Hinnant28c97e62010-09-23 16:27:361090 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161091 iterator lower_bound(const key_type& __k)
1092 {return __tree_.lower_bound(__k);}
Howard Hinnant28c97e62010-09-23 16:27:361093 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161094 const_iterator lower_bound(const key_type& __k) const
1095 {return __tree_.lower_bound(__k);}
Marshall Clow4a0a9812013-08-13 01:11:061096#if _LIBCPP_STD_VER > 11
1097 template <typename _K2>
1098 _LIBCPP_INLINE_VISIBILITY
1099 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
1100 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
1101
1102 template <typename _K2>
1103 _LIBCPP_INLINE_VISIBILITY
1104 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
1105 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
1106#endif
1107
Howard Hinnant28c97e62010-09-23 16:27:361108 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161109 iterator upper_bound(const key_type& __k)
1110 {return __tree_.upper_bound(__k);}
Howard Hinnant28c97e62010-09-23 16:27:361111 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161112 const_iterator upper_bound(const key_type& __k) const
1113 {return __tree_.upper_bound(__k);}
Marshall Clow4a0a9812013-08-13 01:11:061114#if _LIBCPP_STD_VER > 11
1115 template <typename _K2>
1116 _LIBCPP_INLINE_VISIBILITY
1117 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
1118 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
1119 template <typename _K2>
1120 _LIBCPP_INLINE_VISIBILITY
1121 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
1122 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
1123#endif
1124
Howard Hinnant28c97e62010-09-23 16:27:361125 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161126 pair<iterator,iterator> equal_range(const key_type& __k)
1127 {return __tree_.__equal_range_multi(__k);}
Howard Hinnant28c97e62010-09-23 16:27:361128 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161129 pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
1130 {return __tree_.__equal_range_multi(__k);}
Marshall Clow4a0a9812013-08-13 01:11:061131#if _LIBCPP_STD_VER > 11
1132 template <typename _K2>
1133 _LIBCPP_INLINE_VISIBILITY
1134 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
1135 equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
1136 template <typename _K2>
1137 _LIBCPP_INLINE_VISIBILITY
1138 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
1139 equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
1140#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161141};
1142
Howard Hinnant73d21a42010-09-04 23:28:191143#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:161144
1145template <class _Key, class _Compare, class _Allocator>
1146multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:191147 : __tree_(_VSTD::move(__s.__tree_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:161148{
1149 if (__a != __s.get_allocator())
1150 {
1151 const_iterator __e = cend();
1152 while (!__s.empty())
Howard Hinnant0949eed2011-06-30 21:18:191153 insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:161154 }
1155}
1156
Howard Hinnant73d21a42010-09-04 23:28:191157#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:161158
1159template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:361160inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161161bool
1162operator==(const multiset<_Key, _Compare, _Allocator>& __x,
1163 const multiset<_Key, _Compare, _Allocator>& __y)
1164{
Howard Hinnant0949eed2011-06-30 21:18:191165 return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
Howard Hinnantbc8d3f92010-05-11 19:42:161166}
1167
1168template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:361169inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161170bool
1171operator< (const multiset<_Key, _Compare, _Allocator>& __x,
1172 const multiset<_Key, _Compare, _Allocator>& __y)
1173{
Howard Hinnant0949eed2011-06-30 21:18:191174 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
Howard Hinnantbc8d3f92010-05-11 19:42:161175}
1176
1177template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:361178inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161179bool
1180operator!=(const multiset<_Key, _Compare, _Allocator>& __x,
1181 const multiset<_Key, _Compare, _Allocator>& __y)
1182{
1183 return !(__x == __y);
1184}
1185
1186template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:361187inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161188bool
1189operator> (const multiset<_Key, _Compare, _Allocator>& __x,
1190 const multiset<_Key, _Compare, _Allocator>& __y)
1191{
1192 return __y < __x;
1193}
1194
1195template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:361196inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161197bool
1198operator>=(const multiset<_Key, _Compare, _Allocator>& __x,
1199 const multiset<_Key, _Compare, _Allocator>& __y)
1200{
1201 return !(__x < __y);
1202}
1203
1204template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:361205inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161206bool
1207operator<=(const multiset<_Key, _Compare, _Allocator>& __x,
1208 const multiset<_Key, _Compare, _Allocator>& __y)
1209{
1210 return !(__y < __x);
1211}
1212
1213template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:361214inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161215void
1216swap(multiset<_Key, _Compare, _Allocator>& __x,
1217 multiset<_Key, _Compare, _Allocator>& __y)
Howard Hinnantb2e2a8f2011-06-04 15:22:341218 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:161219{
1220 __x.swap(__y);
1221}
1222
Howard Hinnantbc8d3f92010-05-11 19:42:161223_LIBCPP_END_NAMESPACE_STD
1224
1225#endif // _LIBCPP_SET