blob: 70b8d28f7e5bc18d31905bb6e4340f1889458beb [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- set -------------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-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 Hinnantbc8d3f92010-05-11 19:42:16 +00008//
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:34 +000045 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:16 +000051 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:34 +000059 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:16 +000063 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);
69 ~set();
70
71 set& operator=(const set& s);
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +000072 set& operator=(set&& s)
73 noexcept(
74 allocator_type::propagate_on_container_move_assignment::value &&
75 is_nothrow_move_assignable<allocator_type>::value &&
76 is_nothrow_move_assignable<key_compare>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000077 set& operator=(initializer_list<value_type> il);
78
79 // iterators:
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +000080 iterator begin() noexcept;
81 const_iterator begin() const noexcept;
82 iterator end() noexcept;
83 const_iterator end() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000084
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +000085 reverse_iterator rbegin() noexcept;
86 const_reverse_iterator rbegin() const noexcept;
87 reverse_iterator rend() noexcept;
88 const_reverse_iterator rend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000089
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +000090 const_iterator cbegin() const noexcept;
91 const_iterator cend() const noexcept;
92 const_reverse_iterator crbegin() const noexcept;
93 const_reverse_iterator crend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000094
95 // capacity:
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +000096 bool empty() const noexcept;
97 size_type size() const noexcept;
98 size_type max_size() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000099
100 // modifiers:
101 template <class... Args>
102 pair<iterator, bool> emplace(Args&&... args);
103 template <class... Args>
104 iterator emplace_hint(const_iterator position, Args&&... args);
105 pair<iterator,bool> insert(const value_type& v);
106 pair<iterator,bool> insert(value_type&& v);
107 iterator insert(const_iterator position, const value_type& v);
108 iterator insert(const_iterator position, value_type&& v);
109 template <class InputIterator>
110 void insert(InputIterator first, InputIterator last);
111 void insert(initializer_list<value_type> il);
112
113 iterator erase(const_iterator position);
114 size_type erase(const key_type& k);
115 iterator erase(const_iterator first, const_iterator last);
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000116 void clear() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000117
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000118 void swap(set& s)
119 noexcept(
120 __is_nothrow_swappable<key_compare>::value &&
121 (!allocator_type::propagate_on_container_swap::value ||
122 __is_nothrow_swappable<allocator_type>::value));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000123
124 // observers:
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000125 allocator_type get_allocator() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000126 key_compare key_comp() const;
127 value_compare value_comp() const;
128
129 // set operations:
130 iterator find(const key_type& k);
131 const_iterator find(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06 +0000132 template<typename K>
133 iterator find(const K& x);
134 template<typename K>
135 const_iterator find(const K& x) const; // C++14
136 template<typename K>
137 size_type count(const K& x) const; // C++14
138
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000139 size_type count(const key_type& k) const;
140 iterator lower_bound(const key_type& k);
141 const_iterator lower_bound(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06 +0000142 template<typename K>
143 iterator lower_bound(const K& x); // C++14
144 template<typename K>
145 const_iterator lower_bound(const K& x) const; // C++14
146
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000147 iterator upper_bound(const key_type& k);
148 const_iterator upper_bound(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06 +0000149 template<typename K>
150 iterator upper_bound(const K& x); // C++14
151 template<typename K>
152 const_iterator upper_bound(const K& x) const; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000153 pair<iterator,iterator> equal_range(const key_type& k);
154 pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06 +0000155 template<typename K>
156 pair<iterator,iterator> equal_range(const K& x); // C++14
157 template<typename K>
158 pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000159};
160
161template <class Key, class Compare, class Allocator>
162bool
163operator==(const set<Key, Compare, Allocator>& x,
164 const set<Key, Compare, Allocator>& y);
165
166template <class Key, class Compare, class Allocator>
167bool
168operator< (const set<Key, Compare, Allocator>& x,
169 const set<Key, Compare, Allocator>& y);
170
171template <class Key, class Compare, class Allocator>
172bool
173operator!=(const set<Key, Compare, Allocator>& x,
174 const set<Key, Compare, Allocator>& y);
175
176template <class Key, class Compare, class Allocator>
177bool
178operator> (const set<Key, Compare, Allocator>& x,
179 const set<Key, Compare, Allocator>& y);
180
181template <class Key, class Compare, class Allocator>
182bool
183operator>=(const set<Key, Compare, Allocator>& x,
184 const set<Key, Compare, Allocator>& y);
185
186template <class Key, class Compare, class Allocator>
187bool
188operator<=(const set<Key, Compare, Allocator>& x,
189 const set<Key, Compare, Allocator>& y);
190
191// specialized algorithms:
192template <class Key, class Compare, class Allocator>
193void
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000194swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
195 noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000196
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000197template <class Key, class Compare = less<Key>,
198 class Allocator = allocator<Key>>
199class multiset
200{
201public:
202 // types:
203 typedef Key key_type;
204 typedef key_type value_type;
205 typedef Compare key_compare;
206 typedef key_compare value_compare;
207 typedef Allocator allocator_type;
208 typedef typename allocator_type::reference reference;
209 typedef typename allocator_type::const_reference const_reference;
210 typedef typename allocator_type::size_type size_type;
211 typedef typename allocator_type::difference_type difference_type;
212 typedef typename allocator_type::pointer pointer;
213 typedef typename allocator_type::const_pointer const_pointer;
214
215 typedef implementation-defined iterator;
216 typedef implementation-defined const_iterator;
217 typedef std::reverse_iterator<iterator> reverse_iterator;
218 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
219
220 // construct/copy/destroy:
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000221 multiset()
222 noexcept(
223 is_nothrow_default_constructible<allocator_type>::value &&
224 is_nothrow_default_constructible<key_compare>::value &&
225 is_nothrow_copy_constructible<key_compare>::value);
226 explicit multiset(const value_compare& comp);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000227 multiset(const value_compare& comp, const allocator_type& a);
228 template <class InputIterator>
229 multiset(InputIterator first, InputIterator last,
230 const value_compare& comp = value_compare());
231 template <class InputIterator>
232 multiset(InputIterator first, InputIterator last,
233 const value_compare& comp, const allocator_type& a);
234 multiset(const multiset& s);
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000235 multiset(multiset&& s)
236 noexcept(
237 is_nothrow_move_constructible<allocator_type>::value &&
238 is_nothrow_move_constructible<key_compare>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000239 explicit multiset(const allocator_type& a);
240 multiset(const multiset& s, const allocator_type& a);
241 multiset(multiset&& s, const allocator_type& a);
242 multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
243 multiset(initializer_list<value_type> il, const value_compare& comp,
244 const allocator_type& a);
245 ~multiset();
246
247 multiset& operator=(const multiset& s);
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000248 multiset& operator=(multiset&& s)
249 noexcept(
250 allocator_type::propagate_on_container_move_assignment::value &&
251 is_nothrow_move_assignable<allocator_type>::value &&
252 is_nothrow_move_assignable<key_compare>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000253 multiset& operator=(initializer_list<value_type> il);
254
255 // iterators:
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000256 iterator begin() noexcept;
257 const_iterator begin() const noexcept;
258 iterator end() noexcept;
259 const_iterator end() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000260
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000261 reverse_iterator rbegin() noexcept;
262 const_reverse_iterator rbegin() const noexcept;
263 reverse_iterator rend() noexcept;
264 const_reverse_iterator rend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000265
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000266 const_iterator cbegin() const noexcept;
267 const_iterator cend() const noexcept;
268 const_reverse_iterator crbegin() const noexcept;
269 const_reverse_iterator crend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000270
271 // capacity:
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000272 bool empty() const noexcept;
273 size_type size() const noexcept;
274 size_type max_size() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000275
276 // modifiers:
277 template <class... Args>
278 iterator emplace(Args&&... args);
279 template <class... Args>
280 iterator emplace_hint(const_iterator position, Args&&... args);
281 iterator insert(const value_type& v);
282 iterator insert(value_type&& v);
283 iterator insert(const_iterator position, const value_type& v);
284 iterator insert(const_iterator position, value_type&& v);
285 template <class InputIterator>
286 void insert(InputIterator first, InputIterator last);
287 void insert(initializer_list<value_type> il);
288
289 iterator erase(const_iterator position);
290 size_type erase(const key_type& k);
291 iterator erase(const_iterator first, const_iterator last);
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000292 void clear() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000293
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000294 void swap(multiset& s)
295 noexcept(
296 __is_nothrow_swappable<key_compare>::value &&
297 (!allocator_type::propagate_on_container_swap::value ||
298 __is_nothrow_swappable<allocator_type>::value));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000299
300 // observers:
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000301 allocator_type get_allocator() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000302 key_compare key_comp() const;
303 value_compare value_comp() const;
304
305 // set operations:
306 iterator find(const key_type& k);
307 const_iterator find(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06 +0000308 template<typename K>
309 iterator find(const K& x);
310 template<typename K>
311 const_iterator find(const K& x) const; // C++14
312
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000313 size_type count(const key_type& k) const;
314 iterator lower_bound(const key_type& k);
315 const_iterator lower_bound(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06 +0000316 template<typename K>
317 iterator lower_bound(const K& x); // C++14
318 template<typename K>
319 const_iterator lower_bound(const K& x) const; // C++14
320
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000321 iterator upper_bound(const key_type& k);
322 const_iterator upper_bound(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06 +0000323 template<typename K>
324 iterator upper_bound(const K& x); // C++14
325 template<typename K>
326 const_iterator upper_bound(const K& x) const; // C++14
327
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000328 pair<iterator,iterator> equal_range(const key_type& k);
329 pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
Marshall Clow4a0a9812013-08-13 01:11:06 +0000330 template<typename K>
331 pair<iterator,iterator> equal_range(const K& x); // C++14
332 template<typename K>
333 pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000334};
335
336template <class Key, class Compare, class Allocator>
337bool
338operator==(const multiset<Key, Compare, Allocator>& x,
339 const multiset<Key, Compare, Allocator>& y);
340
341template <class Key, class Compare, class Allocator>
342bool
343operator< (const multiset<Key, Compare, Allocator>& x,
344 const multiset<Key, Compare, Allocator>& y);
345
346template <class Key, class Compare, class Allocator>
347bool
348operator!=(const multiset<Key, Compare, Allocator>& x,
349 const multiset<Key, Compare, Allocator>& y);
350
351template <class Key, class Compare, class Allocator>
352bool
353operator> (const multiset<Key, Compare, Allocator>& x,
354 const multiset<Key, Compare, Allocator>& y);
355
356template <class Key, class Compare, class Allocator>
357bool
358operator>=(const multiset<Key, Compare, Allocator>& x,
359 const multiset<Key, Compare, Allocator>& y);
360
361template <class Key, class Compare, class Allocator>
362bool
363operator<=(const multiset<Key, Compare, Allocator>& x,
364 const multiset<Key, Compare, Allocator>& y);
365
366// specialized algorithms:
367template <class Key, class Compare, class Allocator>
368void
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000369swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
370 noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000371
372} // std
373
374*/
375
376#include <__config>
377#include <__tree>
378#include <functional>
379
Howard Hinnant08e17472011-10-17 20:05:10 +0000380#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000381#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000382#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000383
384_LIBCPP_BEGIN_NAMESPACE_STD
385
386template <class _Key, class _Compare = less<_Key>,
387 class _Allocator = allocator<_Key> >
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000388class _LIBCPP_TYPE_VIS_ONLY set
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000389{
390public:
391 // types:
392 typedef _Key key_type;
393 typedef key_type value_type;
394 typedef _Compare key_compare;
395 typedef key_compare value_compare;
396 typedef _Allocator allocator_type;
397 typedef value_type& reference;
398 typedef const value_type& const_reference;
399
400private:
401 typedef __tree<value_type, value_compare, allocator_type> __base;
402 typedef allocator_traits<allocator_type> __alloc_traits;
403 typedef typename __base::__node_holder __node_holder;
404
405 __base __tree_;
406
407public:
408 typedef typename __base::pointer pointer;
409 typedef typename __base::const_pointer const_pointer;
410 typedef typename __base::size_type size_type;
411 typedef typename __base::difference_type difference_type;
412 typedef typename __base::const_iterator iterator;
413 typedef typename __base::const_iterator const_iterator;
Howard Hinnant0949eed2011-06-30 21:18:19 +0000414 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
415 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000416
Howard Hinnant28c97e62010-09-23 16:27:36 +0000417 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000418 explicit set(const value_compare& __comp = value_compare())
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000419 _NOEXCEPT_(
420 is_nothrow_default_constructible<allocator_type>::value &&
421 is_nothrow_default_constructible<key_compare>::value &&
422 is_nothrow_copy_constructible<key_compare>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000423 : __tree_(__comp) {}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000424 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000425 set(const value_compare& __comp, const allocator_type& __a)
426 : __tree_(__comp, __a) {}
427 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000428 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000429 set(_InputIterator __f, _InputIterator __l,
430 const value_compare& __comp = value_compare())
431 : __tree_(__comp)
432 {
433 insert(__f, __l);
434 }
435
436 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000437 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000438 set(_InputIterator __f, _InputIterator __l, const value_compare& __comp,
439 const allocator_type& __a)
440 : __tree_(__comp, __a)
441 {
442 insert(__f, __l);
443 }
444
Howard Hinnant28c97e62010-09-23 16:27:36 +0000445 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000446 set(const set& __s)
447 : __tree_(__s.__tree_)
448 {
449 insert(__s.begin(), __s.end());
450 }
451
Howard Hinnant61aa6012011-07-01 19:24:36 +0000452 _LIBCPP_INLINE_VISIBILITY
453 set& operator=(const set& __s)
454 {
455 __tree_ = __s.__tree_;
456 return *this;
457 }
458
Howard Hinnant73d21a42010-09-04 23:28:19 +0000459#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000460 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000461 set(set&& __s)
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000462 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000463 : __tree_(_VSTD::move(__s.__tree_)) {}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000464#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000465
Howard Hinnant28c97e62010-09-23 16:27:36 +0000466 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000467 explicit set(const allocator_type& __a)
468 : __tree_(__a) {}
469
Howard Hinnant28c97e62010-09-23 16:27:36 +0000470 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000471 set(const set& __s, const allocator_type& __a)
472 : __tree_(__s.__tree_.value_comp(), __a)
473 {
474 insert(__s.begin(), __s.end());
475 }
476
Howard Hinnant73d21a42010-09-04 23:28:19 +0000477#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000478 set(set&& __s, const allocator_type& __a);
479#endif
480
Howard Hinnante3e32912011-08-12 21:56:02 +0000481#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnant28c97e62010-09-23 16:27:36 +0000482 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000483 set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
484 : __tree_(__comp)
485 {
486 insert(__il.begin(), __il.end());
487 }
488
Howard Hinnant28c97e62010-09-23 16:27:36 +0000489 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000490 set(initializer_list<value_type> __il, const value_compare& __comp,
491 const allocator_type& __a)
492 : __tree_(__comp, __a)
493 {
494 insert(__il.begin(), __il.end());
495 }
496
Howard Hinnant28c97e62010-09-23 16:27:36 +0000497 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000498 set& operator=(initializer_list<value_type> __il)
499 {
500 __tree_.__assign_unique(__il.begin(), __il.end());
501 return *this;
502 }
Howard Hinnante3e32912011-08-12 21:56:02 +0000503#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000504
Howard Hinnant73d21a42010-09-04 23:28:19 +0000505#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000506 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000507 set& operator=(set&& __s)
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000508 _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000509 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000510 __tree_ = _VSTD::move(__s.__tree_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000511 return *this;
512 }
Howard Hinnant73d21a42010-09-04 23:28:19 +0000513#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000514
Howard Hinnant28c97e62010-09-23 16:27:36 +0000515 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000516 iterator begin() _NOEXCEPT {return __tree_.begin();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000517 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000518 const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000519 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000520 iterator end() _NOEXCEPT {return __tree_.end();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000521 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000522 const_iterator end() const _NOEXCEPT {return __tree_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000523
Howard Hinnant28c97e62010-09-23 16:27:36 +0000524 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000525 reverse_iterator rbegin() _NOEXCEPT
526 {return reverse_iterator(end());}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000527 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000528 const_reverse_iterator rbegin() const _NOEXCEPT
529 {return const_reverse_iterator(end());}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000530 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000531 reverse_iterator rend() _NOEXCEPT
532 {return reverse_iterator(begin());}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000533 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000534 const_reverse_iterator rend() const _NOEXCEPT
535 {return const_reverse_iterator(begin());}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000536
Howard Hinnant28c97e62010-09-23 16:27:36 +0000537 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000538 const_iterator cbegin() const _NOEXCEPT {return begin();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000539 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000540 const_iterator cend() const _NOEXCEPT {return end();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000541 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000542 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000543 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000544 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000545
Howard Hinnant28c97e62010-09-23 16:27:36 +0000546 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000547 bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000548 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000549 size_type size() const _NOEXCEPT {return __tree_.size();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000550 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000551 size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000552
553 // modifiers:
Howard Hinnant73d21a42010-09-04 23:28:19 +0000554#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000555 template <class... _Args>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000556 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000557 pair<iterator, bool> emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000558 {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000559 template <class... _Args>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000560 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000561 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000562 {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000563#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnant28c97e62010-09-23 16:27:36 +0000564 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000565 pair<iterator,bool> insert(const value_type& __v)
566 {return __tree_.__insert_unique(__v);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000567#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000568 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000569 pair<iterator,bool> insert(value_type&& __v)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000570 {return __tree_.__insert_unique(_VSTD::move(__v));}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000571#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000572 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000573 iterator insert(const_iterator __p, const value_type& __v)
574 {return __tree_.__insert_unique(__p, __v);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000575#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000576 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000577 iterator insert(const_iterator __p, value_type&& __v)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000578 {return __tree_.__insert_unique(__p, _VSTD::move(__v));}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000579#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000580 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000581 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000582 void insert(_InputIterator __f, _InputIterator __l)
583 {
584 for (const_iterator __e = cend(); __f != __l; ++__f)
585 __tree_.__insert_unique(__e, *__f);
586 }
587
Howard Hinnante3e32912011-08-12 21:56:02 +0000588#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnant28c97e62010-09-23 16:27:36 +0000589 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000590 void insert(initializer_list<value_type> __il)
591 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:02 +0000592#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000593
Howard Hinnant28c97e62010-09-23 16:27:36 +0000594 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000595 iterator erase(const_iterator __p) {return __tree_.erase(__p);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000596 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000597 size_type erase(const key_type& __k)
598 {return __tree_.__erase_unique(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000599 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000600 iterator erase(const_iterator __f, const_iterator __l)
601 {return __tree_.erase(__f, __l);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000602 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000603 void clear() _NOEXCEPT {__tree_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000604
Howard Hinnant28c97e62010-09-23 16:27:36 +0000605 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000606 void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
607 {__tree_.swap(__s.__tree_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000608
Howard Hinnant28c97e62010-09-23 16:27:36 +0000609 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000610 allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000611 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000612 key_compare key_comp() const {return __tree_.value_comp();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000613 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000614 value_compare value_comp() const {return __tree_.value_comp();}
615
616 // set operations:
Howard Hinnant28c97e62010-09-23 16:27:36 +0000617 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000618 iterator find(const key_type& __k) {return __tree_.find(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000619 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000620 const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06 +0000621#if _LIBCPP_STD_VER > 11
622 template <typename _K2>
623 _LIBCPP_INLINE_VISIBILITY
624 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
625 find(const _K2& __k) {return __tree_.find(__k);}
626 template <typename _K2>
627 _LIBCPP_INLINE_VISIBILITY
628 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
629 find(const _K2& __k) const {return __tree_.find(__k);}
630#endif
631
Howard Hinnant28c97e62010-09-23 16:27:36 +0000632 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000633 size_type count(const key_type& __k) const
634 {return __tree_.__count_unique(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000635 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000636 iterator lower_bound(const key_type& __k)
637 {return __tree_.lower_bound(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000638 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000639 const_iterator lower_bound(const key_type& __k) const
640 {return __tree_.lower_bound(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06 +0000641#if _LIBCPP_STD_VER > 11
642 template <typename _K2>
643 _LIBCPP_INLINE_VISIBILITY
644 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
645 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
646
647 template <typename _K2>
648 _LIBCPP_INLINE_VISIBILITY
649 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
650 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
651#endif
652
Howard Hinnant28c97e62010-09-23 16:27:36 +0000653 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000654 iterator upper_bound(const key_type& __k)
655 {return __tree_.upper_bound(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000656 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000657 const_iterator upper_bound(const key_type& __k) const
658 {return __tree_.upper_bound(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06 +0000659#if _LIBCPP_STD_VER > 11
660 template <typename _K2>
661 _LIBCPP_INLINE_VISIBILITY
662 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
663 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
664 template <typename _K2>
665 _LIBCPP_INLINE_VISIBILITY
666 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
667 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
668#endif
669
Howard Hinnant28c97e62010-09-23 16:27:36 +0000670 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000671 pair<iterator,iterator> equal_range(const key_type& __k)
672 {return __tree_.__equal_range_unique(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000673 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000674 pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
675 {return __tree_.__equal_range_unique(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06 +0000676#if _LIBCPP_STD_VER > 11
677 template <typename _K2>
678 _LIBCPP_INLINE_VISIBILITY
679 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
680 equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);}
681 template <typename _K2>
682 _LIBCPP_INLINE_VISIBILITY
683 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
684 equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);}
685#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000686};
687
Howard Hinnant73d21a42010-09-04 23:28:19 +0000688#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000689
690template <class _Key, class _Compare, class _Allocator>
691set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000692 : __tree_(_VSTD::move(__s.__tree_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000693{
694 if (__a != __s.get_allocator())
695 {
696 const_iterator __e = cend();
697 while (!__s.empty())
Howard Hinnant0949eed2011-06-30 21:18:19 +0000698 insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000699 }
700}
701
Howard Hinnant73d21a42010-09-04 23:28:19 +0000702#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000703
704template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000705inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000706bool
707operator==(const set<_Key, _Compare, _Allocator>& __x,
708 const set<_Key, _Compare, _Allocator>& __y)
709{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000710 return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000711}
712
713template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000714inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000715bool
716operator< (const set<_Key, _Compare, _Allocator>& __x,
717 const set<_Key, _Compare, _Allocator>& __y)
718{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000719 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000720}
721
722template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000723inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000724bool
725operator!=(const set<_Key, _Compare, _Allocator>& __x,
726 const set<_Key, _Compare, _Allocator>& __y)
727{
728 return !(__x == __y);
729}
730
731template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000732inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000733bool
734operator> (const set<_Key, _Compare, _Allocator>& __x,
735 const set<_Key, _Compare, _Allocator>& __y)
736{
737 return __y < __x;
738}
739
740template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000741inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000742bool
743operator>=(const set<_Key, _Compare, _Allocator>& __x,
744 const set<_Key, _Compare, _Allocator>& __y)
745{
746 return !(__x < __y);
747}
748
749template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000750inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000751bool
752operator<=(const set<_Key, _Compare, _Allocator>& __x,
753 const set<_Key, _Compare, _Allocator>& __y)
754{
755 return !(__y < __x);
756}
757
758// specialized algorithms:
759template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000760inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000761void
762swap(set<_Key, _Compare, _Allocator>& __x,
763 set<_Key, _Compare, _Allocator>& __y)
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000764 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000765{
766 __x.swap(__y);
767}
768
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000769template <class _Key, class _Compare = less<_Key>,
770 class _Allocator = allocator<_Key> >
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000771class _LIBCPP_TYPE_VIS_ONLY multiset
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000772{
773public:
774 // types:
775 typedef _Key key_type;
776 typedef key_type value_type;
777 typedef _Compare key_compare;
778 typedef key_compare value_compare;
779 typedef _Allocator allocator_type;
780 typedef value_type& reference;
781 typedef const value_type& const_reference;
782
783private:
784 typedef __tree<value_type, value_compare, allocator_type> __base;
785 typedef allocator_traits<allocator_type> __alloc_traits;
786 typedef typename __base::__node_holder __node_holder;
787
788 __base __tree_;
789
790public:
791 typedef typename __base::pointer pointer;
792 typedef typename __base::const_pointer const_pointer;
793 typedef typename __base::size_type size_type;
794 typedef typename __base::difference_type difference_type;
795 typedef typename __base::const_iterator iterator;
796 typedef typename __base::const_iterator const_iterator;
Howard Hinnant0949eed2011-06-30 21:18:19 +0000797 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
798 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000799
800 // construct/copy/destroy:
Howard Hinnant28c97e62010-09-23 16:27:36 +0000801 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000802 explicit multiset(const value_compare& __comp = value_compare())
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000803 _NOEXCEPT_(
804 is_nothrow_default_constructible<allocator_type>::value &&
805 is_nothrow_default_constructible<key_compare>::value &&
806 is_nothrow_copy_constructible<key_compare>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000807 : __tree_(__comp) {}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000808 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000809 multiset(const value_compare& __comp, const allocator_type& __a)
810 : __tree_(__comp, __a) {}
811 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000812 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000813 multiset(_InputIterator __f, _InputIterator __l,
814 const value_compare& __comp = value_compare())
815 : __tree_(__comp)
816 {
817 insert(__f, __l);
818 }
819
820 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000821 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000822 multiset(_InputIterator __f, _InputIterator __l,
823 const value_compare& __comp, const allocator_type& __a)
824 : __tree_(__comp, __a)
825 {
826 insert(__f, __l);
827 }
828
Howard Hinnant28c97e62010-09-23 16:27:36 +0000829 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000830 multiset(const multiset& __s)
831 : __tree_(__s.__tree_.value_comp(),
832 __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc()))
833 {
834 insert(__s.begin(), __s.end());
835 }
836
Howard Hinnant61aa6012011-07-01 19:24:36 +0000837 _LIBCPP_INLINE_VISIBILITY
838 multiset& operator=(const multiset& __s)
839 {
840 __tree_ = __s.__tree_;
841 return *this;
842 }
843
Howard Hinnant73d21a42010-09-04 23:28:19 +0000844#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000845 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000846 multiset(multiset&& __s)
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000847 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000848 : __tree_(_VSTD::move(__s.__tree_)) {}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000849#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000850 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000851 explicit multiset(const allocator_type& __a)
852 : __tree_(__a) {}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000853 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000854 multiset(const multiset& __s, const allocator_type& __a)
855 : __tree_(__s.__tree_.value_comp(), __a)
856 {
857 insert(__s.begin(), __s.end());
858 }
Howard Hinnant73d21a42010-09-04 23:28:19 +0000859#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000860 multiset(multiset&& __s, const allocator_type& __a);
861#endif
862
Howard Hinnante3e32912011-08-12 21:56:02 +0000863#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnant28c97e62010-09-23 16:27:36 +0000864 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000865 multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
866 : __tree_(__comp)
867 {
868 insert(__il.begin(), __il.end());
869 }
870
Howard Hinnant28c97e62010-09-23 16:27:36 +0000871 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000872 multiset(initializer_list<value_type> __il, const value_compare& __comp,
873 const allocator_type& __a)
874 : __tree_(__comp, __a)
875 {
876 insert(__il.begin(), __il.end());
877 }
878
Howard Hinnant28c97e62010-09-23 16:27:36 +0000879 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000880 multiset& operator=(initializer_list<value_type> __il)
881 {
882 __tree_.__assign_multi(__il.begin(), __il.end());
883 return *this;
884 }
Howard Hinnante3e32912011-08-12 21:56:02 +0000885#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000886
Howard Hinnant73d21a42010-09-04 23:28:19 +0000887#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000888 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000889 multiset& operator=(multiset&& __s)
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000890 _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000891 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000892 __tree_ = _VSTD::move(__s.__tree_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000893 return *this;
894 }
Howard Hinnant73d21a42010-09-04 23:28:19 +0000895#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000896
Howard Hinnant28c97e62010-09-23 16:27:36 +0000897 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000898 iterator begin() _NOEXCEPT {return __tree_.begin();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000899 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000900 const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000901 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000902 iterator end() _NOEXCEPT {return __tree_.end();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000903 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000904 const_iterator end() const _NOEXCEPT {return __tree_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000905
Howard Hinnant28c97e62010-09-23 16:27:36 +0000906 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000907 reverse_iterator rbegin() _NOEXCEPT
908 {return reverse_iterator(end());}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000909 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000910 const_reverse_iterator rbegin() const _NOEXCEPT
911 {return const_reverse_iterator(end());}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000912 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000913 reverse_iterator rend() _NOEXCEPT
914 {return reverse_iterator(begin());}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000915 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000916 const_reverse_iterator rend() const _NOEXCEPT
917 {return const_reverse_iterator(begin());}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000918
Howard Hinnant28c97e62010-09-23 16:27:36 +0000919 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000920 const_iterator cbegin() const _NOEXCEPT {return begin();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000921 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000922 const_iterator cend() const _NOEXCEPT {return end();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000923 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000924 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000925 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000926 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000927
Howard Hinnant28c97e62010-09-23 16:27:36 +0000928 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000929 bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000930 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000931 size_type size() const _NOEXCEPT {return __tree_.size();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000932 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000933 size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000934
935 // modifiers:
Howard Hinnant73d21a42010-09-04 23:28:19 +0000936#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000937 template <class... _Args>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000938 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000939 iterator emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000940 {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000941 template <class... _Args>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000942 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000943 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000944 {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000945#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnant28c97e62010-09-23 16:27:36 +0000946 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000947 iterator insert(const value_type& __v)
948 {return __tree_.__insert_multi(__v);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000949#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000950 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000951 iterator insert(value_type&& __v)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000952 {return __tree_.__insert_multi(_VSTD::move(__v));}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000953#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000954 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000955 iterator insert(const_iterator __p, const value_type& __v)
956 {return __tree_.__insert_multi(__p, __v);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000957#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant28c97e62010-09-23 16:27:36 +0000958 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000959 iterator insert(const_iterator __p, value_type&& __v)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000960 {return __tree_.__insert_multi(_VSTD::move(__v));}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000961#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000962 template <class _InputIterator>
Howard Hinnant28c97e62010-09-23 16:27:36 +0000963 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000964 void insert(_InputIterator __f, _InputIterator __l)
965 {
966 for (const_iterator __e = cend(); __f != __l; ++__f)
967 __tree_.__insert_multi(__e, *__f);
968 }
969
Howard Hinnante3e32912011-08-12 21:56:02 +0000970#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnant28c97e62010-09-23 16:27:36 +0000971 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000972 void insert(initializer_list<value_type> __il)
973 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:02 +0000974#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000975
Howard Hinnant28c97e62010-09-23 16:27:36 +0000976 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000977 iterator erase(const_iterator __p) {return __tree_.erase(__p);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000978 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000979 size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000980 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000981 iterator erase(const_iterator __f, const_iterator __l)
982 {return __tree_.erase(__f, __l);}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000983 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000984 void clear() _NOEXCEPT {__tree_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000985
Howard Hinnant28c97e62010-09-23 16:27:36 +0000986 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000987 void swap(multiset& __s)
988 _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
989 {__tree_.swap(__s.__tree_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000990
Howard Hinnant28c97e62010-09-23 16:27:36 +0000991 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +0000992 allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000993 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000994 key_compare key_comp() const {return __tree_.value_comp();}
Howard Hinnant28c97e62010-09-23 16:27:36 +0000995 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000996 value_compare value_comp() const {return __tree_.value_comp();}
997
998 // set operations:
Howard Hinnant28c97e62010-09-23 16:27:36 +0000999 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001000 iterator find(const key_type& __k) {return __tree_.find(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +00001001 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001002 const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06 +00001003#if _LIBCPP_STD_VER > 11
1004 template <typename _K2>
1005 _LIBCPP_INLINE_VISIBILITY
1006 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
1007 find(const _K2& __k) {return __tree_.find(__k);}
1008 template <typename _K2>
1009 _LIBCPP_INLINE_VISIBILITY
1010 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
1011 find(const _K2& __k) const {return __tree_.find(__k);}
1012#endif
1013
Howard Hinnant28c97e62010-09-23 16:27:36 +00001014 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001015 size_type count(const key_type& __k) const
1016 {return __tree_.__count_multi(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06 +00001017
Howard Hinnant28c97e62010-09-23 16:27:36 +00001018 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001019 iterator lower_bound(const key_type& __k)
1020 {return __tree_.lower_bound(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +00001021 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001022 const_iterator lower_bound(const key_type& __k) const
1023 {return __tree_.lower_bound(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06 +00001024#if _LIBCPP_STD_VER > 11
1025 template <typename _K2>
1026 _LIBCPP_INLINE_VISIBILITY
1027 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
1028 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
1029
1030 template <typename _K2>
1031 _LIBCPP_INLINE_VISIBILITY
1032 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
1033 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
1034#endif
1035
Howard Hinnant28c97e62010-09-23 16:27:36 +00001036 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001037 iterator upper_bound(const key_type& __k)
1038 {return __tree_.upper_bound(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +00001039 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001040 const_iterator upper_bound(const key_type& __k) const
1041 {return __tree_.upper_bound(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06 +00001042#if _LIBCPP_STD_VER > 11
1043 template <typename _K2>
1044 _LIBCPP_INLINE_VISIBILITY
1045 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
1046 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
1047 template <typename _K2>
1048 _LIBCPP_INLINE_VISIBILITY
1049 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
1050 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
1051#endif
1052
Howard Hinnant28c97e62010-09-23 16:27:36 +00001053 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001054 pair<iterator,iterator> equal_range(const key_type& __k)
1055 {return __tree_.__equal_range_multi(__k);}
Howard Hinnant28c97e62010-09-23 16:27:36 +00001056 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001057 pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
1058 {return __tree_.__equal_range_multi(__k);}
Marshall Clow4a0a9812013-08-13 01:11:06 +00001059#if _LIBCPP_STD_VER > 11
1060 template <typename _K2>
1061 _LIBCPP_INLINE_VISIBILITY
1062 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
1063 equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
1064 template <typename _K2>
1065 _LIBCPP_INLINE_VISIBILITY
1066 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
1067 equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
1068#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001069};
1070
Howard Hinnant73d21a42010-09-04 23:28:19 +00001071#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001072
1073template <class _Key, class _Compare, class _Allocator>
1074multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001075 : __tree_(_VSTD::move(__s.__tree_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001076{
1077 if (__a != __s.get_allocator())
1078 {
1079 const_iterator __e = cend();
1080 while (!__s.empty())
Howard Hinnant0949eed2011-06-30 21:18:19 +00001081 insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001082 }
1083}
1084
Howard Hinnant73d21a42010-09-04 23:28:19 +00001085#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001086
1087template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +00001088inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001089bool
1090operator==(const multiset<_Key, _Compare, _Allocator>& __x,
1091 const multiset<_Key, _Compare, _Allocator>& __y)
1092{
Howard Hinnant0949eed2011-06-30 21:18:19 +00001093 return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001094}
1095
1096template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +00001097inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001098bool
1099operator< (const multiset<_Key, _Compare, _Allocator>& __x,
1100 const multiset<_Key, _Compare, _Allocator>& __y)
1101{
Howard Hinnant0949eed2011-06-30 21:18:19 +00001102 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001103}
1104
1105template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +00001106inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001107bool
1108operator!=(const multiset<_Key, _Compare, _Allocator>& __x,
1109 const multiset<_Key, _Compare, _Allocator>& __y)
1110{
1111 return !(__x == __y);
1112}
1113
1114template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +00001115inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001116bool
1117operator> (const multiset<_Key, _Compare, _Allocator>& __x,
1118 const multiset<_Key, _Compare, _Allocator>& __y)
1119{
1120 return __y < __x;
1121}
1122
1123template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +00001124inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001125bool
1126operator>=(const multiset<_Key, _Compare, _Allocator>& __x,
1127 const multiset<_Key, _Compare, _Allocator>& __y)
1128{
1129 return !(__x < __y);
1130}
1131
1132template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +00001133inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001134bool
1135operator<=(const multiset<_Key, _Compare, _Allocator>& __x,
1136 const multiset<_Key, _Compare, _Allocator>& __y)
1137{
1138 return !(__y < __x);
1139}
1140
1141template <class _Key, class _Compare, class _Allocator>
Howard Hinnant28c97e62010-09-23 16:27:36 +00001142inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001143void
1144swap(multiset<_Key, _Compare, _Allocator>& __x,
1145 multiset<_Key, _Compare, _Allocator>& __y)
Howard Hinnantb2e2a8f2011-06-04 15:22:34 +00001146 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001147{
1148 __x.swap(__y);
1149}
1150
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001151_LIBCPP_END_NAMESPACE_STD
1152
1153#endif // _LIBCPP_SET