]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/debug/set.h
i386: Change Diamond Rapids feature detect when model number could not be distinguished
[thirdparty/gcc.git] / libstdc++-v3 / include / debug / set.h
CommitLineData
285b36d6
BK
1// Debugging set implementation -*- C++ -*-
2
6441eb6d 3// Copyright (C) 2003-2025 Free Software Foundation, Inc.
285b36d6
BK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
285b36d6
BK
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
748086b7
JJ
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
285b36d6 19
748086b7
JJ
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
285b36d6 24
78a53887
BK
25/** @file debug/set.h
26 * This file is a GNU debug extension to the Standard C++ Library.
27 */
28
285b36d6
BK
29#ifndef _GLIBCXX_DEBUG_SET_H
30#define _GLIBCXX_DEBUG_SET_H 1
31
32#include <debug/safe_sequence.h>
15ee1a77 33#include <debug/safe_container.h>
285b36d6 34#include <debug/safe_iterator.h>
16158c96 35#include <bits/stl_pair.h>
285b36d6 36
15ee1a77 37namespace std _GLIBCXX_VISIBILITY(default)
3cbc7af0 38{
45f388bb 39namespace __debug
285b36d6 40{
1ceb9e06 41 /// Class std::set with safety/checking/debug instrumentation.
285b36d6
BK
42 template<typename _Key, typename _Compare = std::less<_Key>,
43 typename _Allocator = std::allocator<_Key> >
44 class set
15ee1a77
FD
45 : public __gnu_debug::_Safe_container<
46 set<_Key, _Compare, _Allocator>, _Allocator,
47 __gnu_debug::_Safe_node_sequence>,
48 public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>
285b36d6 49 {
15ee1a77
FD
50 typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base;
51 typedef __gnu_debug::_Safe_container<
52 set, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe;
526da49c 53
15ee1a77
FD
54 typedef typename _Base::const_iterator _Base_const_iterator;
55 typedef typename _Base::iterator _Base_iterator;
afe96d41 56 typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
15ee1a77 57
e9afbed0
FD
58 template<typename _ItT, typename _SeqT, typename _CatT>
59 friend class ::__gnu_debug::_Safe_iterator;
60
eca833b8
JW
61 // Reference wrapper for base class. Disambiguates set(const _Base&)
62 // from copy constructor by requiring a user-defined conversion.
63 // See PR libstdc++/90102.
64 struct _Base_ref
65 {
66 _Base_ref(const _Base& __r) : _M_ref(__r) { }
67
68 const _Base& _M_ref;
69 };
70
285b36d6
BK
71 public:
72 // types:
15ee1a77
FD
73 typedef _Key key_type;
74 typedef _Key value_type;
75 typedef _Compare key_compare;
76 typedef _Compare value_compare;
77 typedef _Allocator allocator_type;
78 typedef typename _Base::reference reference;
79 typedef typename _Base::const_reference const_reference;
526da49c 80
afe96d41 81 typedef __gnu_debug::_Safe_iterator<_Base_iterator, set>
15ee1a77 82 iterator;
afe96d41 83 typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, set>
15ee1a77 84 const_iterator;
285b36d6 85
15ee1a77
FD
86 typedef typename _Base::size_type size_type;
87 typedef typename _Base::difference_type difference_type;
88 typedef typename _Base::pointer pointer;
89 typedef typename _Base::const_pointer const_pointer;
90 typedef std::reverse_iterator<iterator> reverse_iterator;
91 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
526da49c 92
285b36d6 93 // 23.3.3.1 construct/copy/destroy:
c3cdd71f 94
15ee1a77 95#if __cplusplus < 201103L
c3cdd71f
JW
96 set() : _Base() { }
97
ed540c0a 98 set(const set& __x)
4c2d93db 99 : _Base(__x) { }
526da49c 100
15ee1a77
FD
101 ~set() { }
102#else
103 set() = default;
104 set(const set&) = default;
105 set(set&&) = default;
988499f4
JM
106
107 set(initializer_list<value_type> __l,
108 const _Compare& __comp = _Compare(),
109 const allocator_type& __a = allocator_type())
4c2d93db 110 : _Base(__l, __comp, __a) { }
51835a80
FD
111
112 explicit
113 set(const allocator_type& __a)
114 : _Base(__a) { }
115
22d34a2a 116 set(const set& __x, const __type_identity_t<allocator_type>& __a)
51835a80
FD
117 : _Base(__x, __a) { }
118
22d34a2a 119 set(set&& __x, const __type_identity_t<allocator_type>& __a)
e9a53a4f
FD
120 noexcept( noexcept(_Base(std::move(__x), __a)) )
121 : _Safe(std::move(__x), __a),
122 _Base(std::move(__x), __a) { }
51835a80
FD
123
124 set(initializer_list<value_type> __l, const allocator_type& __a)
15ee1a77 125 : _Base(__l, __a) { }
51835a80
FD
126
127 template<typename _InputIterator>
15ee1a77 128 set(_InputIterator __first, _InputIterator __last,
51835a80 129 const allocator_type& __a)
90aabc7e
FD
130 : _Base(__gnu_debug::__base(
131 __glibcxx_check_valid_constructor_range(__first, __last)),
15ee1a77
FD
132 __gnu_debug::__base(__last), __a) { }
133
ae54d8cb 134#if __glibcxx_containers_ranges // C++ >= 23
f3253bd7
JW
135 /**
136 * @brief Construct a set from a range.
137 * @since C++23
138 */
139 template<std::__detail::__container_compatible_range<_Key> _Rg>
140 set(std::from_range_t __t, _Rg&& __rg,
141 const _Compare& __c,
142 const allocator_type& __a = allocator_type())
143 : _Base(__t, std::forward<_Rg>(__rg), __c, __a)
144 { }
145
146 template<std::__detail::__container_compatible_range<_Key> _Rg>
147 set(std::from_range_t __t, _Rg&& __rg,
148 const allocator_type& __a = allocator_type())
149 : _Base(__t, std::forward<_Rg>(__rg), __a)
150 { }
151#endif
152
153 ~set() = default;
ed540c0a 154#endif
526da49c 155
15ee1a77
FD
156 explicit set(const _Compare& __comp,
157 const _Allocator& __a = _Allocator())
158 : _Base(__comp, __a) { }
159
160 template<typename _InputIterator>
161 set(_InputIterator __first, _InputIterator __last,
162 const _Compare& __comp = _Compare(),
163 const _Allocator& __a = _Allocator())
90aabc7e
FD
164 : _Base(__gnu_debug::__base(
165 __glibcxx_check_valid_constructor_range(__first, __last)),
15ee1a77
FD
166 __gnu_debug::__base(__last),
167 __comp, __a) { }
526da49c 168
eca833b8
JW
169 set(_Base_ref __x)
170 : _Base(__x._M_ref) { }
15ee1a77 171
4a407d35 172#if __cplusplus >= 201103L
15ee1a77
FD
173 set&
174 operator=(const set&) = default;
526da49c 175
ed540c0a 176 set&
15ee1a77 177 operator=(set&&) = default;
988499f4
JM
178
179 set&
180 operator=(initializer_list<value_type> __l)
181 {
e9a53a4f 182 _Base::operator=(__l);
51835a80 183 this->_M_invalidate_all();
988499f4
JM
184 return *this;
185 }
ed540c0a
CJ
186#endif
187
285b36d6 188 using _Base::get_allocator;
526da49c 189
285b36d6 190 // iterators:
526da49c 191 iterator
d3677132 192 begin() _GLIBCXX_NOEXCEPT
285b36d6 193 { return iterator(_Base::begin(), this); }
526da49c
BI
194
195 const_iterator
d3677132 196 begin() const _GLIBCXX_NOEXCEPT
285b36d6 197 { return const_iterator(_Base::begin(), this); }
526da49c
BI
198
199 iterator
d3677132 200 end() _GLIBCXX_NOEXCEPT
285b36d6 201 { return iterator(_Base::end(), this); }
526da49c
BI
202
203 const_iterator
d3677132 204 end() const _GLIBCXX_NOEXCEPT
285b36d6 205 { return const_iterator(_Base::end(), this); }
526da49c
BI
206
207 reverse_iterator
d3677132 208 rbegin() _GLIBCXX_NOEXCEPT
285b36d6 209 { return reverse_iterator(end()); }
526da49c
BI
210
211 const_reverse_iterator
d3677132 212 rbegin() const _GLIBCXX_NOEXCEPT
285b36d6 213 { return const_reverse_iterator(end()); }
526da49c
BI
214
215 reverse_iterator
d3677132 216 rend() _GLIBCXX_NOEXCEPT
285b36d6 217 { return reverse_iterator(begin()); }
526da49c
BI
218
219 const_reverse_iterator
d3677132 220 rend() const _GLIBCXX_NOEXCEPT
285b36d6 221 { return const_reverse_iterator(begin()); }
526da49c 222
734f5023 223#if __cplusplus >= 201103L
0cd50f89 224 const_iterator
d3677132 225 cbegin() const noexcept
0cd50f89
PC
226 { return const_iterator(_Base::begin(), this); }
227
228 const_iterator
d3677132 229 cend() const noexcept
0cd50f89
PC
230 { return const_iterator(_Base::end(), this); }
231
232 const_reverse_iterator
d3677132 233 crbegin() const noexcept
0cd50f89
PC
234 { return const_reverse_iterator(end()); }
235
236 const_reverse_iterator
d3677132 237 crend() const noexcept
0cd50f89
PC
238 { return const_reverse_iterator(begin()); }
239#endif
240
285b36d6
BK
241 // capacity:
242 using _Base::empty;
243 using _Base::size;
244 using _Base::max_size;
526da49c 245
285b36d6 246 // modifiers:
734f5023 247#if __cplusplus >= 201103L
55826ab6
FD
248 template<typename... _Args>
249 std::pair<iterator, bool>
250 emplace(_Args&&... __args)
251 {
252 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
784779d4 253 return { { __res.first, this }, __res.second };
55826ab6
FD
254 }
255
256 template<typename... _Args>
257 iterator
258 emplace_hint(const_iterator __pos, _Args&&... __args)
259 {
260 __glibcxx_check_insert(__pos);
784779d4
FD
261 return
262 {
263 _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...),
264 this
265 };
55826ab6
FD
266 }
267#endif
268
526da49c 269 std::pair<iterator, bool>
285b36d6
BK
270 insert(const value_type& __x)
271 {
285b36d6
BK
272 std::pair<_Base_iterator, bool> __res = _Base::insert(__x);
273 return std::pair<iterator, bool>(iterator(__res.first, this),
274 __res.second);
275 }
526da49c 276
734f5023 277#if __cplusplus >= 201103L
e6a05448
PC
278 std::pair<iterator, bool>
279 insert(value_type&& __x)
280 {
784779d4
FD
281 auto __res = _Base::insert(std::move(__x));
282 return { { __res.first, this }, __res.second };
e6a05448
PC
283 }
284#endif
285
526da49c 286 iterator
6b6d5d09 287 insert(const_iterator __position, const value_type& __x)
285b36d6
BK
288 {
289 __glibcxx_check_insert(__position);
290 return iterator(_Base::insert(__position.base(), __x), this);
291 }
526da49c 292
734f5023 293#if __cplusplus >= 201103L
e6a05448
PC
294 iterator
295 insert(const_iterator __position, value_type&& __x)
296 {
297 __glibcxx_check_insert(__position);
784779d4 298 return { _Base::insert(__position.base(), std::move(__x)), this };
e6a05448
PC
299 }
300#endif
301
285b36d6 302 template <typename _InputIterator>
15ee1a77
FD
303 void
304 insert(_InputIterator __first, _InputIterator __last)
305 {
24167c42
FD
306 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
307 __glibcxx_check_valid_range2(__first, __last, __dist);
308
309 if (__dist.second >= __gnu_debug::__dp_sign)
310 _Base::insert(__gnu_debug::__unsafe(__first),
311 __gnu_debug::__unsafe(__last));
312 else
313 _Base::insert(__first, __last);
285b36d6 314 }
526da49c 315
734f5023 316#if __cplusplus >= 201103L
988499f4
JM
317 void
318 insert(initializer_list<value_type> __l)
319 { _Base::insert(__l); }
320#endif
321
2dbe56bd
JW
322#if __cplusplus > 201402L
323 using node_type = typename _Base::node_type;
adaefe2a 324 using insert_return_type = _Node_insert_return<iterator, node_type>;
2dbe56bd
JW
325
326 node_type
327 extract(const_iterator __position)
328 {
329 __glibcxx_check_erase(__position);
330 this->_M_invalidate_if(_Equal(__position.base()));
331 return _Base::extract(__position.base());
332 }
333
334 node_type
335 extract(const key_type& __key)
336 {
337 const auto __position = find(__key);
338 if (__position != end())
339 return extract(__position);
340 return {};
341 }
342
343 insert_return_type
344 insert(node_type&& __nh)
345 {
346 auto __ret = _Base::insert(std::move(__nh));
347 iterator __pos = iterator(__ret.position, this);
adaefe2a 348 return { __pos, __ret.inserted, std::move(__ret.node) };
2dbe56bd
JW
349 }
350
351 iterator
352 insert(const_iterator __hint, node_type&& __nh)
353 {
354 __glibcxx_check_insert(__hint);
784779d4 355 return { _Base::insert(__hint.base(), std::move(__nh)), this };
2dbe56bd
JW
356 }
357
358 using _Base::merge;
359#endif // C++17
360
734f5023 361#if __cplusplus >= 201103L
7b1e8acf 362 _GLIBCXX_ABI_TAG_CXX11
5ab06c6d 363 iterator
6b6d5d09 364 erase(const_iterator __position)
5ab06c6d
PC
365 {
366 __glibcxx_check_erase(__position);
5f40d34b
FD
367 return { erase(__position.base()), this };
368 }
369
370 _Base_iterator
371 erase(_Base_const_iterator __position)
372 {
373 __glibcxx_check_erase2(__position);
374 this->_M_invalidate_if(_Equal(__position));
375 return _Base::erase(__position);
5ab06c6d
PC
376 }
377#else
526da49c 378 void
285b36d6
BK
379 erase(iterator __position)
380 {
381 __glibcxx_check_erase(__position);
afe96d41 382 this->_M_invalidate_if(_Equal(__position.base()));
285b36d6
BK
383 _Base::erase(__position.base());
384 }
5ab06c6d 385#endif
526da49c
BI
386
387 size_type
285b36d6
BK
388 erase(const key_type& __x)
389 {
afe96d41
FD
390 _Base_iterator __victim = _Base::find(__x);
391 if (__victim == _Base::end())
15ee1a77 392 return 0;
285b36d6 393 else
afe96d41
FD
394 {
395 this->_M_invalidate_if(_Equal(__victim));
396 _Base::erase(__victim);
397 return 1;
398 }
285b36d6 399 }
526da49c 400
734f5023 401#if __cplusplus >= 201103L
7b1e8acf 402 _GLIBCXX_ABI_TAG_CXX11
5ab06c6d 403 iterator
6b6d5d09 404 erase(const_iterator __first, const_iterator __last)
5ab06c6d
PC
405 {
406 // _GLIBCXX_RESOLVE_LIB_DEFECTS
407 // 151. can't currently clear() empty container
408 __glibcxx_check_erase_range(__first, __last);
afe96d41
FD
409 for (_Base_const_iterator __victim = __first.base();
410 __victim != __last.base(); ++__victim)
411 {
e0b9bc23 412 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
afe96d41
FD
413 _M_message(__gnu_debug::__msg_valid_range)
414 ._M_iterator(__first, "first")
415 ._M_iterator(__last, "last"));
416 this->_M_invalidate_if(_Equal(__victim));
417 }
784779d4
FD
418
419 return { _Base::erase(__first.base(), __last.base()), this };
5ab06c6d
PC
420 }
421#else
526da49c 422 void
285b36d6
BK
423 erase(iterator __first, iterator __last)
424 {
425 // _GLIBCXX_RESOLVE_LIB_DEFECTS
426 // 151. can't currently clear() empty container
427 __glibcxx_check_erase_range(__first, __last);
afe96d41
FD
428 for (_Base_iterator __victim = __first.base();
429 __victim != __last.base(); ++__victim)
430 {
431 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
432 _M_message(__gnu_debug::__msg_valid_range)
433 ._M_iterator(__first, "first")
434 ._M_iterator(__last, "last"));
435 this->_M_invalidate_if(_Equal(__victim));
436 }
437 _Base::erase(__first.base(), __last.base());
285b36d6 438 }
5ab06c6d 439#endif
526da49c
BI
440
441 void
ed540c0a 442 swap(set& __x)
c5d9ec56 443 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
285b36d6 444 {
15ee1a77 445 _Safe::_M_swap(__x);
285b36d6 446 _Base::swap(__x);
285b36d6 447 }
526da49c
BI
448
449 void
d3677132 450 clear() _GLIBCXX_NOEXCEPT
afe96d41
FD
451 {
452 this->_M_invalidate_all();
453 _Base::clear();
454 }
526da49c 455
285b36d6
BK
456 // observers:
457 using _Base::key_comp;
458 using _Base::value_comp;
526da49c 459
285b36d6 460 // set operations:
526da49c 461 iterator
285b36d6
BK
462 find(const key_type& __x)
463 { return iterator(_Base::find(__x), this); }
526da49c 464
285b36d6
BK
465 // _GLIBCXX_RESOLVE_LIB_DEFECTS
466 // 214. set::find() missing const overload
526da49c 467 const_iterator
285b36d6
BK
468 find(const key_type& __x) const
469 { return const_iterator(_Base::find(__x), this); }
526da49c 470
d7b35f22
FD
471#if __cplusplus > 201103L
472 template<typename _Kt,
473 typename _Req =
474 typename __has_is_transparent<_Compare, _Kt>::type>
475 iterator
476 find(const _Kt& __x)
477 { return { _Base::find(__x), this }; }
478
479 template<typename _Kt,
480 typename _Req =
481 typename __has_is_transparent<_Compare, _Kt>::type>
482 const_iterator
483 find(const _Kt& __x) const
484 { return { _Base::find(__x), this }; }
485#endif
486
285b36d6 487 using _Base::count;
526da49c
BI
488
489 iterator
285b36d6
BK
490 lower_bound(const key_type& __x)
491 { return iterator(_Base::lower_bound(__x), this); }
526da49c 492
285b36d6
BK
493 // _GLIBCXX_RESOLVE_LIB_DEFECTS
494 // 214. set::find() missing const overload
526da49c 495 const_iterator
285b36d6
BK
496 lower_bound(const key_type& __x) const
497 { return const_iterator(_Base::lower_bound(__x), this); }
526da49c 498
d7b35f22
FD
499#if __cplusplus > 201103L
500 template<typename _Kt,
501 typename _Req =
502 typename __has_is_transparent<_Compare, _Kt>::type>
503 iterator
504 lower_bound(const _Kt& __x)
505 { return { _Base::lower_bound(__x), this }; }
506
507 template<typename _Kt,
508 typename _Req =
509 typename __has_is_transparent<_Compare, _Kt>::type>
510 const_iterator
511 lower_bound(const _Kt& __x) const
512 { return { _Base::lower_bound(__x), this }; }
513#endif
514
526da49c 515 iterator
285b36d6
BK
516 upper_bound(const key_type& __x)
517 { return iterator(_Base::upper_bound(__x), this); }
526da49c 518
285b36d6
BK
519 // _GLIBCXX_RESOLVE_LIB_DEFECTS
520 // 214. set::find() missing const overload
526da49c 521 const_iterator
285b36d6
BK
522 upper_bound(const key_type& __x) const
523 { return const_iterator(_Base::upper_bound(__x), this); }
526da49c 524
d7b35f22
FD
525#if __cplusplus > 201103L
526 template<typename _Kt,
527 typename _Req =
528 typename __has_is_transparent<_Compare, _Kt>::type>
529 iterator
530 upper_bound(const _Kt& __x)
531 { return { _Base::upper_bound(__x), this }; }
532
533 template<typename _Kt,
534 typename _Req =
535 typename __has_is_transparent<_Compare, _Kt>::type>
536 const_iterator
537 upper_bound(const _Kt& __x) const
538 { return { _Base::upper_bound(__x), this }; }
539#endif
540
541 std::pair<iterator, iterator>
285b36d6
BK
542 equal_range(const key_type& __x)
543 {
285b36d6 544 std::pair<_Base_iterator, _Base_iterator> __res =
15ee1a77 545 _Base::equal_range(__x);
285b36d6
BK
546 return std::make_pair(iterator(__res.first, this),
547 iterator(__res.second, this));
548 }
526da49c 549
285b36d6
BK
550 // _GLIBCXX_RESOLVE_LIB_DEFECTS
551 // 214. set::find() missing const overload
d7b35f22 552 std::pair<const_iterator, const_iterator>
285b36d6
BK
553 equal_range(const key_type& __x) const
554 {
d7b35f22 555 std::pair<_Base_const_iterator, _Base_const_iterator> __res =
15ee1a77 556 _Base::equal_range(__x);
285b36d6
BK
557 return std::make_pair(const_iterator(__res.first, this),
558 const_iterator(__res.second, this));
559 }
526da49c 560
d7b35f22
FD
561#if __cplusplus > 201103L
562 template<typename _Kt,
563 typename _Req =
564 typename __has_is_transparent<_Compare, _Kt>::type>
565 std::pair<iterator, iterator>
566 equal_range(const _Kt& __x)
567 {
568 auto __res = _Base::equal_range(__x);
569 return { { __res.first, this }, { __res.second, this } };
570 }
571
572 template<typename _Kt,
573 typename _Req =
574 typename __has_is_transparent<_Compare, _Kt>::type>
575 std::pair<const_iterator, const_iterator>
576 equal_range(const _Kt& __x) const
577 {
578 auto __res = _Base::equal_range(__x);
579 return { { __res.first, this }, { __res.second, this } };
580 }
581#endif
582
526da49c 583 _Base&
15ee1a77 584 _M_base() _GLIBCXX_NOEXCEPT { return *this; }
285b36d6 585
526da49c 586 const _Base&
15ee1a77 587 _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
285b36d6 588 };
526da49c 589
957f5fea
VV
590#if __cpp_deduction_guides >= 201606
591
592 template<typename _InputIterator,
593 typename _Compare =
594 less<typename iterator_traits<_InputIterator>::value_type>,
595 typename _Allocator =
596 allocator<typename iterator_traits<_InputIterator>::value_type>,
597 typename = _RequireInputIter<_InputIterator>,
c0cb38c2 598 typename = _RequireNotAllocator<_Compare>,
957f5fea
VV
599 typename = _RequireAllocator<_Allocator>>
600 set(_InputIterator, _InputIterator,
c0cb38c2
FD
601 _Compare = _Compare(), _Allocator = _Allocator())
602 -> set<typename iterator_traits<_InputIterator>::value_type,
603 _Compare, _Allocator>;
604
605 template<typename _Key, typename _Compare = less<_Key>,
606 typename _Allocator = allocator<_Key>,
607 typename = _RequireNotAllocator<_Compare>,
608 typename = _RequireAllocator<_Allocator>>
609 set(initializer_list<_Key>,
610 _Compare = _Compare(), _Allocator = _Allocator())
611 -> set<_Key, _Compare, _Allocator>;
612
613 template<typename _InputIterator, typename _Allocator,
614 typename = _RequireInputIter<_InputIterator>,
615 typename = _RequireAllocator<_Allocator>>
616 set(_InputIterator, _InputIterator, _Allocator)
617 -> set<typename iterator_traits<_InputIterator>::value_type,
618 less<typename iterator_traits<_InputIterator>::value_type>,
619 _Allocator>;
620
621 template<typename _Key, typename _Allocator,
622 typename = _RequireAllocator<_Allocator>>
623 set(initializer_list<_Key>, _Allocator)
624 -> set<_Key, less<_Key>, _Allocator>;
957f5fea 625
ae54d8cb 626#if __glibcxx_containers_ranges // C++ >= 23
f3253bd7
JW
627 template<ranges::input_range _Rg,
628 __not_allocator_like _Compare = less<ranges::range_value_t<_Rg>>,
629 __allocator_like _Alloc = std::allocator<ranges::range_value_t<_Rg>>>
630 set(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
631 -> set<ranges::range_value_t<_Rg>, _Compare, _Alloc>;
632
633 template<ranges::input_range _Rg, __allocator_like _Alloc>
634 set(from_range_t, _Rg&&, _Alloc)
635 -> set<ranges::range_value_t<_Rg>, less<ranges::range_value_t<_Rg>>, _Alloc>;
636#endif
93843da6 637#endif // deduction guides
957f5fea 638
285b36d6 639 template<typename _Key, typename _Compare, typename _Allocator>
526da49c 640 inline bool
ed540c0a
CJ
641 operator==(const set<_Key, _Compare, _Allocator>& __lhs,
642 const set<_Key, _Compare, _Allocator>& __rhs)
285b36d6
BK
643 { return __lhs._M_base() == __rhs._M_base(); }
644
93843da6
JW
645#if __cpp_lib_three_way_comparison
646 template<typename _Key, typename _Compare, typename _Alloc>
647 inline __detail::__synth3way_t<_Key>
648 operator<=>(const set<_Key, _Compare, _Alloc>& __lhs,
649 const set<_Key, _Compare, _Alloc>& __rhs)
650 { return __lhs._M_base() <=> __rhs._M_base(); }
651#else
285b36d6 652 template<typename _Key, typename _Compare, typename _Allocator>
526da49c 653 inline bool
ed540c0a
CJ
654 operator!=(const set<_Key, _Compare, _Allocator>& __lhs,
655 const set<_Key, _Compare, _Allocator>& __rhs)
285b36d6
BK
656 { return __lhs._M_base() != __rhs._M_base(); }
657
658 template<typename _Key, typename _Compare, typename _Allocator>
526da49c 659 inline bool
ed540c0a
CJ
660 operator<(const set<_Key, _Compare, _Allocator>& __lhs,
661 const set<_Key, _Compare, _Allocator>& __rhs)
285b36d6
BK
662 { return __lhs._M_base() < __rhs._M_base(); }
663
664 template<typename _Key, typename _Compare, typename _Allocator>
526da49c 665 inline bool
ed540c0a
CJ
666 operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
667 const set<_Key, _Compare, _Allocator>& __rhs)
285b36d6
BK
668 { return __lhs._M_base() <= __rhs._M_base(); }
669
670 template<typename _Key, typename _Compare, typename _Allocator>
526da49c 671 inline bool
ed540c0a
CJ
672 operator>=(const set<_Key, _Compare, _Allocator>& __lhs,
673 const set<_Key, _Compare, _Allocator>& __rhs)
285b36d6
BK
674 { return __lhs._M_base() >= __rhs._M_base(); }
675
676 template<typename _Key, typename _Compare, typename _Allocator>
526da49c 677 inline bool
ed540c0a
CJ
678 operator>(const set<_Key, _Compare, _Allocator>& __lhs,
679 const set<_Key, _Compare, _Allocator>& __rhs)
285b36d6 680 { return __lhs._M_base() > __rhs._M_base(); }
93843da6 681#endif // three-way comparison
285b36d6
BK
682
683 template<typename _Key, typename _Compare, typename _Allocator>
684 void
ed540c0a
CJ
685 swap(set<_Key, _Compare, _Allocator>& __x,
686 set<_Key, _Compare, _Allocator>& __y)
c5d9ec56 687 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
285b36d6 688 { return __x.swap(__y); }
ed540c0a 689
45f388bb 690} // namespace __debug
3cbc7af0 691} // namespace std
285b36d6
BK
692
693#endif