blob: 70ab4d37add208788ba0a6612b58bc7897bfa516 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- set -------------------------------------===//
3//
Chandler Carruthd2012102019-01-19 10:56:40 +00004// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnantc51e1022010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_SET
11#define _LIBCPP_SET
12
13/*
14
15 set synopsis
16
17namespace std
18{
19
20template <class Key, class Compare = less<Key>,
21 class Allocator = allocator<Key>>
22class set
23{
24public:
25 // types:
26 typedef Key key_type;
27 typedef key_type value_type;
28 typedef Compare key_compare;
29 typedef key_compare value_compare;
30 typedef Allocator allocator_type;
31 typedef typename allocator_type::reference reference;
32 typedef typename allocator_type::const_reference const_reference;
33 typedef typename allocator_type::size_type size_type;
34 typedef typename allocator_type::difference_type difference_type;
35 typedef typename allocator_type::pointer pointer;
36 typedef typename allocator_type::const_pointer const_pointer;
37
38 typedef implementation-defined iterator;
39 typedef implementation-defined const_iterator;
40 typedef std::reverse_iterator<iterator> reverse_iterator;
41 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +000042 typedef unspecified node_type; // C++17
43 typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +000044
45 // construct/copy/destroy:
Howard Hinnantf95f4f52011-06-04 15:22:34 +000046 set()
47 noexcept(
48 is_nothrow_default_constructible<allocator_type>::value &&
49 is_nothrow_default_constructible<key_compare>::value &&
50 is_nothrow_copy_constructible<key_compare>::value);
51 explicit set(const value_compare& comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +000052 set(const value_compare& comp, const allocator_type& a);
53 template <class InputIterator>
54 set(InputIterator first, InputIterator last,
55 const value_compare& comp = value_compare());
56 template <class InputIterator>
57 set(InputIterator first, InputIterator last, const value_compare& comp,
58 const allocator_type& a);
59 set(const set& s);
Howard Hinnantf95f4f52011-06-04 15:22:34 +000060 set(set&& s)
61 noexcept(
62 is_nothrow_move_constructible<allocator_type>::value &&
63 is_nothrow_move_constructible<key_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +000064 explicit set(const allocator_type& a);
65 set(const set& s, const allocator_type& a);
66 set(set&& s, const allocator_type& a);
67 set(initializer_list<value_type> il, const value_compare& comp = value_compare());
68 set(initializer_list<value_type> il, const value_compare& comp,
69 const allocator_type& a);
Marshall Clow631788a2013-09-11 00:06:45 +000070 template <class InputIterator>
71 set(InputIterator first, InputIterator last, const allocator_type& a)
72 : set(first, last, Compare(), a) {} // C++14
73 set(initializer_list<value_type> il, const allocator_type& a)
74 : set(il, Compare(), a) {} // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +000075 ~set();
76
77 set& operator=(const set& s);
Howard Hinnantf95f4f52011-06-04 15:22:34 +000078 set& operator=(set&& s)
79 noexcept(
80 allocator_type::propagate_on_container_move_assignment::value &&
81 is_nothrow_move_assignable<allocator_type>::value &&
82 is_nothrow_move_assignable<key_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +000083 set& operator=(initializer_list<value_type> il);
84
85 // iterators:
Howard Hinnantf95f4f52011-06-04 15:22:34 +000086 iterator begin() noexcept;
87 const_iterator begin() const noexcept;
88 iterator end() noexcept;
89 const_iterator end() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +000090
Howard Hinnantf95f4f52011-06-04 15:22:34 +000091 reverse_iterator rbegin() noexcept;
92 const_reverse_iterator rbegin() const noexcept;
93 reverse_iterator rend() noexcept;
94 const_reverse_iterator rend() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +000095
Howard Hinnantf95f4f52011-06-04 15:22:34 +000096 const_iterator cbegin() const noexcept;
97 const_iterator cend() const noexcept;
98 const_reverse_iterator crbegin() const noexcept;
99 const_reverse_iterator crend() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000100
101 // capacity:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000102 bool empty() const noexcept;
103 size_type size() const noexcept;
104 size_type max_size() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000105
106 // modifiers:
107 template <class... Args>
108 pair<iterator, bool> emplace(Args&&... args);
109 template <class... Args>
110 iterator emplace_hint(const_iterator position, Args&&... args);
111 pair<iterator,bool> insert(const value_type& v);
112 pair<iterator,bool> insert(value_type&& v);
113 iterator insert(const_iterator position, const value_type& v);
114 iterator insert(const_iterator position, value_type&& v);
115 template <class InputIterator>
116 void insert(InputIterator first, InputIterator last);
117 void insert(initializer_list<value_type> il);
118
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +0000119 node_type extract(const_iterator position); // C++17
120 node_type extract(const key_type& x); // C++17
121 insert_return_type insert(node_type&& nh); // C++17
122 iterator insert(const_iterator hint, node_type&& nh); // C++17
123
Howard Hinnantc51e1022010-05-11 19:42:16 +0000124 iterator erase(const_iterator position);
Marshall Clow22ea5b82015-05-10 13:35:00 +0000125 iterator erase(iterator position); // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000126 size_type erase(const key_type& k);
127 iterator erase(const_iterator first, const_iterator last);
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000128 void clear() noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000129
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000130 template<class C2>
131 void merge(set<Key, C2, Allocator>& source); // C++17
132 template<class C2>
133 void merge(set<Key, C2, Allocator>&& source); // C++17
134 template<class C2>
135 void merge(multiset<Key, C2, Allocator>& source); // C++17
136 template<class C2>
137 void merge(multiset<Key, C2, Allocator>&& source); // C++17
138
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000139 void swap(set& s)
140 noexcept(
141 __is_nothrow_swappable<key_compare>::value &&
142 (!allocator_type::propagate_on_container_swap::value ||
143 __is_nothrow_swappable<allocator_type>::value));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000144
145 // observers:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000146 allocator_type get_allocator() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000147 key_compare key_comp() const;
148 value_compare value_comp() const;
149
150 // set operations:
151 iterator find(const key_type& k);
152 const_iterator find(const key_type& k) const;
Marshall Clowc0152142013-08-13 01:11:06 +0000153 template<typename K>
154 iterator find(const K& x);
155 template<typename K>
156 const_iterator find(const K& x) const; // C++14
157 template<typename K>
Zoe Carver3ffbab12019-07-16 03:21:01 +0000158 size_type count(const K& x) const; // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000159 size_type count(const key_type& k) const;
Zoe Carver3ffbab12019-07-16 03:21:01 +0000160 bool contains(const key_type& x) const; // C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000161 iterator lower_bound(const key_type& k);
162 const_iterator lower_bound(const key_type& k) const;
Marshall Clowc0152142013-08-13 01:11:06 +0000163 template<typename K>
164 iterator lower_bound(const K& x); // C++14
165 template<typename K>
166 const_iterator lower_bound(const K& x) const; // C++14
167
Howard Hinnantc51e1022010-05-11 19:42:16 +0000168 iterator upper_bound(const key_type& k);
169 const_iterator upper_bound(const key_type& k) const;
Marshall Clowc0152142013-08-13 01:11:06 +0000170 template<typename K>
171 iterator upper_bound(const K& x); // C++14
172 template<typename K>
173 const_iterator upper_bound(const K& x) const; // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000174 pair<iterator,iterator> equal_range(const key_type& k);
175 pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
Marshall Clowc0152142013-08-13 01:11:06 +0000176 template<typename K>
177 pair<iterator,iterator> equal_range(const K& x); // C++14
178 template<typename K>
179 pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000180};
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
197template <class Key, class Compare, class Allocator>
198bool
199operator> (const set<Key, Compare, Allocator>& x,
200 const set<Key, Compare, Allocator>& y);
201
202template <class Key, class Compare, class Allocator>
203bool
204operator>=(const set<Key, Compare, Allocator>& x,
205 const set<Key, Compare, Allocator>& y);
206
207template <class Key, class Compare, class Allocator>
208bool
209operator<=(const set<Key, Compare, Allocator>& x,
210 const set<Key, Compare, Allocator>& y);
211
212// specialized algorithms:
213template <class Key, class Compare, class Allocator>
214void
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000215swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
216 noexcept(noexcept(x.swap(y)));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000217
Marshall Clow29b53f22018-12-14 18:49:35 +0000218template <class Key, class Compare, class Allocator, class Predicate>
219 void erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20
220
Howard Hinnantc51e1022010-05-11 19:42:16 +0000221template <class Key, class Compare = less<Key>,
222 class Allocator = allocator<Key>>
223class multiset
224{
225public:
226 // types:
227 typedef Key key_type;
228 typedef key_type value_type;
229 typedef Compare key_compare;
230 typedef key_compare value_compare;
231 typedef Allocator allocator_type;
232 typedef typename allocator_type::reference reference;
233 typedef typename allocator_type::const_reference const_reference;
234 typedef typename allocator_type::size_type size_type;
235 typedef typename allocator_type::difference_type difference_type;
236 typedef typename allocator_type::pointer pointer;
237 typedef typename allocator_type::const_pointer const_pointer;
238
239 typedef implementation-defined iterator;
240 typedef implementation-defined const_iterator;
241 typedef std::reverse_iterator<iterator> reverse_iterator;
242 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +0000243 typedef unspecified node_type; // C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +0000244
245 // construct/copy/destroy:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000246 multiset()
247 noexcept(
248 is_nothrow_default_constructible<allocator_type>::value &&
249 is_nothrow_default_constructible<key_compare>::value &&
250 is_nothrow_copy_constructible<key_compare>::value);
251 explicit multiset(const value_compare& comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000252 multiset(const value_compare& comp, const allocator_type& a);
253 template <class InputIterator>
254 multiset(InputIterator first, InputIterator last,
255 const value_compare& comp = value_compare());
256 template <class InputIterator>
257 multiset(InputIterator first, InputIterator last,
258 const value_compare& comp, const allocator_type& a);
259 multiset(const multiset& s);
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000260 multiset(multiset&& s)
261 noexcept(
262 is_nothrow_move_constructible<allocator_type>::value &&
263 is_nothrow_move_constructible<key_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000264 explicit multiset(const allocator_type& a);
265 multiset(const multiset& s, const allocator_type& a);
266 multiset(multiset&& s, const allocator_type& a);
267 multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
268 multiset(initializer_list<value_type> il, const value_compare& comp,
269 const allocator_type& a);
Marshall Clow631788a2013-09-11 00:06:45 +0000270 template <class InputIterator>
271 multiset(InputIterator first, InputIterator last, const allocator_type& a)
272 : set(first, last, Compare(), a) {} // C++14
273 multiset(initializer_list<value_type> il, const allocator_type& a)
274 : set(il, Compare(), a) {} // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000275 ~multiset();
276
277 multiset& operator=(const multiset& s);
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000278 multiset& operator=(multiset&& s)
279 noexcept(
280 allocator_type::propagate_on_container_move_assignment::value &&
281 is_nothrow_move_assignable<allocator_type>::value &&
282 is_nothrow_move_assignable<key_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000283 multiset& operator=(initializer_list<value_type> il);
284
285 // iterators:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000286 iterator begin() noexcept;
287 const_iterator begin() const noexcept;
288 iterator end() noexcept;
289 const_iterator end() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000290
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000291 reverse_iterator rbegin() noexcept;
292 const_reverse_iterator rbegin() const noexcept;
293 reverse_iterator rend() noexcept;
294 const_reverse_iterator rend() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000295
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000296 const_iterator cbegin() const noexcept;
297 const_iterator cend() const noexcept;
298 const_reverse_iterator crbegin() const noexcept;
299 const_reverse_iterator crend() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000300
301 // capacity:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000302 bool empty() const noexcept;
303 size_type size() const noexcept;
304 size_type max_size() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000305
306 // modifiers:
307 template <class... Args>
308 iterator emplace(Args&&... args);
309 template <class... Args>
310 iterator emplace_hint(const_iterator position, Args&&... args);
311 iterator insert(const value_type& v);
312 iterator insert(value_type&& v);
313 iterator insert(const_iterator position, const value_type& v);
314 iterator insert(const_iterator position, value_type&& v);
315 template <class InputIterator>
316 void insert(InputIterator first, InputIterator last);
317 void insert(initializer_list<value_type> il);
318
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +0000319 node_type extract(const_iterator position); // C++17
320 node_type extract(const key_type& x); // C++17
321 iterator insert(node_type&& nh); // C++17
322 iterator insert(const_iterator hint, node_type&& nh); // C++17
323
Howard Hinnantc51e1022010-05-11 19:42:16 +0000324 iterator erase(const_iterator position);
Marshall Clow22ea5b82015-05-10 13:35:00 +0000325 iterator erase(iterator position); // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000326 size_type erase(const key_type& k);
327 iterator erase(const_iterator first, const_iterator last);
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000328 void clear() noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000329
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000330 template<class C2>
331 void merge(multiset<Key, C2, Allocator>& source); // C++17
332 template<class C2>
333 void merge(multiset<Key, C2, Allocator>&& source); // C++17
334 template<class C2>
335 void merge(set<Key, C2, Allocator>& source); // C++17
336 template<class C2>
337 void merge(set<Key, C2, Allocator>&& source); // C++17
338
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000339 void swap(multiset& s)
340 noexcept(
341 __is_nothrow_swappable<key_compare>::value &&
342 (!allocator_type::propagate_on_container_swap::value ||
343 __is_nothrow_swappable<allocator_type>::value));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000344
345 // observers:
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000346 allocator_type get_allocator() const noexcept;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000347 key_compare key_comp() const;
348 value_compare value_comp() const;
349
350 // set operations:
351 iterator find(const key_type& k);
352 const_iterator find(const key_type& k) const;
Marshall Clowc0152142013-08-13 01:11:06 +0000353 template<typename K>
354 iterator find(const K& x);
355 template<typename K>
356 const_iterator find(const K& x) const; // C++14
Zoe Carver3ffbab12019-07-16 03:21:01 +0000357 template<typename K>
358 size_type count(const K& x) const; // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000359 size_type count(const key_type& k) const;
Zoe Carver3ffbab12019-07-16 03:21:01 +0000360 bool contains(const key_type& x) const; // C++20
Howard Hinnantc51e1022010-05-11 19:42:16 +0000361 iterator lower_bound(const key_type& k);
362 const_iterator lower_bound(const key_type& k) const;
Marshall Clowc0152142013-08-13 01:11:06 +0000363 template<typename K>
364 iterator lower_bound(const K& x); // C++14
365 template<typename K>
366 const_iterator lower_bound(const K& x) const; // C++14
367
Howard Hinnantc51e1022010-05-11 19:42:16 +0000368 iterator upper_bound(const key_type& k);
369 const_iterator upper_bound(const key_type& k) const;
Marshall Clowc0152142013-08-13 01:11:06 +0000370 template<typename K>
371 iterator upper_bound(const K& x); // C++14
372 template<typename K>
373 const_iterator upper_bound(const K& x) const; // C++14
374
Howard Hinnantc51e1022010-05-11 19:42:16 +0000375 pair<iterator,iterator> equal_range(const key_type& k);
376 pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
Marshall Clowc0152142013-08-13 01:11:06 +0000377 template<typename K>
378 pair<iterator,iterator> equal_range(const K& x); // C++14
379 template<typename K>
380 pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +0000381};
382
383template <class Key, class Compare, class Allocator>
384bool
385operator==(const multiset<Key, Compare, Allocator>& x,
386 const multiset<Key, Compare, Allocator>& y);
387
388template <class Key, class Compare, class Allocator>
389bool
390operator< (const multiset<Key, Compare, Allocator>& x,
391 const multiset<Key, Compare, Allocator>& y);
392
393template <class Key, class Compare, class Allocator>
394bool
395operator!=(const multiset<Key, Compare, Allocator>& x,
396 const multiset<Key, Compare, Allocator>& y);
397
398template <class Key, class Compare, class Allocator>
399bool
400operator> (const multiset<Key, Compare, Allocator>& x,
401 const multiset<Key, Compare, Allocator>& y);
402
403template <class Key, class Compare, class Allocator>
404bool
405operator>=(const multiset<Key, Compare, Allocator>& x,
406 const multiset<Key, Compare, Allocator>& y);
407
408template <class Key, class Compare, class Allocator>
409bool
410operator<=(const multiset<Key, Compare, Allocator>& x,
411 const multiset<Key, Compare, Allocator>& y);
412
413// specialized algorithms:
414template <class Key, class Compare, class Allocator>
415void
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000416swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
417 noexcept(noexcept(x.swap(y)));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000418
Marshall Clow29b53f22018-12-14 18:49:35 +0000419template <class Key, class Compare, class Allocator, class Predicate>
420 void erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
421
Howard Hinnantc51e1022010-05-11 19:42:16 +0000422} // std
423
424*/
425
426#include <__config>
427#include <__tree>
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +0000428#include <__node_handle>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000429#include <functional>
Marshall Clow0a1e7502018-09-12 19:41:40 +0000430#include <version>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000431
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000432#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000433#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000434#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000435
436_LIBCPP_BEGIN_NAMESPACE_STD
437
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000438template <class _Key, class _Compare, class _Allocator>
439class multiset;
440
Howard Hinnantc51e1022010-05-11 19:42:16 +0000441template <class _Key, class _Compare = less<_Key>,
442 class _Allocator = allocator<_Key> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000443class _LIBCPP_TEMPLATE_VIS set
Howard Hinnantc51e1022010-05-11 19:42:16 +0000444{
445public:
446 // types:
447 typedef _Key key_type;
448 typedef key_type value_type;
449 typedef _Compare key_compare;
450 typedef key_compare value_compare;
Louis Dionne27ecc152019-06-11 18:21:08 +0000451 typedef typename __identity<_Allocator>::type allocator_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000452 typedef value_type& reference;
453 typedef const value_type& const_reference;
454
Marshall Clow5128cf32015-11-26 01:24:04 +0000455 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
456 "Allocator::value_type must be same type as value_type");
457
Howard Hinnantc51e1022010-05-11 19:42:16 +0000458private:
459 typedef __tree<value_type, value_compare, allocator_type> __base;
460 typedef allocator_traits<allocator_type> __alloc_traits;
461 typedef typename __base::__node_holder __node_holder;
462
463 __base __tree_;
464
465public:
466 typedef typename __base::pointer pointer;
467 typedef typename __base::const_pointer const_pointer;
468 typedef typename __base::size_type size_type;
469 typedef typename __base::difference_type difference_type;
470 typedef typename __base::const_iterator iterator;
471 typedef typename __base::const_iterator const_iterator;
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000472 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
473 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000474
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +0000475#if _LIBCPP_STD_VER > 14
476 typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
477 typedef __insert_return_type<iterator, node_type> insert_return_type;
478#endif
479
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000480 template <class _Key2, class _Compare2, class _Alloc2>
481 friend class _LIBCPP_TEMPLATE_VIS set;
482 template <class _Key2, class _Compare2, class _Alloc2>
483 friend class _LIBCPP_TEMPLATE_VIS multiset;
484
Howard Hinnant192cf032010-09-23 16:27:36 +0000485 _LIBCPP_INLINE_VISIBILITY
Marshall Clow7086a5a2014-03-10 04:50:10 +0000486 set()
487 _NOEXCEPT_(
488 is_nothrow_default_constructible<allocator_type>::value &&
489 is_nothrow_default_constructible<key_compare>::value &&
490 is_nothrow_copy_constructible<key_compare>::value)
491 : __tree_(value_compare()) {}
492
493 _LIBCPP_INLINE_VISIBILITY
494 explicit set(const value_compare& __comp)
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000495 _NOEXCEPT_(
496 is_nothrow_default_constructible<allocator_type>::value &&
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000497 is_nothrow_copy_constructible<key_compare>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000498 : __tree_(__comp) {}
Marshall Clow7086a5a2014-03-10 04:50:10 +0000499
Howard Hinnant192cf032010-09-23 16:27:36 +0000500 _LIBCPP_INLINE_VISIBILITY
Marshall Clow7ed23a72014-03-05 19:06:20 +0000501 explicit set(const value_compare& __comp, const allocator_type& __a)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000502 : __tree_(__comp, __a) {}
503 template <class _InputIterator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000504 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000505 set(_InputIterator __f, _InputIterator __l,
506 const value_compare& __comp = value_compare())
507 : __tree_(__comp)
508 {
509 insert(__f, __l);
510 }
511
512 template <class _InputIterator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000513 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000514 set(_InputIterator __f, _InputIterator __l, const value_compare& __comp,
515 const allocator_type& __a)
516 : __tree_(__comp, __a)
517 {
518 insert(__f, __l);
519 }
520
Marshall Clow631788a2013-09-11 00:06:45 +0000521#if _LIBCPP_STD_VER > 11
522 template <class _InputIterator>
Louis Dionned2322c82018-11-01 14:41:37 +0000523 _LIBCPP_INLINE_VISIBILITY
Marshall Clow631788a2013-09-11 00:06:45 +0000524 set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
525 : set(__f, __l, key_compare(), __a) {}
526#endif
527
Howard Hinnant192cf032010-09-23 16:27:36 +0000528 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000529 set(const set& __s)
530 : __tree_(__s.__tree_)
531 {
532 insert(__s.begin(), __s.end());
533 }
534
Howard Hinnantd3a657f2011-07-01 19:24:36 +0000535 _LIBCPP_INLINE_VISIBILITY
536 set& operator=(const set& __s)
537 {
538 __tree_ = __s.__tree_;
539 return *this;
540 }
541
Eric Fiselier615961b2017-04-18 20:58:03 +0000542#ifndef _LIBCPP_CXX03_LANG
Howard Hinnant192cf032010-09-23 16:27:36 +0000543 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000544 set(set&& __s)
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000545 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000546 : __tree_(_VSTD::move(__s.__tree_)) {}
Eric Fiselier615961b2017-04-18 20:58:03 +0000547#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000548
Howard Hinnant192cf032010-09-23 16:27:36 +0000549 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000550 explicit set(const allocator_type& __a)
551 : __tree_(__a) {}
552
Howard Hinnant192cf032010-09-23 16:27:36 +0000553 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000554 set(const set& __s, const allocator_type& __a)
555 : __tree_(__s.__tree_.value_comp(), __a)
556 {
557 insert(__s.begin(), __s.end());
558 }
559
Eric Fiselier615961b2017-04-18 20:58:03 +0000560#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000561 set(set&& __s, const allocator_type& __a);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000562
Howard Hinnant192cf032010-09-23 16:27:36 +0000563 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000564 set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
565 : __tree_(__comp)
566 {
567 insert(__il.begin(), __il.end());
568 }
569
Howard Hinnant192cf032010-09-23 16:27:36 +0000570 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000571 set(initializer_list<value_type> __il, const value_compare& __comp,
572 const allocator_type& __a)
573 : __tree_(__comp, __a)
574 {
575 insert(__il.begin(), __il.end());
576 }
577
Marshall Clow631788a2013-09-11 00:06:45 +0000578#if _LIBCPP_STD_VER > 11
Louis Dionned2322c82018-11-01 14:41:37 +0000579 _LIBCPP_INLINE_VISIBILITY
Marshall Clow631788a2013-09-11 00:06:45 +0000580 set(initializer_list<value_type> __il, const allocator_type& __a)
581 : set(__il, key_compare(), __a) {}
582#endif
583
Howard Hinnant192cf032010-09-23 16:27:36 +0000584 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000585 set& operator=(initializer_list<value_type> __il)
586 {
587 __tree_.__assign_unique(__il.begin(), __il.end());
588 return *this;
589 }
590
Howard Hinnant192cf032010-09-23 16:27:36 +0000591 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000592 set& operator=(set&& __s)
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000593 _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000594 {
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000595 __tree_ = _VSTD::move(__s.__tree_);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000596 return *this;
597 }
Eric Fiselier615961b2017-04-18 20:58:03 +0000598#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000599
Howard Hinnant192cf032010-09-23 16:27:36 +0000600 _LIBCPP_INLINE_VISIBILITY
Louis Dionne69c42c02019-04-11 16:14:56 +0000601 ~set() {
602 static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
603 }
604
605 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000606 iterator begin() _NOEXCEPT {return __tree_.begin();}
Howard Hinnant192cf032010-09-23 16:27:36 +0000607 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000608 const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
Howard Hinnant192cf032010-09-23 16:27:36 +0000609 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000610 iterator end() _NOEXCEPT {return __tree_.end();}
Howard Hinnant192cf032010-09-23 16:27:36 +0000611 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000612 const_iterator end() const _NOEXCEPT {return __tree_.end();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000613
Howard Hinnant192cf032010-09-23 16:27:36 +0000614 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000615 reverse_iterator rbegin() _NOEXCEPT
616 {return reverse_iterator(end());}
Howard Hinnant192cf032010-09-23 16:27:36 +0000617 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000618 const_reverse_iterator rbegin() const _NOEXCEPT
619 {return const_reverse_iterator(end());}
Howard Hinnant192cf032010-09-23 16:27:36 +0000620 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000621 reverse_iterator rend() _NOEXCEPT
622 {return reverse_iterator(begin());}
Howard Hinnant192cf032010-09-23 16:27:36 +0000623 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000624 const_reverse_iterator rend() const _NOEXCEPT
625 {return const_reverse_iterator(begin());}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000626
Howard Hinnant192cf032010-09-23 16:27:36 +0000627 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000628 const_iterator cbegin() const _NOEXCEPT {return begin();}
Howard Hinnant192cf032010-09-23 16:27:36 +0000629 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000630 const_iterator cend() const _NOEXCEPT {return end();}
Howard Hinnant192cf032010-09-23 16:27:36 +0000631 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000632 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
Howard Hinnant192cf032010-09-23 16:27:36 +0000633 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000634 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000635
Marshall Clow425f5752017-11-15 05:51:26 +0000636 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000637 bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
Howard Hinnant192cf032010-09-23 16:27:36 +0000638 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000639 size_type size() const _NOEXCEPT {return __tree_.size();}
Howard Hinnant192cf032010-09-23 16:27:36 +0000640 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000641 size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000642
643 // modifiers:
Eric Fiselier615961b2017-04-18 20:58:03 +0000644#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000645 template <class... _Args>
Howard Hinnant192cf032010-09-23 16:27:36 +0000646 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000647 pair<iterator, bool> emplace(_Args&&... __args)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000648 {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000649 template <class... _Args>
Howard Hinnant192cf032010-09-23 16:27:36 +0000650 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000651 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000652 {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);}
Eric Fiselier615961b2017-04-18 20:58:03 +0000653#endif // _LIBCPP_CXX03_LANG
654
Howard Hinnant192cf032010-09-23 16:27:36 +0000655 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000656 pair<iterator,bool> insert(const value_type& __v)
657 {return __tree_.__insert_unique(__v);}
Howard Hinnant192cf032010-09-23 16:27:36 +0000658 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000659 iterator insert(const_iterator __p, const value_type& __v)
660 {return __tree_.__insert_unique(__p, __v);}
Eric Fiselier615961b2017-04-18 20:58:03 +0000661
Howard Hinnantc51e1022010-05-11 19:42:16 +0000662 template <class _InputIterator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000663 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000664 void insert(_InputIterator __f, _InputIterator __l)
665 {
666 for (const_iterator __e = cend(); __f != __l; ++__f)
667 __tree_.__insert_unique(__e, *__f);
668 }
669
Eric Fiselier615961b2017-04-18 20:58:03 +0000670#ifndef _LIBCPP_CXX03_LANG
671 _LIBCPP_INLINE_VISIBILITY
672 pair<iterator,bool> insert(value_type&& __v)
673 {return __tree_.__insert_unique(_VSTD::move(__v));}
674
675 _LIBCPP_INLINE_VISIBILITY
676 iterator insert(const_iterator __p, value_type&& __v)
677 {return __tree_.__insert_unique(__p, _VSTD::move(__v));}
678
Howard Hinnant192cf032010-09-23 16:27:36 +0000679 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000680 void insert(initializer_list<value_type> __il)
681 {insert(__il.begin(), __il.end());}
Eric Fiselier615961b2017-04-18 20:58:03 +0000682#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000683
Howard Hinnant192cf032010-09-23 16:27:36 +0000684 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000685 iterator erase(const_iterator __p) {return __tree_.erase(__p);}
Howard Hinnant192cf032010-09-23 16:27:36 +0000686 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000687 size_type erase(const key_type& __k)
688 {return __tree_.__erase_unique(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +0000689 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000690 iterator erase(const_iterator __f, const_iterator __l)
691 {return __tree_.erase(__f, __l);}
Howard Hinnant192cf032010-09-23 16:27:36 +0000692 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000693 void clear() _NOEXCEPT {__tree_.clear();}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000694
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +0000695#if _LIBCPP_STD_VER > 14
696 _LIBCPP_INLINE_VISIBILITY
697 insert_return_type insert(node_type&& __nh)
698 {
699 _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
700 "node_type with incompatible allocator passed to set::insert()");
701 return __tree_.template __node_handle_insert_unique<
702 node_type, insert_return_type>(_VSTD::move(__nh));
703 }
704 _LIBCPP_INLINE_VISIBILITY
705 iterator insert(const_iterator __hint, node_type&& __nh)
706 {
707 _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
708 "node_type with incompatible allocator passed to set::insert()");
709 return __tree_.template __node_handle_insert_unique<node_type>(
710 __hint, _VSTD::move(__nh));
711 }
712 _LIBCPP_INLINE_VISIBILITY
713 node_type extract(key_type const& __key)
714 {
715 return __tree_.template __node_handle_extract<node_type>(__key);
716 }
717 _LIBCPP_INLINE_VISIBILITY
718 node_type extract(const_iterator __it)
719 {
720 return __tree_.template __node_handle_extract<node_type>(__it);
721 }
Louis Dionned2322c82018-11-01 14:41:37 +0000722 template <class _Compare2>
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000723 _LIBCPP_INLINE_VISIBILITY
Louis Dionned2322c82018-11-01 14:41:37 +0000724 void merge(set<key_type, _Compare2, allocator_type>& __source)
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000725 {
726 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
727 "merging container with incompatible allocator");
728 __tree_.__node_handle_merge_unique(__source.__tree_);
729 }
Louis Dionned2322c82018-11-01 14:41:37 +0000730 template <class _Compare2>
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000731 _LIBCPP_INLINE_VISIBILITY
Louis Dionned2322c82018-11-01 14:41:37 +0000732 void merge(set<key_type, _Compare2, allocator_type>&& __source)
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000733 {
734 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
735 "merging container with incompatible allocator");
736 __tree_.__node_handle_merge_unique(__source.__tree_);
737 }
Louis Dionned2322c82018-11-01 14:41:37 +0000738 template <class _Compare2>
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000739 _LIBCPP_INLINE_VISIBILITY
Louis Dionned2322c82018-11-01 14:41:37 +0000740 void merge(multiset<key_type, _Compare2, allocator_type>& __source)
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000741 {
742 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
743 "merging container with incompatible allocator");
744 __tree_.__node_handle_merge_unique(__source.__tree_);
745 }
Louis Dionned2322c82018-11-01 14:41:37 +0000746 template <class _Compare2>
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000747 _LIBCPP_INLINE_VISIBILITY
Louis Dionned2322c82018-11-01 14:41:37 +0000748 void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
Erik Pilkington82a65ad2018-10-31 17:31:35 +0000749 {
750 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
751 "merging container with incompatible allocator");
752 __tree_.__node_handle_merge_unique(__source.__tree_);
753 }
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +0000754#endif
755
Howard Hinnant192cf032010-09-23 16:27:36 +0000756 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000757 void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
758 {__tree_.swap(__s.__tree_);}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000759
Howard Hinnant192cf032010-09-23 16:27:36 +0000760 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000761 allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
Howard Hinnant192cf032010-09-23 16:27:36 +0000762 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000763 key_compare key_comp() const {return __tree_.value_comp();}
Howard Hinnant192cf032010-09-23 16:27:36 +0000764 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000765 value_compare value_comp() const {return __tree_.value_comp();}
766
767 // set operations:
Howard Hinnant192cf032010-09-23 16:27:36 +0000768 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000769 iterator find(const key_type& __k) {return __tree_.find(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +0000770 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000771 const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +0000772#if _LIBCPP_STD_VER > 11
773 template <typename _K2>
774 _LIBCPP_INLINE_VISIBILITY
775 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
776 find(const _K2& __k) {return __tree_.find(__k);}
777 template <typename _K2>
778 _LIBCPP_INLINE_VISIBILITY
779 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
780 find(const _K2& __k) const {return __tree_.find(__k);}
781#endif
782
Howard Hinnant192cf032010-09-23 16:27:36 +0000783 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000784 size_type count(const key_type& __k) const
785 {return __tree_.__count_unique(__k);}
Marshall Clowe6a5f522014-08-24 23:54:16 +0000786#if _LIBCPP_STD_VER > 11
787 template <typename _K2>
788 _LIBCPP_INLINE_VISIBILITY
789 typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
Eric Fiseliera85c9e92018-02-10 02:53:47 +0000790 count(const _K2& __k) const {return __tree_.__count_multi(__k);}
Marshall Clowe6a5f522014-08-24 23:54:16 +0000791#endif
Zoe Carver3ffbab12019-07-16 03:21:01 +0000792
793#if _LIBCPP_STD_VER > 17
794 _LIBCPP_INLINE_VISIBILITY
795 bool contains(const key_type& __k) const {return find(__k) != end();}
796#endif // _LIBCPP_STD_VER > 17
797
Howard Hinnant192cf032010-09-23 16:27:36 +0000798 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000799 iterator lower_bound(const key_type& __k)
800 {return __tree_.lower_bound(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +0000801 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000802 const_iterator lower_bound(const key_type& __k) const
803 {return __tree_.lower_bound(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +0000804#if _LIBCPP_STD_VER > 11
805 template <typename _K2>
806 _LIBCPP_INLINE_VISIBILITY
807 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
808 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
809
810 template <typename _K2>
811 _LIBCPP_INLINE_VISIBILITY
812 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
813 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
814#endif
815
Howard Hinnant192cf032010-09-23 16:27:36 +0000816 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000817 iterator upper_bound(const key_type& __k)
818 {return __tree_.upper_bound(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +0000819 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000820 const_iterator upper_bound(const key_type& __k) const
821 {return __tree_.upper_bound(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +0000822#if _LIBCPP_STD_VER > 11
823 template <typename _K2>
824 _LIBCPP_INLINE_VISIBILITY
825 typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
826 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
827 template <typename _K2>
828 _LIBCPP_INLINE_VISIBILITY
829 typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
830 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
831#endif
832
Howard Hinnant192cf032010-09-23 16:27:36 +0000833 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000834 pair<iterator,iterator> equal_range(const key_type& __k)
835 {return __tree_.__equal_range_unique(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +0000836 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000837 pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
838 {return __tree_.__equal_range_unique(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +0000839#if _LIBCPP_STD_VER > 11
840 template <typename _K2>
841 _LIBCPP_INLINE_VISIBILITY
842 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
Eric Fiseliera85c9e92018-02-10 02:53:47 +0000843 equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +0000844 template <typename _K2>
845 _LIBCPP_INLINE_VISIBILITY
846 typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
Eric Fiseliera85c9e92018-02-10 02:53:47 +0000847 equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +0000848#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000849};
850
Louis Dionne27ecc152019-06-11 18:21:08 +0000851#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
852template<class _InputIterator,
853 class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
854 class _Allocator = allocator<typename iterator_traits<_InputIterator>::value_type>,
855 class = typename enable_if<__is_allocator<_Allocator>::value, void>::type,
856 class = typename enable_if<!__is_allocator<_Compare>::value, void>::type>
857set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
858 -> set<typename iterator_traits<_InputIterator>::value_type, _Compare, _Allocator>;
859
860template<class _Key, class _Compare = less<_Key>,
861 class _Allocator = allocator<_Key>,
862 class = typename enable_if<__is_allocator<_Allocator>::value, void>::type,
863 class = typename enable_if<!__is_allocator<_Compare>::value, void>::type>
864set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
865 -> set<_Key, _Compare, _Allocator>;
866
867template<class _InputIterator, class _Allocator,
868 class = typename enable_if<__is_allocator<_Allocator>::value, void>::type>
869set(_InputIterator, _InputIterator, _Allocator)
870 -> set<typename iterator_traits<_InputIterator>::value_type,
871 less<typename iterator_traits<_InputIterator>::value_type>, _Allocator>;
872
873template<class _Key, class _Allocator,
874 class = typename enable_if<__is_allocator<_Allocator>::value, void>::type>
875set(initializer_list<_Key>, _Allocator)
876 -> set<_Key, less<_Key>, _Allocator>;
877#endif
878
Eric Fiselier615961b2017-04-18 20:58:03 +0000879#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000880
881template <class _Key, class _Compare, class _Allocator>
882set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000883 : __tree_(_VSTD::move(__s.__tree_), __a)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000884{
885 if (__a != __s.get_allocator())
886 {
887 const_iterator __e = cend();
888 while (!__s.empty())
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000889 insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000890 }
891}
892
Eric Fiselier615961b2017-04-18 20:58:03 +0000893#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000894
895template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000896inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000897bool
898operator==(const set<_Key, _Compare, _Allocator>& __x,
899 const set<_Key, _Compare, _Allocator>& __y)
900{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000901 return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
Howard Hinnantc51e1022010-05-11 19:42:16 +0000902}
903
904template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000905inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000906bool
907operator< (const set<_Key, _Compare, _Allocator>& __x,
908 const set<_Key, _Compare, _Allocator>& __y)
909{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000910 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
Howard Hinnantc51e1022010-05-11 19:42:16 +0000911}
912
913template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000914inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000915bool
916operator!=(const set<_Key, _Compare, _Allocator>& __x,
917 const set<_Key, _Compare, _Allocator>& __y)
918{
919 return !(__x == __y);
920}
921
922template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000923inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000924bool
925operator> (const set<_Key, _Compare, _Allocator>& __x,
926 const set<_Key, _Compare, _Allocator>& __y)
927{
928 return __y < __x;
929}
930
931template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000932inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000933bool
934operator>=(const set<_Key, _Compare, _Allocator>& __x,
935 const set<_Key, _Compare, _Allocator>& __y)
936{
937 return !(__x < __y);
938}
939
940template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000941inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000942bool
943operator<=(const set<_Key, _Compare, _Allocator>& __x,
944 const set<_Key, _Compare, _Allocator>& __y)
945{
946 return !(__y < __x);
947}
948
949// specialized algorithms:
950template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +0000951inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000952void
953swap(set<_Key, _Compare, _Allocator>& __x,
954 set<_Key, _Compare, _Allocator>& __y)
Howard Hinnantf95f4f52011-06-04 15:22:34 +0000955 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantc51e1022010-05-11 19:42:16 +0000956{
957 __x.swap(__y);
958}
959
Marshall Clow29b53f22018-12-14 18:49:35 +0000960#if _LIBCPP_STD_VER > 17
961template <class _Key, class _Compare, class _Allocator, class _Predicate>
962inline _LIBCPP_INLINE_VISIBILITY
963void erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred)
964{ __libcpp_erase_if_container(__c, __pred); }
965#endif
966
Howard Hinnantc51e1022010-05-11 19:42:16 +0000967template <class _Key, class _Compare = less<_Key>,
968 class _Allocator = allocator<_Key> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000969class _LIBCPP_TEMPLATE_VIS multiset
Howard Hinnantc51e1022010-05-11 19:42:16 +0000970{
971public:
972 // types:
973 typedef _Key key_type;
974 typedef key_type value_type;
975 typedef _Compare key_compare;
976 typedef key_compare value_compare;
Louis Dionne27ecc152019-06-11 18:21:08 +0000977 typedef typename __identity<_Allocator>::type allocator_type;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000978 typedef value_type& reference;
979 typedef const value_type& const_reference;
980
Marshall Clow5128cf32015-11-26 01:24:04 +0000981 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
982 "Allocator::value_type must be same type as value_type");
983
Howard Hinnantc51e1022010-05-11 19:42:16 +0000984private:
985 typedef __tree<value_type, value_compare, allocator_type> __base;
986 typedef allocator_traits<allocator_type> __alloc_traits;
987 typedef typename __base::__node_holder __node_holder;
988
989 __base __tree_;
990
991public:
992 typedef typename __base::pointer pointer;
993 typedef typename __base::const_pointer const_pointer;
994 typedef typename __base::size_type size_type;
995 typedef typename __base::difference_type difference_type;
996 typedef typename __base::const_iterator iterator;
997 typedef typename __base::const_iterator const_iterator;
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000998 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
999 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
Howard Hinnantc51e1022010-05-11 19:42:16 +00001000
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +00001001#if _LIBCPP_STD_VER > 14
1002 typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
1003#endif
1004
Erik Pilkington82a65ad2018-10-31 17:31:35 +00001005 template <class _Key2, class _Compare2, class _Alloc2>
1006 friend class _LIBCPP_TEMPLATE_VIS set;
1007 template <class _Key2, class _Compare2, class _Alloc2>
1008 friend class _LIBCPP_TEMPLATE_VIS multiset;
1009
Howard Hinnantc51e1022010-05-11 19:42:16 +00001010 // construct/copy/destroy:
Howard Hinnant192cf032010-09-23 16:27:36 +00001011 _LIBCPP_INLINE_VISIBILITY
Marshall Clow7086a5a2014-03-10 04:50:10 +00001012 multiset()
1013 _NOEXCEPT_(
1014 is_nothrow_default_constructible<allocator_type>::value &&
1015 is_nothrow_default_constructible<key_compare>::value &&
1016 is_nothrow_copy_constructible<key_compare>::value)
1017 : __tree_(value_compare()) {}
1018
1019 _LIBCPP_INLINE_VISIBILITY
1020 explicit multiset(const value_compare& __comp)
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001021 _NOEXCEPT_(
1022 is_nothrow_default_constructible<allocator_type>::value &&
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001023 is_nothrow_copy_constructible<key_compare>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001024 : __tree_(__comp) {}
Marshall Clow7086a5a2014-03-10 04:50:10 +00001025
Howard Hinnant192cf032010-09-23 16:27:36 +00001026 _LIBCPP_INLINE_VISIBILITY
Marshall Clow7ed23a72014-03-05 19:06:20 +00001027 explicit multiset(const value_compare& __comp, const allocator_type& __a)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001028 : __tree_(__comp, __a) {}
1029 template <class _InputIterator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001030 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001031 multiset(_InputIterator __f, _InputIterator __l,
1032 const value_compare& __comp = value_compare())
1033 : __tree_(__comp)
1034 {
1035 insert(__f, __l);
1036 }
1037
Marshall Clow631788a2013-09-11 00:06:45 +00001038#if _LIBCPP_STD_VER > 11
1039 template <class _InputIterator>
Louis Dionned2322c82018-11-01 14:41:37 +00001040 _LIBCPP_INLINE_VISIBILITY
Marshall Clow631788a2013-09-11 00:06:45 +00001041 multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
1042 : multiset(__f, __l, key_compare(), __a) {}
1043#endif
1044
Howard Hinnantc51e1022010-05-11 19:42:16 +00001045 template <class _InputIterator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001046 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001047 multiset(_InputIterator __f, _InputIterator __l,
1048 const value_compare& __comp, const allocator_type& __a)
1049 : __tree_(__comp, __a)
1050 {
1051 insert(__f, __l);
1052 }
1053
Howard Hinnant192cf032010-09-23 16:27:36 +00001054 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001055 multiset(const multiset& __s)
1056 : __tree_(__s.__tree_.value_comp(),
1057 __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc()))
1058 {
1059 insert(__s.begin(), __s.end());
1060 }
1061
Howard Hinnantd3a657f2011-07-01 19:24:36 +00001062 _LIBCPP_INLINE_VISIBILITY
1063 multiset& operator=(const multiset& __s)
1064 {
1065 __tree_ = __s.__tree_;
1066 return *this;
1067 }
1068
Eric Fiselier615961b2017-04-18 20:58:03 +00001069#ifndef _LIBCPP_CXX03_LANG
Howard Hinnant192cf032010-09-23 16:27:36 +00001070 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001071 multiset(multiset&& __s)
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001072 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001073 : __tree_(_VSTD::move(__s.__tree_)) {}
Eric Fiselier615961b2017-04-18 20:58:03 +00001074
1075 multiset(multiset&& __s, const allocator_type& __a);
1076#endif // _LIBCPP_CXX03_LANG
Howard Hinnant192cf032010-09-23 16:27:36 +00001077 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001078 explicit multiset(const allocator_type& __a)
1079 : __tree_(__a) {}
Howard Hinnant192cf032010-09-23 16:27:36 +00001080 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001081 multiset(const multiset& __s, const allocator_type& __a)
1082 : __tree_(__s.__tree_.value_comp(), __a)
1083 {
1084 insert(__s.begin(), __s.end());
1085 }
Howard Hinnantc51e1022010-05-11 19:42:16 +00001086
Eric Fiselier615961b2017-04-18 20:58:03 +00001087#ifndef _LIBCPP_CXX03_LANG
Howard Hinnant192cf032010-09-23 16:27:36 +00001088 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001089 multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
1090 : __tree_(__comp)
1091 {
1092 insert(__il.begin(), __il.end());
1093 }
1094
Howard Hinnant192cf032010-09-23 16:27:36 +00001095 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001096 multiset(initializer_list<value_type> __il, const value_compare& __comp,
1097 const allocator_type& __a)
1098 : __tree_(__comp, __a)
1099 {
1100 insert(__il.begin(), __il.end());
1101 }
1102
Marshall Clow631788a2013-09-11 00:06:45 +00001103#if _LIBCPP_STD_VER > 11
Louis Dionned2322c82018-11-01 14:41:37 +00001104 _LIBCPP_INLINE_VISIBILITY
Marshall Clow631788a2013-09-11 00:06:45 +00001105 multiset(initializer_list<value_type> __il, const allocator_type& __a)
1106 : multiset(__il, key_compare(), __a) {}
1107#endif
1108
Howard Hinnant192cf032010-09-23 16:27:36 +00001109 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001110 multiset& operator=(initializer_list<value_type> __il)
1111 {
1112 __tree_.__assign_multi(__il.begin(), __il.end());
1113 return *this;
1114 }
1115
Howard Hinnant192cf032010-09-23 16:27:36 +00001116 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001117 multiset& operator=(multiset&& __s)
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001118 _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001119 {
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001120 __tree_ = _VSTD::move(__s.__tree_);
Howard Hinnantc51e1022010-05-11 19:42:16 +00001121 return *this;
1122 }
Eric Fiselier615961b2017-04-18 20:58:03 +00001123#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +00001124
Howard Hinnant192cf032010-09-23 16:27:36 +00001125 _LIBCPP_INLINE_VISIBILITY
Louis Dionne69c42c02019-04-11 16:14:56 +00001126 ~multiset() {
1127 static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
1128 }
1129
1130 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001131 iterator begin() _NOEXCEPT {return __tree_.begin();}
Howard Hinnant192cf032010-09-23 16:27:36 +00001132 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001133 const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
Howard Hinnant192cf032010-09-23 16:27:36 +00001134 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001135 iterator end() _NOEXCEPT {return __tree_.end();}
Howard Hinnant192cf032010-09-23 16:27:36 +00001136 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001137 const_iterator end() const _NOEXCEPT {return __tree_.end();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001138
Howard Hinnant192cf032010-09-23 16:27:36 +00001139 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001140 reverse_iterator rbegin() _NOEXCEPT
1141 {return reverse_iterator(end());}
Howard Hinnant192cf032010-09-23 16:27:36 +00001142 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001143 const_reverse_iterator rbegin() const _NOEXCEPT
1144 {return const_reverse_iterator(end());}
Howard Hinnant192cf032010-09-23 16:27:36 +00001145 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001146 reverse_iterator rend() _NOEXCEPT
1147 {return reverse_iterator(begin());}
Howard Hinnant192cf032010-09-23 16:27:36 +00001148 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001149 const_reverse_iterator rend() const _NOEXCEPT
1150 {return const_reverse_iterator(begin());}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001151
Howard Hinnant192cf032010-09-23 16:27:36 +00001152 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001153 const_iterator cbegin() const _NOEXCEPT {return begin();}
Howard Hinnant192cf032010-09-23 16:27:36 +00001154 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001155 const_iterator cend() const _NOEXCEPT {return end();}
Howard Hinnant192cf032010-09-23 16:27:36 +00001156 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001157 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
Howard Hinnant192cf032010-09-23 16:27:36 +00001158 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001159 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001160
Marshall Clow425f5752017-11-15 05:51:26 +00001161 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001162 bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
Howard Hinnant192cf032010-09-23 16:27:36 +00001163 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001164 size_type size() const _NOEXCEPT {return __tree_.size();}
Howard Hinnant192cf032010-09-23 16:27:36 +00001165 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001166 size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001167
1168 // modifiers:
Eric Fiselier615961b2017-04-18 20:58:03 +00001169#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +00001170 template <class... _Args>
Howard Hinnant192cf032010-09-23 16:27:36 +00001171 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001172 iterator emplace(_Args&&... __args)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001173 {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001174 template <class... _Args>
Howard Hinnant192cf032010-09-23 16:27:36 +00001175 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001176 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001177 {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
Eric Fiselier615961b2017-04-18 20:58:03 +00001178#endif // _LIBCPP_CXX03_LANG
1179
Howard Hinnant192cf032010-09-23 16:27:36 +00001180 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001181 iterator insert(const value_type& __v)
1182 {return __tree_.__insert_multi(__v);}
Howard Hinnant192cf032010-09-23 16:27:36 +00001183 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001184 iterator insert(const_iterator __p, const value_type& __v)
1185 {return __tree_.__insert_multi(__p, __v);}
Eric Fiselier615961b2017-04-18 20:58:03 +00001186
Howard Hinnantc51e1022010-05-11 19:42:16 +00001187 template <class _InputIterator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001188 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001189 void insert(_InputIterator __f, _InputIterator __l)
1190 {
1191 for (const_iterator __e = cend(); __f != __l; ++__f)
1192 __tree_.__insert_multi(__e, *__f);
1193 }
1194
Eric Fiselier615961b2017-04-18 20:58:03 +00001195#ifndef _LIBCPP_CXX03_LANG
1196 _LIBCPP_INLINE_VISIBILITY
1197 iterator insert(value_type&& __v)
1198 {return __tree_.__insert_multi(_VSTD::move(__v));}
1199
1200 _LIBCPP_INLINE_VISIBILITY
1201 iterator insert(const_iterator __p, value_type&& __v)
1202 {return __tree_.__insert_multi(__p, _VSTD::move(__v));}
1203
Howard Hinnant192cf032010-09-23 16:27:36 +00001204 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001205 void insert(initializer_list<value_type> __il)
1206 {insert(__il.begin(), __il.end());}
Eric Fiselier615961b2017-04-18 20:58:03 +00001207#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +00001208
Howard Hinnant192cf032010-09-23 16:27:36 +00001209 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001210 iterator erase(const_iterator __p) {return __tree_.erase(__p);}
Howard Hinnant192cf032010-09-23 16:27:36 +00001211 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001212 size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +00001213 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001214 iterator erase(const_iterator __f, const_iterator __l)
1215 {return __tree_.erase(__f, __l);}
Howard Hinnant192cf032010-09-23 16:27:36 +00001216 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001217 void clear() _NOEXCEPT {__tree_.clear();}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001218
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +00001219#if _LIBCPP_STD_VER > 14
1220 _LIBCPP_INLINE_VISIBILITY
1221 iterator insert(node_type&& __nh)
1222 {
1223 _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1224 "node_type with incompatible allocator passed to multiset::insert()");
1225 return __tree_.template __node_handle_insert_multi<node_type>(
1226 _VSTD::move(__nh));
1227 }
1228 _LIBCPP_INLINE_VISIBILITY
1229 iterator insert(const_iterator __hint, node_type&& __nh)
1230 {
1231 _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1232 "node_type with incompatible allocator passed to multiset::insert()");
1233 return __tree_.template __node_handle_insert_multi<node_type>(
1234 __hint, _VSTD::move(__nh));
1235 }
1236 _LIBCPP_INLINE_VISIBILITY
1237 node_type extract(key_type const& __key)
1238 {
1239 return __tree_.template __node_handle_extract<node_type>(__key);
1240 }
1241 _LIBCPP_INLINE_VISIBILITY
1242 node_type extract(const_iterator __it)
1243 {
1244 return __tree_.template __node_handle_extract<node_type>(__it);
1245 }
Louis Dionned2322c82018-11-01 14:41:37 +00001246 template <class _Compare2>
Erik Pilkington82a65ad2018-10-31 17:31:35 +00001247 _LIBCPP_INLINE_VISIBILITY
Louis Dionned2322c82018-11-01 14:41:37 +00001248 void merge(multiset<key_type, _Compare2, allocator_type>& __source)
Erik Pilkington82a65ad2018-10-31 17:31:35 +00001249 {
1250 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1251 "merging container with incompatible allocator");
1252 __tree_.__node_handle_merge_multi(__source.__tree_);
1253 }
Louis Dionned2322c82018-11-01 14:41:37 +00001254 template <class _Compare2>
Erik Pilkington82a65ad2018-10-31 17:31:35 +00001255 _LIBCPP_INLINE_VISIBILITY
Louis Dionned2322c82018-11-01 14:41:37 +00001256 void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
Erik Pilkington82a65ad2018-10-31 17:31:35 +00001257 {
1258 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1259 "merging container with incompatible allocator");
1260 __tree_.__node_handle_merge_multi(__source.__tree_);
1261 }
Louis Dionned2322c82018-11-01 14:41:37 +00001262 template <class _Compare2>
Erik Pilkington82a65ad2018-10-31 17:31:35 +00001263 _LIBCPP_INLINE_VISIBILITY
Louis Dionned2322c82018-11-01 14:41:37 +00001264 void merge(set<key_type, _Compare2, allocator_type>& __source)
Erik Pilkington82a65ad2018-10-31 17:31:35 +00001265 {
1266 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1267 "merging container with incompatible allocator");
1268 __tree_.__node_handle_merge_multi(__source.__tree_);
1269 }
Louis Dionned2322c82018-11-01 14:41:37 +00001270 template <class _Compare2>
Erik Pilkington82a65ad2018-10-31 17:31:35 +00001271 _LIBCPP_INLINE_VISIBILITY
Louis Dionned2322c82018-11-01 14:41:37 +00001272 void merge(set<key_type, _Compare2, allocator_type>&& __source)
Erik Pilkington82a65ad2018-10-31 17:31:35 +00001273 {
1274 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1275 "merging container with incompatible allocator");
1276 __tree_.__node_handle_merge_multi(__source.__tree_);
1277 }
Erik Pilkingtonc37a3d82018-08-01 01:33:38 +00001278#endif
1279
Howard Hinnant192cf032010-09-23 16:27:36 +00001280 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001281 void swap(multiset& __s)
1282 _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
1283 {__tree_.swap(__s.__tree_);}
Howard Hinnantc51e1022010-05-11 19:42:16 +00001284
Howard Hinnant192cf032010-09-23 16:27:36 +00001285 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001286 allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
Howard Hinnant192cf032010-09-23 16:27:36 +00001287 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001288 key_compare key_comp() const {return __tree_.value_comp();}
Howard Hinnant192cf032010-09-23 16:27:36 +00001289 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001290 value_compare value_comp() const {return __tree_.value_comp();}
1291
1292 // set operations:
Howard Hinnant192cf032010-09-23 16:27:36 +00001293 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001294 iterator find(const key_type& __k) {return __tree_.find(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +00001295 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001296 const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +00001297#if _LIBCPP_STD_VER > 11
1298 template <typename _K2>
1299 _LIBCPP_INLINE_VISIBILITY
1300 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
1301 find(const _K2& __k) {return __tree_.find(__k);}
1302 template <typename _K2>
1303 _LIBCPP_INLINE_VISIBILITY
1304 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
1305 find(const _K2& __k) const {return __tree_.find(__k);}
1306#endif
1307
Howard Hinnant192cf032010-09-23 16:27:36 +00001308 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001309 size_type count(const key_type& __k) const
1310 {return __tree_.__count_multi(__k);}
Marshall Clowe6a5f522014-08-24 23:54:16 +00001311#if _LIBCPP_STD_VER > 11
1312 template <typename _K2>
1313 _LIBCPP_INLINE_VISIBILITY
1314 typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
Marshall Clow5571bcd2018-01-07 17:39:57 +00001315 count(const _K2& __k) const {return __tree_.__count_multi(__k);}
Marshall Clowe6a5f522014-08-24 23:54:16 +00001316#endif
Marshall Clowc0152142013-08-13 01:11:06 +00001317
Zoe Carver3ffbab12019-07-16 03:21:01 +00001318#if _LIBCPP_STD_VER > 17
1319 _LIBCPP_INLINE_VISIBILITY
1320 bool contains(const key_type& __k) const {return find(__k) != end();}
1321#endif // _LIBCPP_STD_VER > 17
1322
Howard Hinnant192cf032010-09-23 16:27:36 +00001323 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001324 iterator lower_bound(const key_type& __k)
1325 {return __tree_.lower_bound(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +00001326 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001327 const_iterator lower_bound(const key_type& __k) const
1328 {return __tree_.lower_bound(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +00001329#if _LIBCPP_STD_VER > 11
1330 template <typename _K2>
1331 _LIBCPP_INLINE_VISIBILITY
1332 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
1333 lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
1334
1335 template <typename _K2>
1336 _LIBCPP_INLINE_VISIBILITY
1337 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
1338 lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
1339#endif
1340
Howard Hinnant192cf032010-09-23 16:27:36 +00001341 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001342 iterator upper_bound(const key_type& __k)
1343 {return __tree_.upper_bound(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +00001344 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001345 const_iterator upper_bound(const key_type& __k) const
1346 {return __tree_.upper_bound(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +00001347#if _LIBCPP_STD_VER > 11
1348 template <typename _K2>
1349 _LIBCPP_INLINE_VISIBILITY
1350 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
1351 upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
1352 template <typename _K2>
1353 _LIBCPP_INLINE_VISIBILITY
1354 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
1355 upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
1356#endif
1357
Howard Hinnant192cf032010-09-23 16:27:36 +00001358 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001359 pair<iterator,iterator> equal_range(const key_type& __k)
1360 {return __tree_.__equal_range_multi(__k);}
Howard Hinnant192cf032010-09-23 16:27:36 +00001361 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001362 pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
1363 {return __tree_.__equal_range_multi(__k);}
Marshall Clowc0152142013-08-13 01:11:06 +00001364#if _LIBCPP_STD_VER > 11
1365 template <typename _K2>
1366 _LIBCPP_INLINE_VISIBILITY
1367 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
1368 equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
1369 template <typename _K2>
1370 _LIBCPP_INLINE_VISIBILITY
1371 typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
1372 equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
1373#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +00001374};
1375
Louis Dionne27ecc152019-06-11 18:21:08 +00001376#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1377template<class _InputIterator,
1378 class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
1379 class _Allocator = allocator<typename iterator_traits<_InputIterator>::value_type>,
1380 class = typename enable_if<__is_allocator<_Allocator>::value, void>::type,
1381 class = typename enable_if<!__is_allocator<_Compare>::value, void>::type>
1382multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
1383 -> multiset<typename iterator_traits<_InputIterator>::value_type, _Compare, _Allocator>;
1384
1385template<class _Key, class _Compare = less<_Key>,
1386 class _Allocator = allocator<_Key>,
1387 class = typename enable_if<__is_allocator<_Allocator>::value, void>::type,
1388 class = typename enable_if<!__is_allocator<_Compare>::value, void>::type>
1389multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
1390 -> multiset<_Key, _Compare, _Allocator>;
1391
1392template<class _InputIterator, class _Allocator,
1393 class = typename enable_if<__is_allocator<_Allocator>::value, void>::type>
1394multiset(_InputIterator, _InputIterator, _Allocator)
1395 -> multiset<typename iterator_traits<_InputIterator>::value_type,
1396 less<typename iterator_traits<_InputIterator>::value_type>, _Allocator>;
1397
1398template<class _Key, class _Allocator,
1399 class = typename enable_if<__is_allocator<_Allocator>::value, void>::type>
1400multiset(initializer_list<_Key>, _Allocator)
1401 -> multiset<_Key, less<_Key>, _Allocator>;
1402#endif
1403
Eric Fiselier615961b2017-04-18 20:58:03 +00001404#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +00001405
1406template <class _Key, class _Compare, class _Allocator>
1407multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001408 : __tree_(_VSTD::move(__s.__tree_), __a)
Howard Hinnantc51e1022010-05-11 19:42:16 +00001409{
1410 if (__a != __s.get_allocator())
1411 {
1412 const_iterator __e = cend();
1413 while (!__s.empty())
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001414 insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
Howard Hinnantc51e1022010-05-11 19:42:16 +00001415 }
1416}
1417
Eric Fiselier615961b2017-04-18 20:58:03 +00001418#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +00001419
1420template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001421inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001422bool
1423operator==(const multiset<_Key, _Compare, _Allocator>& __x,
1424 const multiset<_Key, _Compare, _Allocator>& __y)
1425{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001426 return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
Howard Hinnantc51e1022010-05-11 19:42:16 +00001427}
1428
1429template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001430inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001431bool
1432operator< (const multiset<_Key, _Compare, _Allocator>& __x,
1433 const multiset<_Key, _Compare, _Allocator>& __y)
1434{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +00001435 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
Howard Hinnantc51e1022010-05-11 19:42:16 +00001436}
1437
1438template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001439inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001440bool
1441operator!=(const multiset<_Key, _Compare, _Allocator>& __x,
1442 const multiset<_Key, _Compare, _Allocator>& __y)
1443{
1444 return !(__x == __y);
1445}
1446
1447template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001448inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001449bool
1450operator> (const multiset<_Key, _Compare, _Allocator>& __x,
1451 const multiset<_Key, _Compare, _Allocator>& __y)
1452{
1453 return __y < __x;
1454}
1455
1456template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001457inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001458bool
1459operator>=(const multiset<_Key, _Compare, _Allocator>& __x,
1460 const multiset<_Key, _Compare, _Allocator>& __y)
1461{
1462 return !(__x < __y);
1463}
1464
1465template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001466inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001467bool
1468operator<=(const multiset<_Key, _Compare, _Allocator>& __x,
1469 const multiset<_Key, _Compare, _Allocator>& __y)
1470{
1471 return !(__y < __x);
1472}
1473
1474template <class _Key, class _Compare, class _Allocator>
Howard Hinnant192cf032010-09-23 16:27:36 +00001475inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +00001476void
1477swap(multiset<_Key, _Compare, _Allocator>& __x,
1478 multiset<_Key, _Compare, _Allocator>& __y)
Howard Hinnantf95f4f52011-06-04 15:22:34 +00001479 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantc51e1022010-05-11 19:42:16 +00001480{
1481 __x.swap(__y);
1482}
1483
Marshall Clow29b53f22018-12-14 18:49:35 +00001484#if _LIBCPP_STD_VER > 17
1485template <class _Key, class _Compare, class _Allocator, class _Predicate>
1486inline _LIBCPP_INLINE_VISIBILITY
1487void erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred)
1488{ __libcpp_erase_if_container(__c, __pred); }
1489#endif
1490
Howard Hinnantc51e1022010-05-11 19:42:16 +00001491_LIBCPP_END_NAMESPACE_STD
1492
1493#endif // _LIBCPP_SET