set revision 1.1 1 1.1 joerg // -*- C++ -*-
2 1.1 joerg //===---------------------------- set -------------------------------------===//
3 1.1 joerg //
4 1.1 joerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 1.1 joerg // See https://llvm.org/LICENSE.txt for license information.
6 1.1 joerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 1.1 joerg //
8 1.1 joerg //===----------------------------------------------------------------------===//
9 1.1 joerg
10 1.1 joerg #ifndef _LIBCPP_SET
11 1.1 joerg #define _LIBCPP_SET
12 1.1 joerg
13 1.1 joerg /*
14 1.1 joerg
15 1.1 joerg set synopsis
16 1.1 joerg
17 1.1 joerg namespace std
18 1.1 joerg {
19 1.1 joerg
20 1.1 joerg template <class Key, class Compare = less<Key>,
21 1.1 joerg class Allocator = allocator<Key>>
22 1.1 joerg class set
23 1.1 joerg {
24 1.1 joerg public:
25 1.1 joerg // types:
26 1.1 joerg typedef Key key_type;
27 1.1 joerg typedef key_type value_type;
28 1.1 joerg typedef Compare key_compare;
29 1.1 joerg typedef key_compare value_compare;
30 1.1 joerg typedef Allocator allocator_type;
31 1.1 joerg typedef typename allocator_type::reference reference;
32 1.1 joerg typedef typename allocator_type::const_reference const_reference;
33 1.1 joerg typedef typename allocator_type::size_type size_type;
34 1.1 joerg typedef typename allocator_type::difference_type difference_type;
35 1.1 joerg typedef typename allocator_type::pointer pointer;
36 1.1 joerg typedef typename allocator_type::const_pointer const_pointer;
37 1.1 joerg
38 1.1 joerg typedef implementation-defined iterator;
39 1.1 joerg typedef implementation-defined const_iterator;
40 1.1 joerg typedef std::reverse_iterator<iterator> reverse_iterator;
41 1.1 joerg typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
42 1.1 joerg typedef unspecified node_type; // C++17
43 1.1 joerg typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
44 1.1 joerg
45 1.1 joerg // construct/copy/destroy:
46 1.1 joerg set()
47 1.1 joerg noexcept(
48 1.1 joerg is_nothrow_default_constructible<allocator_type>::value &&
49 1.1 joerg is_nothrow_default_constructible<key_compare>::value &&
50 1.1 joerg is_nothrow_copy_constructible<key_compare>::value);
51 1.1 joerg explicit set(const value_compare& comp);
52 1.1 joerg set(const value_compare& comp, const allocator_type& a);
53 1.1 joerg template <class InputIterator>
54 1.1 joerg set(InputIterator first, InputIterator last,
55 1.1 joerg const value_compare& comp = value_compare());
56 1.1 joerg template <class InputIterator>
57 1.1 joerg set(InputIterator first, InputIterator last, const value_compare& comp,
58 1.1 joerg const allocator_type& a);
59 1.1 joerg set(const set& s);
60 1.1 joerg set(set&& s)
61 1.1 joerg noexcept(
62 1.1 joerg is_nothrow_move_constructible<allocator_type>::value &&
63 1.1 joerg is_nothrow_move_constructible<key_compare>::value);
64 1.1 joerg explicit set(const allocator_type& a);
65 1.1 joerg set(const set& s, const allocator_type& a);
66 1.1 joerg set(set&& s, const allocator_type& a);
67 1.1 joerg set(initializer_list<value_type> il, const value_compare& comp = value_compare());
68 1.1 joerg set(initializer_list<value_type> il, const value_compare& comp,
69 1.1 joerg const allocator_type& a);
70 1.1 joerg template <class InputIterator>
71 1.1 joerg set(InputIterator first, InputIterator last, const allocator_type& a)
72 1.1 joerg : set(first, last, Compare(), a) {} // C++14
73 1.1 joerg set(initializer_list<value_type> il, const allocator_type& a)
74 1.1 joerg : set(il, Compare(), a) {} // C++14
75 1.1 joerg ~set();
76 1.1 joerg
77 1.1 joerg set& operator=(const set& s);
78 1.1 joerg set& operator=(set&& s)
79 1.1 joerg noexcept(
80 1.1 joerg allocator_type::propagate_on_container_move_assignment::value &&
81 1.1 joerg is_nothrow_move_assignable<allocator_type>::value &&
82 1.1 joerg is_nothrow_move_assignable<key_compare>::value);
83 1.1 joerg set& operator=(initializer_list<value_type> il);
84 1.1 joerg
85 1.1 joerg // iterators:
86 1.1 joerg iterator begin() noexcept;
87 1.1 joerg const_iterator begin() const noexcept;
88 1.1 joerg iterator end() noexcept;
89 1.1 joerg const_iterator end() const noexcept;
90 1.1 joerg
91 1.1 joerg reverse_iterator rbegin() noexcept;
92 1.1 joerg const_reverse_iterator rbegin() const noexcept;
93 1.1 joerg reverse_iterator rend() noexcept;
94 1.1 joerg const_reverse_iterator rend() const noexcept;
95 1.1 joerg
96 1.1 joerg const_iterator cbegin() const noexcept;
97 1.1 joerg const_iterator cend() const noexcept;
98 1.1 joerg const_reverse_iterator crbegin() const noexcept;
99 1.1 joerg const_reverse_iterator crend() const noexcept;
100 1.1 joerg
101 1.1 joerg // capacity:
102 1.1 joerg bool empty() const noexcept;
103 1.1 joerg size_type size() const noexcept;
104 1.1 joerg size_type max_size() const noexcept;
105 1.1 joerg
106 1.1 joerg // modifiers:
107 1.1 joerg template <class... Args>
108 1.1 joerg pair<iterator, bool> emplace(Args&&... args);
109 1.1 joerg template <class... Args>
110 1.1 joerg iterator emplace_hint(const_iterator position, Args&&... args);
111 1.1 joerg pair<iterator,bool> insert(const value_type& v);
112 1.1 joerg pair<iterator,bool> insert(value_type&& v);
113 1.1 joerg iterator insert(const_iterator position, const value_type& v);
114 1.1 joerg iterator insert(const_iterator position, value_type&& v);
115 1.1 joerg template <class InputIterator>
116 1.1 joerg void insert(InputIterator first, InputIterator last);
117 1.1 joerg void insert(initializer_list<value_type> il);
118 1.1 joerg
119 1.1 joerg node_type extract(const_iterator position); // C++17
120 1.1 joerg node_type extract(const key_type& x); // C++17
121 1.1 joerg insert_return_type insert(node_type&& nh); // C++17
122 1.1 joerg iterator insert(const_iterator hint, node_type&& nh); // C++17
123 1.1 joerg
124 1.1 joerg iterator erase(const_iterator position);
125 1.1 joerg iterator erase(iterator position); // C++14
126 1.1 joerg size_type erase(const key_type& k);
127 1.1 joerg iterator erase(const_iterator first, const_iterator last);
128 1.1 joerg void clear() noexcept;
129 1.1 joerg
130 1.1 joerg template<class C2>
131 1.1 joerg void merge(set<Key, C2, Allocator>& source); // C++17
132 1.1 joerg template<class C2>
133 1.1 joerg void merge(set<Key, C2, Allocator>&& source); // C++17
134 1.1 joerg template<class C2>
135 1.1 joerg void merge(multiset<Key, C2, Allocator>& source); // C++17
136 1.1 joerg template<class C2>
137 1.1 joerg void merge(multiset<Key, C2, Allocator>&& source); // C++17
138 1.1 joerg
139 1.1 joerg void swap(set& s)
140 1.1 joerg noexcept(
141 1.1 joerg __is_nothrow_swappable<key_compare>::value &&
142 1.1 joerg (!allocator_type::propagate_on_container_swap::value ||
143 1.1 joerg __is_nothrow_swappable<allocator_type>::value));
144 1.1 joerg
145 1.1 joerg // observers:
146 1.1 joerg allocator_type get_allocator() const noexcept;
147 1.1 joerg key_compare key_comp() const;
148 1.1 joerg value_compare value_comp() const;
149 1.1 joerg
150 1.1 joerg // set operations:
151 1.1 joerg iterator find(const key_type& k);
152 1.1 joerg const_iterator find(const key_type& k) const;
153 1.1 joerg template<typename K>
154 1.1 joerg iterator find(const K& x);
155 1.1 joerg template<typename K>
156 1.1 joerg const_iterator find(const K& x) const; // C++14
157 1.1 joerg
158 1.1 joerg template<typename K>
159 1.1 joerg size_type count(const K& x) const; // C++14
160 1.1 joerg size_type count(const key_type& k) const;
161 1.1 joerg
162 1.1 joerg bool contains(const key_type& x) const; // C++20
163 1.1 joerg template<class K> bool contains(const K& x) const; // C++20
164 1.1 joerg
165 1.1 joerg iterator lower_bound(const key_type& k);
166 1.1 joerg const_iterator lower_bound(const key_type& k) const;
167 1.1 joerg template<typename K>
168 1.1 joerg iterator lower_bound(const K& x); // C++14
169 1.1 joerg template<typename K>
170 1.1 joerg const_iterator lower_bound(const K& x) const; // C++14
171 1.1 joerg
172 1.1 joerg iterator upper_bound(const key_type& k);
173 1.1 joerg const_iterator upper_bound(const key_type& k) const;
174 1.1 joerg template<typename K>
175 1.1 joerg iterator upper_bound(const K& x); // C++14
176 1.1 joerg template<typename K>
177 1.1 joerg const_iterator upper_bound(const K& x) const; // C++14
178 1.1 joerg pair<iterator,iterator> equal_range(const key_type& k);
179 1.1 joerg pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
180 1.1 joerg template<typename K>
181 1.1 joerg pair<iterator,iterator> equal_range(const K& x); // C++14
182 1.1 joerg template<typename K>
183 1.1 joerg pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
184 1.1 joerg };
185 1.1 joerg
186 1.1 joerg template <class Key, class Compare, class Allocator>
187 1.1 joerg bool
188 1.1 joerg operator==(const set<Key, Compare, Allocator>& x,
189 1.1 joerg const set<Key, Compare, Allocator>& y);
190 1.1 joerg
191 1.1 joerg template <class Key, class Compare, class Allocator>
192 1.1 joerg bool
193 1.1 joerg operator< (const set<Key, Compare, Allocator>& x,
194 1.1 joerg const set<Key, Compare, Allocator>& y);
195 1.1 joerg
196 1.1 joerg template <class Key, class Compare, class Allocator>
197 1.1 joerg bool
198 1.1 joerg operator!=(const set<Key, Compare, Allocator>& x,
199 1.1 joerg const set<Key, Compare, Allocator>& y);
200 1.1 joerg
201 1.1 joerg template <class Key, class Compare, class Allocator>
202 1.1 joerg bool
203 1.1 joerg operator> (const set<Key, Compare, Allocator>& x,
204 1.1 joerg const set<Key, Compare, Allocator>& y);
205 1.1 joerg
206 1.1 joerg template <class Key, class Compare, class Allocator>
207 1.1 joerg bool
208 1.1 joerg operator>=(const set<Key, Compare, Allocator>& x,
209 1.1 joerg const set<Key, Compare, Allocator>& y);
210 1.1 joerg
211 1.1 joerg template <class Key, class Compare, class Allocator>
212 1.1 joerg bool
213 1.1 joerg operator<=(const set<Key, Compare, Allocator>& x,
214 1.1 joerg const set<Key, Compare, Allocator>& y);
215 1.1 joerg
216 1.1 joerg // specialized algorithms:
217 1.1 joerg template <class Key, class Compare, class Allocator>
218 1.1 joerg void
219 1.1 joerg swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
220 1.1 joerg noexcept(noexcept(x.swap(y)));
221 1.1 joerg
222 1.1 joerg template <class Key, class Compare, class Allocator, class Predicate>
223 1.1 joerg typename set<Key, Compare, Allocator>::size_type
224 1.1 joerg erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20
225 1.1 joerg
226 1.1 joerg template <class Key, class Compare = less<Key>,
227 1.1 joerg class Allocator = allocator<Key>>
228 1.1 joerg class multiset
229 1.1 joerg {
230 1.1 joerg public:
231 1.1 joerg // types:
232 1.1 joerg typedef Key key_type;
233 1.1 joerg typedef key_type value_type;
234 1.1 joerg typedef Compare key_compare;
235 1.1 joerg typedef key_compare value_compare;
236 1.1 joerg typedef Allocator allocator_type;
237 1.1 joerg typedef typename allocator_type::reference reference;
238 1.1 joerg typedef typename allocator_type::const_reference const_reference;
239 1.1 joerg typedef typename allocator_type::size_type size_type;
240 1.1 joerg typedef typename allocator_type::difference_type difference_type;
241 1.1 joerg typedef typename allocator_type::pointer pointer;
242 1.1 joerg typedef typename allocator_type::const_pointer const_pointer;
243 1.1 joerg
244 1.1 joerg typedef implementation-defined iterator;
245 1.1 joerg typedef implementation-defined const_iterator;
246 1.1 joerg typedef std::reverse_iterator<iterator> reverse_iterator;
247 1.1 joerg typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
248 1.1 joerg typedef unspecified node_type; // C++17
249 1.1 joerg
250 1.1 joerg // construct/copy/destroy:
251 1.1 joerg multiset()
252 1.1 joerg noexcept(
253 1.1 joerg is_nothrow_default_constructible<allocator_type>::value &&
254 1.1 joerg is_nothrow_default_constructible<key_compare>::value &&
255 1.1 joerg is_nothrow_copy_constructible<key_compare>::value);
256 1.1 joerg explicit multiset(const value_compare& comp);
257 1.1 joerg multiset(const value_compare& comp, const allocator_type& a);
258 1.1 joerg template <class InputIterator>
259 1.1 joerg multiset(InputIterator first, InputIterator last,
260 1.1 joerg const value_compare& comp = value_compare());
261 1.1 joerg template <class InputIterator>
262 1.1 joerg multiset(InputIterator first, InputIterator last,
263 1.1 joerg const value_compare& comp, const allocator_type& a);
264 1.1 joerg multiset(const multiset& s);
265 1.1 joerg multiset(multiset&& s)
266 1.1 joerg noexcept(
267 1.1 joerg is_nothrow_move_constructible<allocator_type>::value &&
268 1.1 joerg is_nothrow_move_constructible<key_compare>::value);
269 1.1 joerg explicit multiset(const allocator_type& a);
270 1.1 joerg multiset(const multiset& s, const allocator_type& a);
271 1.1 joerg multiset(multiset&& s, const allocator_type& a);
272 1.1 joerg multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
273 1.1 joerg multiset(initializer_list<value_type> il, const value_compare& comp,
274 1.1 joerg const allocator_type& a);
275 1.1 joerg template <class InputIterator>
276 1.1 joerg multiset(InputIterator first, InputIterator last, const allocator_type& a)
277 1.1 joerg : set(first, last, Compare(), a) {} // C++14
278 1.1 joerg multiset(initializer_list<value_type> il, const allocator_type& a)
279 1.1 joerg : set(il, Compare(), a) {} // C++14
280 1.1 joerg ~multiset();
281 1.1 joerg
282 1.1 joerg multiset& operator=(const multiset& s);
283 1.1 joerg multiset& operator=(multiset&& s)
284 1.1 joerg noexcept(
285 1.1 joerg allocator_type::propagate_on_container_move_assignment::value &&
286 1.1 joerg is_nothrow_move_assignable<allocator_type>::value &&
287 1.1 joerg is_nothrow_move_assignable<key_compare>::value);
288 1.1 joerg multiset& operator=(initializer_list<value_type> il);
289 1.1 joerg
290 1.1 joerg // iterators:
291 1.1 joerg iterator begin() noexcept;
292 1.1 joerg const_iterator begin() const noexcept;
293 1.1 joerg iterator end() noexcept;
294 1.1 joerg const_iterator end() const noexcept;
295 1.1 joerg
296 1.1 joerg reverse_iterator rbegin() noexcept;
297 1.1 joerg const_reverse_iterator rbegin() const noexcept;
298 1.1 joerg reverse_iterator rend() noexcept;
299 1.1 joerg const_reverse_iterator rend() const noexcept;
300 1.1 joerg
301 1.1 joerg const_iterator cbegin() const noexcept;
302 1.1 joerg const_iterator cend() const noexcept;
303 1.1 joerg const_reverse_iterator crbegin() const noexcept;
304 1.1 joerg const_reverse_iterator crend() const noexcept;
305 1.1 joerg
306 1.1 joerg // capacity:
307 1.1 joerg bool empty() const noexcept;
308 1.1 joerg size_type size() const noexcept;
309 1.1 joerg size_type max_size() const noexcept;
310 1.1 joerg
311 1.1 joerg // modifiers:
312 1.1 joerg template <class... Args>
313 1.1 joerg iterator emplace(Args&&... args);
314 1.1 joerg template <class... Args>
315 1.1 joerg iterator emplace_hint(const_iterator position, Args&&... args);
316 1.1 joerg iterator insert(const value_type& v);
317 1.1 joerg iterator insert(value_type&& v);
318 1.1 joerg iterator insert(const_iterator position, const value_type& v);
319 1.1 joerg iterator insert(const_iterator position, value_type&& v);
320 1.1 joerg template <class InputIterator>
321 1.1 joerg void insert(InputIterator first, InputIterator last);
322 1.1 joerg void insert(initializer_list<value_type> il);
323 1.1 joerg
324 1.1 joerg node_type extract(const_iterator position); // C++17
325 1.1 joerg node_type extract(const key_type& x); // C++17
326 1.1 joerg iterator insert(node_type&& nh); // C++17
327 1.1 joerg iterator insert(const_iterator hint, node_type&& nh); // C++17
328 1.1 joerg
329 1.1 joerg iterator erase(const_iterator position);
330 1.1 joerg iterator erase(iterator position); // C++14
331 1.1 joerg size_type erase(const key_type& k);
332 1.1 joerg iterator erase(const_iterator first, const_iterator last);
333 1.1 joerg void clear() noexcept;
334 1.1 joerg
335 1.1 joerg template<class C2>
336 1.1 joerg void merge(multiset<Key, C2, Allocator>& source); // C++17
337 1.1 joerg template<class C2>
338 1.1 joerg void merge(multiset<Key, C2, Allocator>&& source); // C++17
339 1.1 joerg template<class C2>
340 1.1 joerg void merge(set<Key, C2, Allocator>& source); // C++17
341 1.1 joerg template<class C2>
342 1.1 joerg void merge(set<Key, C2, Allocator>&& source); // C++17
343 1.1 joerg
344 1.1 joerg void swap(multiset& s)
345 1.1 joerg noexcept(
346 1.1 joerg __is_nothrow_swappable<key_compare>::value &&
347 1.1 joerg (!allocator_type::propagate_on_container_swap::value ||
348 1.1 joerg __is_nothrow_swappable<allocator_type>::value));
349 1.1 joerg
350 1.1 joerg // observers:
351 1.1 joerg allocator_type get_allocator() const noexcept;
352 1.1 joerg key_compare key_comp() const;
353 1.1 joerg value_compare value_comp() const;
354 1.1 joerg
355 1.1 joerg // set operations:
356 1.1 joerg iterator find(const key_type& k);
357 1.1 joerg const_iterator find(const key_type& k) const;
358 1.1 joerg template<typename K>
359 1.1 joerg iterator find(const K& x);
360 1.1 joerg template<typename K>
361 1.1 joerg const_iterator find(const K& x) const; // C++14
362 1.1 joerg
363 1.1 joerg template<typename K>
364 1.1 joerg size_type count(const K& x) const; // C++14
365 1.1 joerg size_type count(const key_type& k) const;
366 1.1 joerg
367 1.1 joerg bool contains(const key_type& x) const; // C++20
368 1.1 joerg template<class K> bool contains(const K& x) const; // C++20
369 1.1 joerg
370 1.1 joerg iterator lower_bound(const key_type& k);
371 1.1 joerg const_iterator lower_bound(const key_type& k) const;
372 1.1 joerg template<typename K>
373 1.1 joerg iterator lower_bound(const K& x); // C++14
374 1.1 joerg template<typename K>
375 1.1 joerg const_iterator lower_bound(const K& x) const; // C++14
376 1.1 joerg
377 1.1 joerg iterator upper_bound(const key_type& k);
378 1.1 joerg const_iterator upper_bound(const key_type& k) const;
379 1.1 joerg template<typename K>
380 1.1 joerg iterator upper_bound(const K& x); // C++14
381 1.1 joerg template<typename K>
382 1.1 joerg const_iterator upper_bound(const K& x) const; // C++14
383 1.1 joerg
384 1.1 joerg pair<iterator,iterator> equal_range(const key_type& k);
385 1.1 joerg pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
386 1.1 joerg template<typename K>
387 1.1 joerg pair<iterator,iterator> equal_range(const K& x); // C++14
388 1.1 joerg template<typename K>
389 1.1 joerg pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
390 1.1 joerg };
391 1.1 joerg
392 1.1 joerg template <class Key, class Compare, class Allocator>
393 1.1 joerg bool
394 1.1 joerg operator==(const multiset<Key, Compare, Allocator>& x,
395 1.1 joerg const multiset<Key, Compare, Allocator>& y);
396 1.1 joerg
397 1.1 joerg template <class Key, class Compare, class Allocator>
398 1.1 joerg bool
399 1.1 joerg operator< (const multiset<Key, Compare, Allocator>& x,
400 1.1 joerg const multiset<Key, Compare, Allocator>& y);
401 1.1 joerg
402 1.1 joerg template <class Key, class Compare, class Allocator>
403 1.1 joerg bool
404 1.1 joerg operator!=(const multiset<Key, Compare, Allocator>& x,
405 1.1 joerg const multiset<Key, Compare, Allocator>& y);
406 1.1 joerg
407 1.1 joerg template <class Key, class Compare, class Allocator>
408 1.1 joerg bool
409 1.1 joerg operator> (const multiset<Key, Compare, Allocator>& x,
410 1.1 joerg const multiset<Key, Compare, Allocator>& y);
411 1.1 joerg
412 1.1 joerg template <class Key, class Compare, class Allocator>
413 1.1 joerg bool
414 1.1 joerg operator>=(const multiset<Key, Compare, Allocator>& x,
415 1.1 joerg const multiset<Key, Compare, Allocator>& y);
416 1.1 joerg
417 1.1 joerg template <class Key, class Compare, class Allocator>
418 1.1 joerg bool
419 1.1 joerg operator<=(const multiset<Key, Compare, Allocator>& x,
420 1.1 joerg const multiset<Key, Compare, Allocator>& y);
421 1.1 joerg
422 1.1 joerg // specialized algorithms:
423 1.1 joerg template <class Key, class Compare, class Allocator>
424 1.1 joerg void
425 1.1 joerg swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
426 1.1 joerg noexcept(noexcept(x.swap(y)));
427 1.1 joerg
428 1.1 joerg template <class Key, class Compare, class Allocator, class Predicate>
429 1.1 joerg typename multiset<Key, Compare, Allocator>::size_type
430 1.1 joerg erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
431 1.1 joerg
432 1.1 joerg } // std
433 1.1 joerg
434 1.1 joerg */
435 1.1 joerg
436 1.1 joerg #include <__config>
437 1.1 joerg #include <__debug>
438 1.1 joerg #include <__node_handle>
439 1.1 joerg #include <__tree>
440 1.1 joerg #include <compare>
441 1.1 joerg #include <functional>
442 1.1 joerg #include <initializer_list>
443 1.1 joerg #include <iterator> // __libcpp_erase_if_container
444 1.1 joerg #include <version>
445 1.1 joerg
446 1.1 joerg #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
447 1.1 joerg #pragma GCC system_header
448 1.1 joerg #endif
449 1.1 joerg
450 1.1 joerg _LIBCPP_BEGIN_NAMESPACE_STD
451 1.1 joerg
452 1.1 joerg template <class _Key, class _Compare, class _Allocator>
453 1.1 joerg class multiset;
454 1.1 joerg
455 1.1 joerg template <class _Key, class _Compare = less<_Key>,
456 1.1 joerg class _Allocator = allocator<_Key> >
457 1.1 joerg class _LIBCPP_TEMPLATE_VIS set
458 1.1 joerg {
459 1.1 joerg public:
460 1.1 joerg // types:
461 1.1 joerg typedef _Key key_type;
462 1.1 joerg typedef key_type value_type;
463 1.1 joerg typedef _Compare key_compare;
464 1.1 joerg typedef key_compare value_compare;
465 1.1 joerg typedef __identity_t<_Allocator> allocator_type;
466 1.1 joerg typedef value_type& reference;
467 1.1 joerg typedef const value_type& const_reference;
468 1.1 joerg
469 1.1 joerg static_assert((is_same<typename allocator_type::value_type, value_type>::value),
470 1.1 joerg "Allocator::value_type must be same type as value_type");
471 1.1 joerg
472 1.1 joerg private:
473 1.1 joerg typedef __tree<value_type, value_compare, allocator_type> __base;
474 1.1 joerg typedef allocator_traits<allocator_type> __alloc_traits;
475 1.1 joerg typedef typename __base::__node_holder __node_holder;
476 1.1 joerg
477 1.1 joerg __base __tree_;
478 1.1 joerg
479 1.1 joerg public:
480 1.1 joerg typedef typename __base::pointer pointer;
481 1.1 joerg typedef typename __base::const_pointer const_pointer;
482 1.1 joerg typedef typename __base::size_type size_type;
483 1.1 joerg typedef typename __base::difference_type difference_type;
484 1.1 joerg typedef typename __base::const_iterator iterator;
485 1.1 joerg typedef typename __base::const_iterator const_iterator;
486 1.1 joerg typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
487 1.1 joerg typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
488 1.1 joerg
489 1.1 joerg #if _LIBCPP_STD_VER > 14
490 1.1 joerg typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
491 1.1 joerg typedef __insert_return_type<iterator, node_type> insert_return_type;
492 1.1 joerg #endif
493 1.1 joerg
494 1.1 joerg template <class _Key2, class _Compare2, class _Alloc2>
495 1.1 joerg friend class _LIBCPP_TEMPLATE_VIS set;
496 1.1 joerg template <class _Key2, class _Compare2, class _Alloc2>
497 1.1 joerg friend class _LIBCPP_TEMPLATE_VIS multiset;
498 1.1 joerg
499 1.1 joerg _LIBCPP_INLINE_VISIBILITY
500 1.1 joerg set()
501 1.1 joerg _NOEXCEPT_(
502 1.1 joerg is_nothrow_default_constructible<allocator_type>::value &&
503 1.1 joerg is_nothrow_default_constructible<key_compare>::value &&
504 1.1 joerg is_nothrow_copy_constructible<key_compare>::value)
505 1.1 joerg : __tree_(value_compare()) {}
506 1.1 joerg
507 1.1 joerg _LIBCPP_INLINE_VISIBILITY
508 1.1 joerg explicit set(const value_compare& __comp)
509 1.1 joerg _NOEXCEPT_(
510 1.1 joerg is_nothrow_default_constructible<allocator_type>::value &&
511 1.1 joerg is_nothrow_copy_constructible<key_compare>::value)
512 1.1 joerg : __tree_(__comp) {}
513 1.1 joerg
514 1.1 joerg _LIBCPP_INLINE_VISIBILITY
515 1.1 joerg explicit set(const value_compare& __comp, const allocator_type& __a)
516 1.1 joerg : __tree_(__comp, __a) {}
517 1.1 joerg template <class _InputIterator>
518 1.1 joerg _LIBCPP_INLINE_VISIBILITY
519 1.1 joerg set(_InputIterator __f, _InputIterator __l,
520 1.1 joerg const value_compare& __comp = value_compare())
521 1.1 joerg : __tree_(__comp)
522 1.1 joerg {
523 1.1 joerg insert(__f, __l);
524 1.1 joerg }
525 1.1 joerg
526 1.1 joerg template <class _InputIterator>
527 1.1 joerg _LIBCPP_INLINE_VISIBILITY
528 1.1 joerg set(_InputIterator __f, _InputIterator __l, const value_compare& __comp,
529 1.1 joerg const allocator_type& __a)
530 1.1 joerg : __tree_(__comp, __a)
531 1.1 joerg {
532 1.1 joerg insert(__f, __l);
533 1.1 joerg }
534 1.1 joerg
535 1.1 joerg #if _LIBCPP_STD_VER > 11
536 1.1 joerg template <class _InputIterator>
537 1.1 joerg _LIBCPP_INLINE_VISIBILITY
538 1.1 joerg set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
539 1.1 joerg : set(__f, __l, key_compare(), __a) {}
540 1.1 joerg #endif
541 1.1 joerg
542 1.1 joerg _LIBCPP_INLINE_VISIBILITY
543 1.1 joerg set(const set& __s)
544 1.1 joerg : __tree_(__s.__tree_)
545 1.1 joerg {
546 1.1 joerg insert(__s.begin(), __s.end());
547 1.1 joerg }
548 1.1 joerg
549 1.1 joerg _LIBCPP_INLINE_VISIBILITY
550 1.1 joerg set& operator=(const set& __s)
551 1.1 joerg {
552 1.1 joerg __tree_ = __s.__tree_;
553 1.1 joerg return *this;
554 1.1 joerg }
555 1.1 joerg
556 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
557 1.1 joerg _LIBCPP_INLINE_VISIBILITY
558 1.1 joerg set(set&& __s)
559 1.1 joerg _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
560 1.1 joerg : __tree_(_VSTD::move(__s.__tree_)) {}
561 1.1 joerg #endif // _LIBCPP_CXX03_LANG
562 1.1 joerg
563 1.1 joerg _LIBCPP_INLINE_VISIBILITY
564 1.1 joerg explicit set(const allocator_type& __a)
565 1.1 joerg : __tree_(__a) {}
566 1.1 joerg
567 1.1 joerg _LIBCPP_INLINE_VISIBILITY
568 1.1 joerg set(const set& __s, const allocator_type& __a)
569 1.1 joerg : __tree_(__s.__tree_.value_comp(), __a)
570 1.1 joerg {
571 1.1 joerg insert(__s.begin(), __s.end());
572 1.1 joerg }
573 1.1 joerg
574 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
575 1.1 joerg set(set&& __s, const allocator_type& __a);
576 1.1 joerg
577 1.1 joerg _LIBCPP_INLINE_VISIBILITY
578 1.1 joerg set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
579 1.1 joerg : __tree_(__comp)
580 1.1 joerg {
581 1.1 joerg insert(__il.begin(), __il.end());
582 1.1 joerg }
583 1.1 joerg
584 1.1 joerg _LIBCPP_INLINE_VISIBILITY
585 1.1 joerg set(initializer_list<value_type> __il, const value_compare& __comp,
586 1.1 joerg const allocator_type& __a)
587 1.1 joerg : __tree_(__comp, __a)
588 1.1 joerg {
589 1.1 joerg insert(__il.begin(), __il.end());
590 1.1 joerg }
591 1.1 joerg
592 1.1 joerg #if _LIBCPP_STD_VER > 11
593 1.1 joerg _LIBCPP_INLINE_VISIBILITY
594 1.1 joerg set(initializer_list<value_type> __il, const allocator_type& __a)
595 1.1 joerg : set(__il, key_compare(), __a) {}
596 1.1 joerg #endif
597 1.1 joerg
598 1.1 joerg _LIBCPP_INLINE_VISIBILITY
599 1.1 joerg set& operator=(initializer_list<value_type> __il)
600 1.1 joerg {
601 1.1 joerg __tree_.__assign_unique(__il.begin(), __il.end());
602 1.1 joerg return *this;
603 1.1 joerg }
604 1.1 joerg
605 1.1 joerg _LIBCPP_INLINE_VISIBILITY
606 1.1 joerg set& operator=(set&& __s)
607 1.1 joerg _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
608 1.1 joerg {
609 1.1 joerg __tree_ = _VSTD::move(__s.__tree_);
610 1.1 joerg return *this;
611 1.1 joerg }
612 1.1 joerg #endif // _LIBCPP_CXX03_LANG
613 1.1 joerg
614 1.1 joerg _LIBCPP_INLINE_VISIBILITY
615 1.1 joerg ~set() {
616 1.1 joerg static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
617 1.1 joerg }
618 1.1 joerg
619 1.1 joerg _LIBCPP_INLINE_VISIBILITY
620 1.1 joerg iterator begin() _NOEXCEPT {return __tree_.begin();}
621 1.1 joerg _LIBCPP_INLINE_VISIBILITY
622 1.1 joerg const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
623 1.1 joerg _LIBCPP_INLINE_VISIBILITY
624 1.1 joerg iterator end() _NOEXCEPT {return __tree_.end();}
625 1.1 joerg _LIBCPP_INLINE_VISIBILITY
626 1.1 joerg const_iterator end() const _NOEXCEPT {return __tree_.end();}
627 1.1 joerg
628 1.1 joerg _LIBCPP_INLINE_VISIBILITY
629 1.1 joerg reverse_iterator rbegin() _NOEXCEPT
630 1.1 joerg {return reverse_iterator(end());}
631 1.1 joerg _LIBCPP_INLINE_VISIBILITY
632 1.1 joerg const_reverse_iterator rbegin() const _NOEXCEPT
633 1.1 joerg {return const_reverse_iterator(end());}
634 1.1 joerg _LIBCPP_INLINE_VISIBILITY
635 1.1 joerg reverse_iterator rend() _NOEXCEPT
636 1.1 joerg {return reverse_iterator(begin());}
637 1.1 joerg _LIBCPP_INLINE_VISIBILITY
638 1.1 joerg const_reverse_iterator rend() const _NOEXCEPT
639 1.1 joerg {return const_reverse_iterator(begin());}
640 1.1 joerg
641 1.1 joerg _LIBCPP_INLINE_VISIBILITY
642 1.1 joerg const_iterator cbegin() const _NOEXCEPT {return begin();}
643 1.1 joerg _LIBCPP_INLINE_VISIBILITY
644 1.1 joerg const_iterator cend() const _NOEXCEPT {return end();}
645 1.1 joerg _LIBCPP_INLINE_VISIBILITY
646 1.1 joerg const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
647 1.1 joerg _LIBCPP_INLINE_VISIBILITY
648 1.1 joerg const_reverse_iterator crend() const _NOEXCEPT {return rend();}
649 1.1 joerg
650 1.1 joerg _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
651 1.1 joerg bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
652 1.1 joerg _LIBCPP_INLINE_VISIBILITY
653 1.1 joerg size_type size() const _NOEXCEPT {return __tree_.size();}
654 1.1 joerg _LIBCPP_INLINE_VISIBILITY
655 1.1 joerg size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
656 1.1 joerg
657 1.1 joerg // modifiers:
658 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
659 1.1 joerg template <class... _Args>
660 1.1 joerg _LIBCPP_INLINE_VISIBILITY
661 1.1 joerg pair<iterator, bool> emplace(_Args&&... __args)
662 1.1 joerg {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
663 1.1 joerg template <class... _Args>
664 1.1 joerg _LIBCPP_INLINE_VISIBILITY
665 1.1 joerg iterator emplace_hint(const_iterator __p, _Args&&... __args)
666 1.1 joerg {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);}
667 1.1 joerg #endif // _LIBCPP_CXX03_LANG
668 1.1 joerg
669 1.1 joerg _LIBCPP_INLINE_VISIBILITY
670 1.1 joerg pair<iterator,bool> insert(const value_type& __v)
671 1.1 joerg {return __tree_.__insert_unique(__v);}
672 1.1 joerg _LIBCPP_INLINE_VISIBILITY
673 1.1 joerg iterator insert(const_iterator __p, const value_type& __v)
674 1.1 joerg {return __tree_.__insert_unique(__p, __v);}
675 1.1 joerg
676 1.1 joerg template <class _InputIterator>
677 1.1 joerg _LIBCPP_INLINE_VISIBILITY
678 1.1 joerg void insert(_InputIterator __f, _InputIterator __l)
679 1.1 joerg {
680 1.1 joerg for (const_iterator __e = cend(); __f != __l; ++__f)
681 1.1 joerg __tree_.__insert_unique(__e, *__f);
682 1.1 joerg }
683 1.1 joerg
684 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
685 1.1 joerg _LIBCPP_INLINE_VISIBILITY
686 1.1 joerg pair<iterator,bool> insert(value_type&& __v)
687 1.1 joerg {return __tree_.__insert_unique(_VSTD::move(__v));}
688 1.1 joerg
689 1.1 joerg _LIBCPP_INLINE_VISIBILITY
690 1.1 joerg iterator insert(const_iterator __p, value_type&& __v)
691 1.1 joerg {return __tree_.__insert_unique(__p, _VSTD::move(__v));}
692 1.1 joerg
693 1.1 joerg _LIBCPP_INLINE_VISIBILITY
694 1.1 joerg void insert(initializer_list<value_type> __il)
695 1.1 joerg {insert(__il.begin(), __il.end());}
696 1.1 joerg #endif // _LIBCPP_CXX03_LANG
697 1.1 joerg
698 1.1 joerg _LIBCPP_INLINE_VISIBILITY
699 1.1 joerg iterator erase(const_iterator __p) {return __tree_.erase(__p);}
700 1.1 joerg _LIBCPP_INLINE_VISIBILITY
701 1.1 joerg size_type erase(const key_type& __k)
702 1.1 joerg {return __tree_.__erase_unique(__k);}
703 1.1 joerg _LIBCPP_INLINE_VISIBILITY
704 1.1 joerg iterator erase(const_iterator __f, const_iterator __l)
705 1.1 joerg {return __tree_.erase(__f, __l);}
706 1.1 joerg _LIBCPP_INLINE_VISIBILITY
707 1.1 joerg void clear() _NOEXCEPT {__tree_.clear();}
708 1.1 joerg
709 1.1 joerg #if _LIBCPP_STD_VER > 14
710 1.1 joerg _LIBCPP_INLINE_VISIBILITY
711 1.1 joerg insert_return_type insert(node_type&& __nh)
712 1.1 joerg {
713 1.1 joerg _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
714 1.1 joerg "node_type with incompatible allocator passed to set::insert()");
715 1.1 joerg return __tree_.template __node_handle_insert_unique<
716 1.1 joerg node_type, insert_return_type>(_VSTD::move(__nh));
717 1.1 joerg }
718 1.1 joerg _LIBCPP_INLINE_VISIBILITY
719 1.1 joerg iterator insert(const_iterator __hint, node_type&& __nh)
720 1.1 joerg {
721 1.1 joerg _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
722 1.1 joerg "node_type with incompatible allocator passed to set::insert()");
723 1.1 joerg return __tree_.template __node_handle_insert_unique<node_type>(
724 1.1 joerg __hint, _VSTD::move(__nh));
725 1.1 joerg }
726 1.1 joerg _LIBCPP_INLINE_VISIBILITY
727 1.1 joerg node_type extract(key_type const& __key)
728 1.1 joerg {
729 1.1 joerg return __tree_.template __node_handle_extract<node_type>(__key);
730 1.1 joerg }
731 1.1 joerg _LIBCPP_INLINE_VISIBILITY
732 1.1 joerg node_type extract(const_iterator __it)
733 1.1 joerg {
734 1.1 joerg return __tree_.template __node_handle_extract<node_type>(__it);
735 1.1 joerg }
736 1.1 joerg template <class _Compare2>
737 1.1 joerg _LIBCPP_INLINE_VISIBILITY
738 1.1 joerg void merge(set<key_type, _Compare2, allocator_type>& __source)
739 1.1 joerg {
740 1.1 joerg _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
741 1.1 joerg "merging container with incompatible allocator");
742 1.1 joerg __tree_.__node_handle_merge_unique(__source.__tree_);
743 1.1 joerg }
744 1.1 joerg template <class _Compare2>
745 1.1 joerg _LIBCPP_INLINE_VISIBILITY
746 1.1 joerg void merge(set<key_type, _Compare2, allocator_type>&& __source)
747 1.1 joerg {
748 1.1 joerg _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
749 1.1 joerg "merging container with incompatible allocator");
750 1.1 joerg __tree_.__node_handle_merge_unique(__source.__tree_);
751 1.1 joerg }
752 1.1 joerg template <class _Compare2>
753 1.1 joerg _LIBCPP_INLINE_VISIBILITY
754 1.1 joerg void merge(multiset<key_type, _Compare2, allocator_type>& __source)
755 1.1 joerg {
756 1.1 joerg _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
757 1.1 joerg "merging container with incompatible allocator");
758 1.1 joerg __tree_.__node_handle_merge_unique(__source.__tree_);
759 1.1 joerg }
760 1.1 joerg template <class _Compare2>
761 1.1 joerg _LIBCPP_INLINE_VISIBILITY
762 1.1 joerg void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
763 1.1 joerg {
764 1.1 joerg _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
765 1.1 joerg "merging container with incompatible allocator");
766 1.1 joerg __tree_.__node_handle_merge_unique(__source.__tree_);
767 1.1 joerg }
768 1.1 joerg #endif
769 1.1 joerg
770 1.1 joerg _LIBCPP_INLINE_VISIBILITY
771 1.1 joerg void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
772 1.1 joerg {__tree_.swap(__s.__tree_);}
773 1.1 joerg
774 1.1 joerg _LIBCPP_INLINE_VISIBILITY
775 1.1 joerg allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
776 1.1 joerg _LIBCPP_INLINE_VISIBILITY
777 1.1 joerg key_compare key_comp() const {return __tree_.value_comp();}
778 1.1 joerg _LIBCPP_INLINE_VISIBILITY
779 1.1 joerg value_compare value_comp() const {return __tree_.value_comp();}
780 1.1 joerg
781 1.1 joerg // set operations:
782 1.1 joerg _LIBCPP_INLINE_VISIBILITY
783 1.1 joerg iterator find(const key_type& __k) {return __tree_.find(__k);}
784 1.1 joerg _LIBCPP_INLINE_VISIBILITY
785 1.1 joerg const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
786 1.1 joerg #if _LIBCPP_STD_VER > 11
787 1.1 joerg template <typename _K2>
788 1.1 joerg _LIBCPP_INLINE_VISIBILITY
789 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
790 1.1 joerg find(const _K2& __k) {return __tree_.find(__k);}
791 1.1 joerg template <typename _K2>
792 1.1 joerg _LIBCPP_INLINE_VISIBILITY
793 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
794 1.1 joerg find(const _K2& __k) const {return __tree_.find(__k);}
795 1.1 joerg #endif
796 1.1 joerg
797 1.1 joerg _LIBCPP_INLINE_VISIBILITY
798 1.1 joerg size_type count(const key_type& __k) const
799 1.1 joerg {return __tree_.__count_unique(__k);}
800 1.1 joerg #if _LIBCPP_STD_VER > 11
801 1.1 joerg template <typename _K2>
802 1.1 joerg _LIBCPP_INLINE_VISIBILITY
803 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
804 1.1 joerg count(const _K2& __k) const {return __tree_.__count_multi(__k);}
805 1.1 joerg #endif
806 1.1 joerg
807 1.1 joerg #if _LIBCPP_STD_VER > 17
808 1.1 joerg _LIBCPP_INLINE_VISIBILITY
809 1.1 joerg bool contains(const key_type& __k) const {return find(__k) != end();}
810 1.1 joerg template <typename _K2>
811 1.1 joerg _LIBCPP_INLINE_VISIBILITY
812 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
813 1.1 joerg contains(const _K2& __k) const { return find(__k) != end(); }
814 1.1 joerg #endif // _LIBCPP_STD_VER > 17
815 1.1 joerg
816 1.1 joerg _LIBCPP_INLINE_VISIBILITY
817 1.1 joerg iterator lower_bound(const key_type& __k)
818 1.1 joerg {return __tree_.lower_bound(__k);}
819 1.1 joerg _LIBCPP_INLINE_VISIBILITY
820 1.1 joerg const_iterator lower_bound(const key_type& __k) const
821 1.1 joerg {return __tree_.lower_bound(__k);}
822 1.1 joerg #if _LIBCPP_STD_VER > 11
823 1.1 joerg template <typename _K2>
824 1.1 joerg _LIBCPP_INLINE_VISIBILITY
825 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
826 1.1 joerg lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
827 1.1 joerg
828 1.1 joerg template <typename _K2>
829 1.1 joerg _LIBCPP_INLINE_VISIBILITY
830 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
831 1.1 joerg lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
832 1.1 joerg #endif
833 1.1 joerg
834 1.1 joerg _LIBCPP_INLINE_VISIBILITY
835 1.1 joerg iterator upper_bound(const key_type& __k)
836 1.1 joerg {return __tree_.upper_bound(__k);}
837 1.1 joerg _LIBCPP_INLINE_VISIBILITY
838 1.1 joerg const_iterator upper_bound(const key_type& __k) const
839 1.1 joerg {return __tree_.upper_bound(__k);}
840 1.1 joerg #if _LIBCPP_STD_VER > 11
841 1.1 joerg template <typename _K2>
842 1.1 joerg _LIBCPP_INLINE_VISIBILITY
843 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
844 1.1 joerg upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
845 1.1 joerg template <typename _K2>
846 1.1 joerg _LIBCPP_INLINE_VISIBILITY
847 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
848 1.1 joerg upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
849 1.1 joerg #endif
850 1.1 joerg
851 1.1 joerg _LIBCPP_INLINE_VISIBILITY
852 1.1 joerg pair<iterator,iterator> equal_range(const key_type& __k)
853 1.1 joerg {return __tree_.__equal_range_unique(__k);}
854 1.1 joerg _LIBCPP_INLINE_VISIBILITY
855 1.1 joerg pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
856 1.1 joerg {return __tree_.__equal_range_unique(__k);}
857 1.1 joerg #if _LIBCPP_STD_VER > 11
858 1.1 joerg template <typename _K2>
859 1.1 joerg _LIBCPP_INLINE_VISIBILITY
860 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
861 1.1 joerg equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
862 1.1 joerg template <typename _K2>
863 1.1 joerg _LIBCPP_INLINE_VISIBILITY
864 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
865 1.1 joerg equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
866 1.1 joerg #endif
867 1.1 joerg };
868 1.1 joerg
869 1.1 joerg #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
870 1.1 joerg template<class _InputIterator,
871 1.1 joerg class _Compare = less<__iter_value_type<_InputIterator>>,
872 1.1 joerg class _Allocator = allocator<__iter_value_type<_InputIterator>>,
873 1.1 joerg class = _EnableIf<__is_allocator<_Allocator>::value, void>,
874 1.1 joerg class = _EnableIf<!__is_allocator<_Compare>::value, void>>
875 1.1 joerg set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
876 1.1 joerg -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
877 1.1 joerg
878 1.1 joerg template<class _Key, class _Compare = less<_Key>,
879 1.1 joerg class _Allocator = allocator<_Key>,
880 1.1 joerg class = _EnableIf<__is_allocator<_Allocator>::value, void>,
881 1.1 joerg class = _EnableIf<!__is_allocator<_Compare>::value, void>>
882 1.1 joerg set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
883 1.1 joerg -> set<_Key, _Compare, _Allocator>;
884 1.1 joerg
885 1.1 joerg template<class _InputIterator, class _Allocator,
886 1.1 joerg class = _EnableIf<__is_allocator<_Allocator>::value, void>>
887 1.1 joerg set(_InputIterator, _InputIterator, _Allocator)
888 1.1 joerg -> set<__iter_value_type<_InputIterator>,
889 1.1 joerg less<__iter_value_type<_InputIterator>>, _Allocator>;
890 1.1 joerg
891 1.1 joerg template<class _Key, class _Allocator,
892 1.1 joerg class = _EnableIf<__is_allocator<_Allocator>::value, void>>
893 1.1 joerg set(initializer_list<_Key>, _Allocator)
894 1.1 joerg -> set<_Key, less<_Key>, _Allocator>;
895 1.1 joerg #endif
896 1.1 joerg
897 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
898 1.1 joerg
899 1.1 joerg template <class _Key, class _Compare, class _Allocator>
900 1.1 joerg set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
901 1.1 joerg : __tree_(_VSTD::move(__s.__tree_), __a)
902 1.1 joerg {
903 1.1 joerg if (__a != __s.get_allocator())
904 1.1 joerg {
905 1.1 joerg const_iterator __e = cend();
906 1.1 joerg while (!__s.empty())
907 1.1 joerg insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
908 1.1 joerg }
909 1.1 joerg }
910 1.1 joerg
911 1.1 joerg #endif // _LIBCPP_CXX03_LANG
912 1.1 joerg
913 1.1 joerg template <class _Key, class _Compare, class _Allocator>
914 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
915 1.1 joerg bool
916 1.1 joerg operator==(const set<_Key, _Compare, _Allocator>& __x,
917 1.1 joerg const set<_Key, _Compare, _Allocator>& __y)
918 1.1 joerg {
919 1.1 joerg return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
920 1.1 joerg }
921 1.1 joerg
922 1.1 joerg template <class _Key, class _Compare, class _Allocator>
923 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
924 1.1 joerg bool
925 1.1 joerg operator< (const set<_Key, _Compare, _Allocator>& __x,
926 1.1 joerg const set<_Key, _Compare, _Allocator>& __y)
927 1.1 joerg {
928 1.1 joerg return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
929 1.1 joerg }
930 1.1 joerg
931 1.1 joerg template <class _Key, class _Compare, class _Allocator>
932 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
933 1.1 joerg bool
934 1.1 joerg operator!=(const set<_Key, _Compare, _Allocator>& __x,
935 1.1 joerg const set<_Key, _Compare, _Allocator>& __y)
936 1.1 joerg {
937 1.1 joerg return !(__x == __y);
938 1.1 joerg }
939 1.1 joerg
940 1.1 joerg template <class _Key, class _Compare, class _Allocator>
941 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
942 1.1 joerg bool
943 1.1 joerg operator> (const set<_Key, _Compare, _Allocator>& __x,
944 1.1 joerg const set<_Key, _Compare, _Allocator>& __y)
945 1.1 joerg {
946 1.1 joerg return __y < __x;
947 1.1 joerg }
948 1.1 joerg
949 1.1 joerg template <class _Key, class _Compare, class _Allocator>
950 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
951 1.1 joerg bool
952 1.1 joerg operator>=(const set<_Key, _Compare, _Allocator>& __x,
953 1.1 joerg const set<_Key, _Compare, _Allocator>& __y)
954 1.1 joerg {
955 1.1 joerg return !(__x < __y);
956 1.1 joerg }
957 1.1 joerg
958 1.1 joerg template <class _Key, class _Compare, class _Allocator>
959 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
960 1.1 joerg bool
961 1.1 joerg operator<=(const set<_Key, _Compare, _Allocator>& __x,
962 1.1 joerg const set<_Key, _Compare, _Allocator>& __y)
963 1.1 joerg {
964 1.1 joerg return !(__y < __x);
965 1.1 joerg }
966 1.1 joerg
967 1.1 joerg // specialized algorithms:
968 1.1 joerg template <class _Key, class _Compare, class _Allocator>
969 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
970 1.1 joerg void
971 1.1 joerg swap(set<_Key, _Compare, _Allocator>& __x,
972 1.1 joerg set<_Key, _Compare, _Allocator>& __y)
973 1.1 joerg _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
974 1.1 joerg {
975 1.1 joerg __x.swap(__y);
976 1.1 joerg }
977 1.1 joerg
978 1.1 joerg #if _LIBCPP_STD_VER > 17
979 1.1 joerg template <class _Key, class _Compare, class _Allocator, class _Predicate>
980 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
981 1.1 joerg typename set<_Key, _Compare, _Allocator>::size_type
982 1.1 joerg erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
983 1.1 joerg return _VSTD::__libcpp_erase_if_container(__c, __pred);
984 1.1 joerg }
985 1.1 joerg #endif
986 1.1 joerg
987 1.1 joerg template <class _Key, class _Compare = less<_Key>,
988 1.1 joerg class _Allocator = allocator<_Key> >
989 1.1 joerg class _LIBCPP_TEMPLATE_VIS multiset
990 1.1 joerg {
991 1.1 joerg public:
992 1.1 joerg // types:
993 1.1 joerg typedef _Key key_type;
994 1.1 joerg typedef key_type value_type;
995 1.1 joerg typedef _Compare key_compare;
996 1.1 joerg typedef key_compare value_compare;
997 1.1 joerg typedef __identity_t<_Allocator> allocator_type;
998 1.1 joerg typedef value_type& reference;
999 1.1 joerg typedef const value_type& const_reference;
1000 1.1 joerg
1001 1.1 joerg static_assert((is_same<typename allocator_type::value_type, value_type>::value),
1002 1.1 joerg "Allocator::value_type must be same type as value_type");
1003 1.1 joerg
1004 1.1 joerg private:
1005 1.1 joerg typedef __tree<value_type, value_compare, allocator_type> __base;
1006 1.1 joerg typedef allocator_traits<allocator_type> __alloc_traits;
1007 1.1 joerg typedef typename __base::__node_holder __node_holder;
1008 1.1 joerg
1009 1.1 joerg __base __tree_;
1010 1.1 joerg
1011 1.1 joerg public:
1012 1.1 joerg typedef typename __base::pointer pointer;
1013 1.1 joerg typedef typename __base::const_pointer const_pointer;
1014 1.1 joerg typedef typename __base::size_type size_type;
1015 1.1 joerg typedef typename __base::difference_type difference_type;
1016 1.1 joerg typedef typename __base::const_iterator iterator;
1017 1.1 joerg typedef typename __base::const_iterator const_iterator;
1018 1.1 joerg typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
1019 1.1 joerg typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
1020 1.1 joerg
1021 1.1 joerg #if _LIBCPP_STD_VER > 14
1022 1.1 joerg typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
1023 1.1 joerg #endif
1024 1.1 joerg
1025 1.1 joerg template <class _Key2, class _Compare2, class _Alloc2>
1026 1.1 joerg friend class _LIBCPP_TEMPLATE_VIS set;
1027 1.1 joerg template <class _Key2, class _Compare2, class _Alloc2>
1028 1.1 joerg friend class _LIBCPP_TEMPLATE_VIS multiset;
1029 1.1 joerg
1030 1.1 joerg // construct/copy/destroy:
1031 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1032 1.1 joerg multiset()
1033 1.1 joerg _NOEXCEPT_(
1034 1.1 joerg is_nothrow_default_constructible<allocator_type>::value &&
1035 1.1 joerg is_nothrow_default_constructible<key_compare>::value &&
1036 1.1 joerg is_nothrow_copy_constructible<key_compare>::value)
1037 1.1 joerg : __tree_(value_compare()) {}
1038 1.1 joerg
1039 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1040 1.1 joerg explicit multiset(const value_compare& __comp)
1041 1.1 joerg _NOEXCEPT_(
1042 1.1 joerg is_nothrow_default_constructible<allocator_type>::value &&
1043 1.1 joerg is_nothrow_copy_constructible<key_compare>::value)
1044 1.1 joerg : __tree_(__comp) {}
1045 1.1 joerg
1046 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1047 1.1 joerg explicit multiset(const value_compare& __comp, const allocator_type& __a)
1048 1.1 joerg : __tree_(__comp, __a) {}
1049 1.1 joerg template <class _InputIterator>
1050 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1051 1.1 joerg multiset(_InputIterator __f, _InputIterator __l,
1052 1.1 joerg const value_compare& __comp = value_compare())
1053 1.1 joerg : __tree_(__comp)
1054 1.1 joerg {
1055 1.1 joerg insert(__f, __l);
1056 1.1 joerg }
1057 1.1 joerg
1058 1.1 joerg #if _LIBCPP_STD_VER > 11
1059 1.1 joerg template <class _InputIterator>
1060 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1061 1.1 joerg multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
1062 1.1 joerg : multiset(__f, __l, key_compare(), __a) {}
1063 1.1 joerg #endif
1064 1.1 joerg
1065 1.1 joerg template <class _InputIterator>
1066 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1067 1.1 joerg multiset(_InputIterator __f, _InputIterator __l,
1068 1.1 joerg const value_compare& __comp, const allocator_type& __a)
1069 1.1 joerg : __tree_(__comp, __a)
1070 1.1 joerg {
1071 1.1 joerg insert(__f, __l);
1072 1.1 joerg }
1073 1.1 joerg
1074 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1075 1.1 joerg multiset(const multiset& __s)
1076 1.1 joerg : __tree_(__s.__tree_.value_comp(),
1077 1.1 joerg __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc()))
1078 1.1 joerg {
1079 1.1 joerg insert(__s.begin(), __s.end());
1080 1.1 joerg }
1081 1.1 joerg
1082 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1083 1.1 joerg multiset& operator=(const multiset& __s)
1084 1.1 joerg {
1085 1.1 joerg __tree_ = __s.__tree_;
1086 1.1 joerg return *this;
1087 1.1 joerg }
1088 1.1 joerg
1089 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
1090 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1091 1.1 joerg multiset(multiset&& __s)
1092 1.1 joerg _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
1093 1.1 joerg : __tree_(_VSTD::move(__s.__tree_)) {}
1094 1.1 joerg
1095 1.1 joerg multiset(multiset&& __s, const allocator_type& __a);
1096 1.1 joerg #endif // _LIBCPP_CXX03_LANG
1097 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1098 1.1 joerg explicit multiset(const allocator_type& __a)
1099 1.1 joerg : __tree_(__a) {}
1100 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1101 1.1 joerg multiset(const multiset& __s, const allocator_type& __a)
1102 1.1 joerg : __tree_(__s.__tree_.value_comp(), __a)
1103 1.1 joerg {
1104 1.1 joerg insert(__s.begin(), __s.end());
1105 1.1 joerg }
1106 1.1 joerg
1107 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
1108 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1109 1.1 joerg multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
1110 1.1 joerg : __tree_(__comp)
1111 1.1 joerg {
1112 1.1 joerg insert(__il.begin(), __il.end());
1113 1.1 joerg }
1114 1.1 joerg
1115 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1116 1.1 joerg multiset(initializer_list<value_type> __il, const value_compare& __comp,
1117 1.1 joerg const allocator_type& __a)
1118 1.1 joerg : __tree_(__comp, __a)
1119 1.1 joerg {
1120 1.1 joerg insert(__il.begin(), __il.end());
1121 1.1 joerg }
1122 1.1 joerg
1123 1.1 joerg #if _LIBCPP_STD_VER > 11
1124 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1125 1.1 joerg multiset(initializer_list<value_type> __il, const allocator_type& __a)
1126 1.1 joerg : multiset(__il, key_compare(), __a) {}
1127 1.1 joerg #endif
1128 1.1 joerg
1129 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1130 1.1 joerg multiset& operator=(initializer_list<value_type> __il)
1131 1.1 joerg {
1132 1.1 joerg __tree_.__assign_multi(__il.begin(), __il.end());
1133 1.1 joerg return *this;
1134 1.1 joerg }
1135 1.1 joerg
1136 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1137 1.1 joerg multiset& operator=(multiset&& __s)
1138 1.1 joerg _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
1139 1.1 joerg {
1140 1.1 joerg __tree_ = _VSTD::move(__s.__tree_);
1141 1.1 joerg return *this;
1142 1.1 joerg }
1143 1.1 joerg #endif // _LIBCPP_CXX03_LANG
1144 1.1 joerg
1145 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1146 1.1 joerg ~multiset() {
1147 1.1 joerg static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
1148 1.1 joerg }
1149 1.1 joerg
1150 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1151 1.1 joerg iterator begin() _NOEXCEPT {return __tree_.begin();}
1152 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1153 1.1 joerg const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
1154 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1155 1.1 joerg iterator end() _NOEXCEPT {return __tree_.end();}
1156 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1157 1.1 joerg const_iterator end() const _NOEXCEPT {return __tree_.end();}
1158 1.1 joerg
1159 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1160 1.1 joerg reverse_iterator rbegin() _NOEXCEPT
1161 1.1 joerg {return reverse_iterator(end());}
1162 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1163 1.1 joerg const_reverse_iterator rbegin() const _NOEXCEPT
1164 1.1 joerg {return const_reverse_iterator(end());}
1165 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1166 1.1 joerg reverse_iterator rend() _NOEXCEPT
1167 1.1 joerg {return reverse_iterator(begin());}
1168 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1169 1.1 joerg const_reverse_iterator rend() const _NOEXCEPT
1170 1.1 joerg {return const_reverse_iterator(begin());}
1171 1.1 joerg
1172 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1173 1.1 joerg const_iterator cbegin() const _NOEXCEPT {return begin();}
1174 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1175 1.1 joerg const_iterator cend() const _NOEXCEPT {return end();}
1176 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1177 1.1 joerg const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
1178 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1179 1.1 joerg const_reverse_iterator crend() const _NOEXCEPT {return rend();}
1180 1.1 joerg
1181 1.1 joerg _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
1182 1.1 joerg bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
1183 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1184 1.1 joerg size_type size() const _NOEXCEPT {return __tree_.size();}
1185 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1186 1.1 joerg size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
1187 1.1 joerg
1188 1.1 joerg // modifiers:
1189 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
1190 1.1 joerg template <class... _Args>
1191 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1192 1.1 joerg iterator emplace(_Args&&... __args)
1193 1.1 joerg {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
1194 1.1 joerg template <class... _Args>
1195 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1196 1.1 joerg iterator emplace_hint(const_iterator __p, _Args&&... __args)
1197 1.1 joerg {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
1198 1.1 joerg #endif // _LIBCPP_CXX03_LANG
1199 1.1 joerg
1200 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1201 1.1 joerg iterator insert(const value_type& __v)
1202 1.1 joerg {return __tree_.__insert_multi(__v);}
1203 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1204 1.1 joerg iterator insert(const_iterator __p, const value_type& __v)
1205 1.1 joerg {return __tree_.__insert_multi(__p, __v);}
1206 1.1 joerg
1207 1.1 joerg template <class _InputIterator>
1208 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1209 1.1 joerg void insert(_InputIterator __f, _InputIterator __l)
1210 1.1 joerg {
1211 1.1 joerg for (const_iterator __e = cend(); __f != __l; ++__f)
1212 1.1 joerg __tree_.__insert_multi(__e, *__f);
1213 1.1 joerg }
1214 1.1 joerg
1215 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
1216 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1217 1.1 joerg iterator insert(value_type&& __v)
1218 1.1 joerg {return __tree_.__insert_multi(_VSTD::move(__v));}
1219 1.1 joerg
1220 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1221 1.1 joerg iterator insert(const_iterator __p, value_type&& __v)
1222 1.1 joerg {return __tree_.__insert_multi(__p, _VSTD::move(__v));}
1223 1.1 joerg
1224 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1225 1.1 joerg void insert(initializer_list<value_type> __il)
1226 1.1 joerg {insert(__il.begin(), __il.end());}
1227 1.1 joerg #endif // _LIBCPP_CXX03_LANG
1228 1.1 joerg
1229 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1230 1.1 joerg iterator erase(const_iterator __p) {return __tree_.erase(__p);}
1231 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1232 1.1 joerg size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
1233 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1234 1.1 joerg iterator erase(const_iterator __f, const_iterator __l)
1235 1.1 joerg {return __tree_.erase(__f, __l);}
1236 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1237 1.1 joerg void clear() _NOEXCEPT {__tree_.clear();}
1238 1.1 joerg
1239 1.1 joerg #if _LIBCPP_STD_VER > 14
1240 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1241 1.1 joerg iterator insert(node_type&& __nh)
1242 1.1 joerg {
1243 1.1 joerg _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1244 1.1 joerg "node_type with incompatible allocator passed to multiset::insert()");
1245 1.1 joerg return __tree_.template __node_handle_insert_multi<node_type>(
1246 1.1 joerg _VSTD::move(__nh));
1247 1.1 joerg }
1248 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1249 1.1 joerg iterator insert(const_iterator __hint, node_type&& __nh)
1250 1.1 joerg {
1251 1.1 joerg _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1252 1.1 joerg "node_type with incompatible allocator passed to multiset::insert()");
1253 1.1 joerg return __tree_.template __node_handle_insert_multi<node_type>(
1254 1.1 joerg __hint, _VSTD::move(__nh));
1255 1.1 joerg }
1256 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1257 1.1 joerg node_type extract(key_type const& __key)
1258 1.1 joerg {
1259 1.1 joerg return __tree_.template __node_handle_extract<node_type>(__key);
1260 1.1 joerg }
1261 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1262 1.1 joerg node_type extract(const_iterator __it)
1263 1.1 joerg {
1264 1.1 joerg return __tree_.template __node_handle_extract<node_type>(__it);
1265 1.1 joerg }
1266 1.1 joerg template <class _Compare2>
1267 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1268 1.1 joerg void merge(multiset<key_type, _Compare2, allocator_type>& __source)
1269 1.1 joerg {
1270 1.1 joerg _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1271 1.1 joerg "merging container with incompatible allocator");
1272 1.1 joerg __tree_.__node_handle_merge_multi(__source.__tree_);
1273 1.1 joerg }
1274 1.1 joerg template <class _Compare2>
1275 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1276 1.1 joerg void merge(multiset<key_type, _Compare2, allocator_type>&& __source)
1277 1.1 joerg {
1278 1.1 joerg _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1279 1.1 joerg "merging container with incompatible allocator");
1280 1.1 joerg __tree_.__node_handle_merge_multi(__source.__tree_);
1281 1.1 joerg }
1282 1.1 joerg template <class _Compare2>
1283 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1284 1.1 joerg void merge(set<key_type, _Compare2, allocator_type>& __source)
1285 1.1 joerg {
1286 1.1 joerg _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1287 1.1 joerg "merging container with incompatible allocator");
1288 1.1 joerg __tree_.__node_handle_merge_multi(__source.__tree_);
1289 1.1 joerg }
1290 1.1 joerg template <class _Compare2>
1291 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1292 1.1 joerg void merge(set<key_type, _Compare2, allocator_type>&& __source)
1293 1.1 joerg {
1294 1.1 joerg _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1295 1.1 joerg "merging container with incompatible allocator");
1296 1.1 joerg __tree_.__node_handle_merge_multi(__source.__tree_);
1297 1.1 joerg }
1298 1.1 joerg #endif
1299 1.1 joerg
1300 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1301 1.1 joerg void swap(multiset& __s)
1302 1.1 joerg _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
1303 1.1 joerg {__tree_.swap(__s.__tree_);}
1304 1.1 joerg
1305 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1306 1.1 joerg allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
1307 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1308 1.1 joerg key_compare key_comp() const {return __tree_.value_comp();}
1309 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1310 1.1 joerg value_compare value_comp() const {return __tree_.value_comp();}
1311 1.1 joerg
1312 1.1 joerg // set operations:
1313 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1314 1.1 joerg iterator find(const key_type& __k) {return __tree_.find(__k);}
1315 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1316 1.1 joerg const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
1317 1.1 joerg #if _LIBCPP_STD_VER > 11
1318 1.1 joerg template <typename _K2>
1319 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1320 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
1321 1.1 joerg find(const _K2& __k) {return __tree_.find(__k);}
1322 1.1 joerg template <typename _K2>
1323 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1324 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
1325 1.1 joerg find(const _K2& __k) const {return __tree_.find(__k);}
1326 1.1 joerg #endif
1327 1.1 joerg
1328 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1329 1.1 joerg size_type count(const key_type& __k) const
1330 1.1 joerg {return __tree_.__count_multi(__k);}
1331 1.1 joerg #if _LIBCPP_STD_VER > 11
1332 1.1 joerg template <typename _K2>
1333 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1334 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
1335 1.1 joerg count(const _K2& __k) const {return __tree_.__count_multi(__k);}
1336 1.1 joerg #endif
1337 1.1 joerg
1338 1.1 joerg #if _LIBCPP_STD_VER > 17
1339 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1340 1.1 joerg bool contains(const key_type& __k) const {return find(__k) != end();}
1341 1.1 joerg template <typename _K2>
1342 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1343 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
1344 1.1 joerg contains(const _K2& __k) const { return find(__k) != end(); }
1345 1.1 joerg #endif // _LIBCPP_STD_VER > 17
1346 1.1 joerg
1347 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1348 1.1 joerg iterator lower_bound(const key_type& __k)
1349 1.1 joerg {return __tree_.lower_bound(__k);}
1350 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1351 1.1 joerg const_iterator lower_bound(const key_type& __k) const
1352 1.1 joerg {return __tree_.lower_bound(__k);}
1353 1.1 joerg #if _LIBCPP_STD_VER > 11
1354 1.1 joerg template <typename _K2>
1355 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1356 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
1357 1.1 joerg lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
1358 1.1 joerg
1359 1.1 joerg template <typename _K2>
1360 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1361 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
1362 1.1 joerg lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
1363 1.1 joerg #endif
1364 1.1 joerg
1365 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1366 1.1 joerg iterator upper_bound(const key_type& __k)
1367 1.1 joerg {return __tree_.upper_bound(__k);}
1368 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1369 1.1 joerg const_iterator upper_bound(const key_type& __k) const
1370 1.1 joerg {return __tree_.upper_bound(__k);}
1371 1.1 joerg #if _LIBCPP_STD_VER > 11
1372 1.1 joerg template <typename _K2>
1373 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1374 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
1375 1.1 joerg upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
1376 1.1 joerg template <typename _K2>
1377 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1378 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
1379 1.1 joerg upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
1380 1.1 joerg #endif
1381 1.1 joerg
1382 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1383 1.1 joerg pair<iterator,iterator> equal_range(const key_type& __k)
1384 1.1 joerg {return __tree_.__equal_range_multi(__k);}
1385 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1386 1.1 joerg pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
1387 1.1 joerg {return __tree_.__equal_range_multi(__k);}
1388 1.1 joerg #if _LIBCPP_STD_VER > 11
1389 1.1 joerg template <typename _K2>
1390 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1391 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
1392 1.1 joerg equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
1393 1.1 joerg template <typename _K2>
1394 1.1 joerg _LIBCPP_INLINE_VISIBILITY
1395 1.1 joerg typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
1396 1.1 joerg equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
1397 1.1 joerg #endif
1398 1.1 joerg };
1399 1.1 joerg
1400 1.1 joerg #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1401 1.1 joerg template<class _InputIterator,
1402 1.1 joerg class _Compare = less<__iter_value_type<_InputIterator>>,
1403 1.1 joerg class _Allocator = allocator<__iter_value_type<_InputIterator>>,
1404 1.1 joerg class = _EnableIf<__is_allocator<_Allocator>::value, void>,
1405 1.1 joerg class = _EnableIf<!__is_allocator<_Compare>::value, void>>
1406 1.1 joerg multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
1407 1.1 joerg -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
1408 1.1 joerg
1409 1.1 joerg template<class _Key, class _Compare = less<_Key>,
1410 1.1 joerg class _Allocator = allocator<_Key>,
1411 1.1 joerg class = _EnableIf<__is_allocator<_Allocator>::value, void>,
1412 1.1 joerg class = _EnableIf<!__is_allocator<_Compare>::value, void>>
1413 1.1 joerg multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
1414 1.1 joerg -> multiset<_Key, _Compare, _Allocator>;
1415 1.1 joerg
1416 1.1 joerg template<class _InputIterator, class _Allocator,
1417 1.1 joerg class = _EnableIf<__is_allocator<_Allocator>::value, void>>
1418 1.1 joerg multiset(_InputIterator, _InputIterator, _Allocator)
1419 1.1 joerg -> multiset<__iter_value_type<_InputIterator>,
1420 1.1 joerg less<__iter_value_type<_InputIterator>>, _Allocator>;
1421 1.1 joerg
1422 1.1 joerg template<class _Key, class _Allocator,
1423 1.1 joerg class = _EnableIf<__is_allocator<_Allocator>::value, void>>
1424 1.1 joerg multiset(initializer_list<_Key>, _Allocator)
1425 1.1 joerg -> multiset<_Key, less<_Key>, _Allocator>;
1426 1.1 joerg #endif
1427 1.1 joerg
1428 1.1 joerg #ifndef _LIBCPP_CXX03_LANG
1429 1.1 joerg
1430 1.1 joerg template <class _Key, class _Compare, class _Allocator>
1431 1.1 joerg multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
1432 1.1 joerg : __tree_(_VSTD::move(__s.__tree_), __a)
1433 1.1 joerg {
1434 1.1 joerg if (__a != __s.get_allocator())
1435 1.1 joerg {
1436 1.1 joerg const_iterator __e = cend();
1437 1.1 joerg while (!__s.empty())
1438 1.1 joerg insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
1439 1.1 joerg }
1440 1.1 joerg }
1441 1.1 joerg
1442 1.1 joerg #endif // _LIBCPP_CXX03_LANG
1443 1.1 joerg
1444 1.1 joerg template <class _Key, class _Compare, class _Allocator>
1445 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
1446 1.1 joerg bool
1447 1.1 joerg operator==(const multiset<_Key, _Compare, _Allocator>& __x,
1448 1.1 joerg const multiset<_Key, _Compare, _Allocator>& __y)
1449 1.1 joerg {
1450 1.1 joerg return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
1451 1.1 joerg }
1452 1.1 joerg
1453 1.1 joerg template <class _Key, class _Compare, class _Allocator>
1454 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
1455 1.1 joerg bool
1456 1.1 joerg operator< (const multiset<_Key, _Compare, _Allocator>& __x,
1457 1.1 joerg const multiset<_Key, _Compare, _Allocator>& __y)
1458 1.1 joerg {
1459 1.1 joerg return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
1460 1.1 joerg }
1461 1.1 joerg
1462 1.1 joerg template <class _Key, class _Compare, class _Allocator>
1463 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
1464 1.1 joerg bool
1465 1.1 joerg operator!=(const multiset<_Key, _Compare, _Allocator>& __x,
1466 1.1 joerg const multiset<_Key, _Compare, _Allocator>& __y)
1467 1.1 joerg {
1468 1.1 joerg return !(__x == __y);
1469 1.1 joerg }
1470 1.1 joerg
1471 1.1 joerg template <class _Key, class _Compare, class _Allocator>
1472 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
1473 1.1 joerg bool
1474 1.1 joerg operator> (const multiset<_Key, _Compare, _Allocator>& __x,
1475 1.1 joerg const multiset<_Key, _Compare, _Allocator>& __y)
1476 1.1 joerg {
1477 1.1 joerg return __y < __x;
1478 1.1 joerg }
1479 1.1 joerg
1480 1.1 joerg template <class _Key, class _Compare, class _Allocator>
1481 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
1482 1.1 joerg bool
1483 1.1 joerg operator>=(const multiset<_Key, _Compare, _Allocator>& __x,
1484 1.1 joerg const multiset<_Key, _Compare, _Allocator>& __y)
1485 1.1 joerg {
1486 1.1 joerg return !(__x < __y);
1487 1.1 joerg }
1488 1.1 joerg
1489 1.1 joerg template <class _Key, class _Compare, class _Allocator>
1490 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
1491 1.1 joerg bool
1492 1.1 joerg operator<=(const multiset<_Key, _Compare, _Allocator>& __x,
1493 1.1 joerg const multiset<_Key, _Compare, _Allocator>& __y)
1494 1.1 joerg {
1495 1.1 joerg return !(__y < __x);
1496 1.1 joerg }
1497 1.1 joerg
1498 1.1 joerg template <class _Key, class _Compare, class _Allocator>
1499 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
1500 1.1 joerg void
1501 1.1 joerg swap(multiset<_Key, _Compare, _Allocator>& __x,
1502 1.1 joerg multiset<_Key, _Compare, _Allocator>& __y)
1503 1.1 joerg _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
1504 1.1 joerg {
1505 1.1 joerg __x.swap(__y);
1506 1.1 joerg }
1507 1.1 joerg
1508 1.1 joerg #if _LIBCPP_STD_VER > 17
1509 1.1 joerg template <class _Key, class _Compare, class _Allocator, class _Predicate>
1510 1.1 joerg inline _LIBCPP_INLINE_VISIBILITY
1511 1.1 joerg typename multiset<_Key, _Compare, _Allocator>::size_type
1512 1.1 joerg erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
1513 1.1 joerg return _VSTD::__libcpp_erase_if_container(__c, __pred);
1514 1.1 joerg }
1515 1.1 joerg #endif
1516 1.1 joerg
1517 1.1 joerg _LIBCPP_END_NAMESPACE_STD
1518 1.1 joerg
1519 1.1 joerg #endif // _LIBCPP_SET
1520