46 set<_Key, _Compare, _Allocator>, _Allocator,
47 __gnu_debug::_Safe_node_sequence>,
48 public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>
50 typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base;
54 typedef typename _Base::const_iterator _Base_const_iterator;
55 typedef typename _Base::iterator _Base_iterator;
58 template<
typename _ItT,
typename _SeqT,
typename _CatT>
59 friend class ::__gnu_debug::_Safe_iterator;
66 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
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;
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;
95#if __cplusplus < 201103L
104 set(
const set&) =
default;
105 set(set&&) =
default;
108 const _Compare& __comp = _Compare(),
109 const allocator_type& __a = allocator_type())
110 : _Base(__l, __comp, __a) { }
113 set(
const allocator_type& __a)
116 set(
const set& __x,
const __type_identity_t<allocator_type>& __a)
117 : _Base(__x, __a) { }
119 set(set&& __x,
const __type_identity_t<allocator_type>& __a)
120 noexcept(
noexcept(_Base(
std::move(__x), __a)) )
125 : _Base(__l, __a) { }
127 template<
typename _InputIterator>
128 set(_InputIterator __first, _InputIterator __last,
129 const allocator_type& __a)
131 __glibcxx_check_valid_constructor_range(__first, __last)),
134#if __glibcxx_containers_ranges
139 template<std::__detail::__container_compatible_range<_Key> _Rg>
140 set(std::from_range_t __t, _Rg&& __rg,
142 const allocator_type& __a = allocator_type())
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())
156 explicit set(
const _Compare& __comp,
157 const _Allocator& __a = _Allocator())
158 : _Base(__comp, __a) { }
160 template<
typename _InputIterator>
161 set(_InputIterator __first, _InputIterator __last,
162 const _Compare& __comp = _Compare(),
163 const _Allocator& __a = _Allocator())
165 __glibcxx_check_valid_constructor_range(__first, __last)),
170 : _Base(__x._M_ref) { }
172#if __cplusplus >= 201103L
174 operator=(
const set&) =
default;
177 operator=(set&&) =
default;
182 _Base::operator=(__l);
183 this->_M_invalidate_all();
188 using _Base::get_allocator;
192 begin() _GLIBCXX_NOEXCEPT
193 {
return iterator(_Base::begin(),
this); }
196 begin()
const _GLIBCXX_NOEXCEPT
197 {
return const_iterator(_Base::begin(),
this); }
200 end() _GLIBCXX_NOEXCEPT
201 {
return iterator(_Base::end(),
this); }
204 end()
const _GLIBCXX_NOEXCEPT
205 {
return const_iterator(_Base::end(),
this); }
208 rbegin() _GLIBCXX_NOEXCEPT
209 {
return reverse_iterator(end()); }
211 const_reverse_iterator
212 rbegin()
const _GLIBCXX_NOEXCEPT
213 {
return const_reverse_iterator(end()); }
216 rend() _GLIBCXX_NOEXCEPT
217 {
return reverse_iterator(begin()); }
219 const_reverse_iterator
220 rend()
const _GLIBCXX_NOEXCEPT
221 {
return const_reverse_iterator(begin()); }
223#if __cplusplus >= 201103L
225 cbegin()
const noexcept
226 {
return const_iterator(_Base::begin(),
this); }
229 cend()
const noexcept
230 {
return const_iterator(_Base::end(),
this); }
232 const_reverse_iterator
233 crbegin()
const noexcept
234 {
return const_reverse_iterator(end()); }
236 const_reverse_iterator
237 crend()
const noexcept
238 {
return const_reverse_iterator(begin()); }
244 using _Base::max_size;
247#if __cplusplus >= 201103L
248 template<
typename... _Args>
250 emplace(_Args&&... __args)
253 return { { __res.first,
this }, __res.second };
256 template<
typename... _Args>
258 emplace_hint(const_iterator __pos, _Args&&... __args)
270 insert(
const value_type& __x)
277#if __cplusplus >= 201103L
279 insert(value_type&& __x)
281 auto __res = _Base::insert(
std::move(__x));
282 return { { __res.first,
this }, __res.second };
287 insert(const_iterator __position,
const value_type& __x)
290 return iterator(_Base::insert(__position.
base(), __x),
this);
293#if __cplusplus >= 201103L
295 insert(const_iterator __position, value_type&& __x)
298 return { _Base::insert(__position.
base(),
std::move(__x)),
this };
302 template <
typename _InputIterator>
304 insert(_InputIterator __first, _InputIterator __last)
306 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
307 __glibcxx_check_valid_range2(__first, __last, __dist);
309 if (__dist.second >= __gnu_debug::__dp_sign)
310 _Base::insert(__gnu_debug::__unsafe(__first),
311 __gnu_debug::__unsafe(__last));
313 _Base::insert(__first, __last);
316#if __cplusplus >= 201103L
319 { _Base::insert(__l); }
322#ifdef __glibcxx_node_extract
323 using node_type =
typename _Base::node_type;
324 using insert_return_type = _Node_insert_return<iterator, node_type>;
327 extract(const_iterator __position)
330 this->_M_invalidate_if(_Equal(__position.
base()));
331 return _Base::extract(__position.
base());
335 extract(
const key_type& __key)
337 const auto __position = find(__key);
338 if (__position != end())
339 return extract(__position);
343# ifdef __glibcxx_associative_heterogeneous_erasure
344 template <__heterogeneous_tree_key<set> _Kt>
348 const auto __position = find(__key);
349 if (__position != end())
350 return extract(__position);
356 insert(node_type&& __nh)
358 auto __ret = _Base::insert(
std::move(__nh));
359 iterator __pos = iterator(__ret.position,
this);
360 return { __pos, __ret.inserted,
std::move(__ret.node) };
364 insert(const_iterator __hint, node_type&& __nh)
367 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
373#if __cplusplus >= 201103L
374 _GLIBCXX_ABI_TAG_CXX11
376 erase(const_iterator __position)
379 return { erase(__position.
base()),
this };
383 erase(_Base_const_iterator __position)
385 __glibcxx_check_erase2(__position);
386 this->_M_invalidate_if(_Equal(__position));
387 return _Base::erase(__position);
391 erase(iterator __position)
394 this->_M_invalidate_if(_Equal(__position.
base()));
395 _Base::erase(__position.
base());
400 erase(
const key_type& __x)
402 _Base_iterator __victim = _Base::find(__x);
403 if (__victim == _Base::end())
407 this->_M_invalidate_if(_Equal(__victim));
408 _Base::erase(__victim);
413# ifdef __glibcxx_associative_heterogeneous_erasure
417 template <__heterogeneous_tree_key<set> _Kt>
421 auto __victims = _Base::equal_range(__x);
422 size_type __count = 0;
423 for (
auto __victim = __victims.first; __victim != __victims.second;)
425 this->_M_invalidate_if(_Equal(__victim));
426 _Base::erase(__victim++);
433#if __cplusplus >= 201103L
434 _GLIBCXX_ABI_TAG_CXX11
436 erase(const_iterator __first, const_iterator __last)
441 for (_Base_const_iterator __victim = __first.base();
442 __victim != __last.base(); ++__victim)
444 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
445 _M_message(__gnu_debug::__msg_valid_range)
446 ._M_iterator(__first,
"first")
447 ._M_iterator(__last,
"last"));
448 this->_M_invalidate_if(_Equal(__victim));
451 return { _Base::erase(__first.base(), __last.base()),
this };
455 erase(iterator __first, iterator __last)
460 for (_Base_iterator __victim = __first.base();
461 __victim != __last.base(); ++__victim)
463 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
464 _M_message(__gnu_debug::__msg_valid_range)
465 ._M_iterator(__first,
"first")
466 ._M_iterator(__last,
"last"));
467 this->_M_invalidate_if(_Equal(__victim));
469 _Base::erase(__first.base(), __last.base());
482 clear() _GLIBCXX_NOEXCEPT
484 this->_M_invalidate_all();
489 using _Base::key_comp;
490 using _Base::value_comp;
494 find(
const key_type& __x)
495 {
return iterator(_Base::find(__x),
this); }
500 find(
const key_type& __x)
const
501 {
return const_iterator(_Base::find(__x),
this); }
503#ifdef __glibcxx_generic_associative_lookup
504 template<
typename _Kt,
506 typename __has_is_transparent<_Compare, _Kt>::type>
509 {
return { _Base::find(__x),
this }; }
511 template<
typename _Kt,
513 typename __has_is_transparent<_Compare, _Kt>::type>
515 find(
const _Kt& __x)
const
516 {
return { _Base::find(__x),
this }; }
522 lower_bound(
const key_type& __x)
523 {
return iterator(_Base::lower_bound(__x),
this); }
528 lower_bound(
const key_type& __x)
const
529 {
return const_iterator(_Base::lower_bound(__x),
this); }
531#ifdef __glibcxx_generic_associative_lookup
532 template<
typename _Kt,
534 typename __has_is_transparent<_Compare, _Kt>::type>
536 lower_bound(
const _Kt& __x)
537 {
return { _Base::lower_bound(__x),
this }; }
539 template<
typename _Kt,
541 typename __has_is_transparent<_Compare, _Kt>::type>
543 lower_bound(
const _Kt& __x)
const
544 {
return { _Base::lower_bound(__x),
this }; }
548 upper_bound(
const key_type& __x)
549 {
return iterator(_Base::upper_bound(__x),
this); }
554 upper_bound(
const key_type& __x)
const
555 {
return const_iterator(_Base::upper_bound(__x),
this); }
557#ifdef __glibcxx_generic_associative_lookup
558 template<
typename _Kt,
560 typename __has_is_transparent<_Compare, _Kt>::type>
562 upper_bound(
const _Kt& __x)
563 {
return { _Base::upper_bound(__x),
this }; }
565 template<
typename _Kt,
567 typename __has_is_transparent<_Compare, _Kt>::type>
569 upper_bound(
const _Kt& __x)
const
570 {
return { _Base::upper_bound(__x),
this }; }
574 equal_range(
const key_type& __x)
577 _Base::equal_range(__x);
579 iterator(__res.
second,
this));
585 equal_range(
const key_type& __x)
const
588 _Base::equal_range(__x);
590 const_iterator(__res.
second,
this));
593#ifdef __glibcxx_generic_associative_lookup
594 template<
typename _Kt,
596 typename __has_is_transparent<_Compare, _Kt>::type>
598 equal_range(
const _Kt& __x)
600 auto __res = _Base::equal_range(__x);
601 return { { __res.first,
this }, { __res.second,
this } };
604 template<
typename _Kt,
606 typename __has_is_transparent<_Compare, _Kt>::type>
608 equal_range(
const _Kt& __x)
const
610 auto __res = _Base::equal_range(__x);
611 return { { __res.first,
this }, { __res.second,
this } };
616 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
619 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }