29#ifndef _GLIBCXX_DEBUG_SET_H
30#define _GLIBCXX_DEBUG_SET_H 1
37namespace std _GLIBCXX_VISIBILITY(default)
42 template<
typename _Key,
typename _Compare = std::less<_Key>,
43 typename _Allocator = std::allocator<_Key> >
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;
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;
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)
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)),
137 explicit set(
const _Compare& __comp,
138 const _Allocator& __a = _Allocator())
139 :
_Base(__comp, __a) { }
141 template<
typename _InputIterator>
142 set(_InputIterator __first, _InputIterator __last,
143 const _Compare& __comp = _Compare(),
144 const _Allocator& __a = _Allocator())
146 __glibcxx_check_valid_constructor_range(__first, __last)),
151 :
_Base(__x._M_ref) { }
153#if __cplusplus >= 201103L
155 operator=(
const set&) =
default;
158 operator=(
set&&) =
default;
163 _Base::operator=(__l);
164 this->_M_invalidate_all();
169 using _Base::get_allocator;
173 begin() _GLIBCXX_NOEXCEPT
174 {
return iterator(_Base::begin(),
this); }
177 begin()
const _GLIBCXX_NOEXCEPT
181 end() _GLIBCXX_NOEXCEPT
182 {
return iterator(_Base::end(),
this); }
185 end()
const _GLIBCXX_NOEXCEPT
189 rbegin() _GLIBCXX_NOEXCEPT
193 rbegin()
const _GLIBCXX_NOEXCEPT
197 rend() _GLIBCXX_NOEXCEPT
201 rend()
const _GLIBCXX_NOEXCEPT
204#if __cplusplus >= 201103L
206 cbegin()
const noexcept
210 cend()
const noexcept
214 crbegin()
const noexcept
218 crend()
const noexcept
225 using _Base::max_size;
228#if __cplusplus >= 201103L
229 template<
typename... _Args>
231 emplace(_Args&&... __args)
233 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
234 return { { __res.first,
this }, __res.second };
237 template<
typename... _Args>
244 _Base::emplace_hint(__pos.
base(), std::forward<_Args>(__args)...),
251 insert(
const value_type& __x)
258#if __cplusplus >= 201103L
260 insert(value_type&& __x)
262 auto __res = _Base::insert(
std::move(__x));
263 return { { __res.first,
this }, __res.second };
271 return iterator(_Base::insert(__position.
base(), __x),
this);
274#if __cplusplus >= 201103L
279 return { _Base::insert(__position.
base(),
std::move(__x)),
this };
283 template <
typename _InputIterator>
285 insert(_InputIterator __first, _InputIterator __last)
288 __glibcxx_check_valid_range2(__first, __last, __dist);
290 if (__dist.
second >= __gnu_debug::__dp_sign)
291 _Base::insert(__gnu_debug::__unsafe(__first),
292 __gnu_debug::__unsafe(__last));
294 _Base::insert(__first, __last);
297#if __cplusplus >= 201103L
300 { _Base::insert(__l); }
303#if __cplusplus > 201402L
304 using node_type =
typename _Base::node_type;
311 this->_M_invalidate_if(
_Equal(__position.
base()));
312 return _Base::extract(__position.
base());
316 extract(
const key_type& __key)
318 const auto __position = find(__key);
319 if (__position != end())
320 return extract(__position);
325 insert(node_type&& __nh)
327 auto __ret = _Base::insert(
std::move(__nh));
329 return { __pos, __ret.inserted,
std::move(__ret.node) };
336 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
342#if __cplusplus >= 201103L
343 _GLIBCXX_ABI_TAG_CXX11
348 return { erase(__position.
base()),
this };
354 __glibcxx_check_erase2(__position);
355 this->_M_invalidate_if(
_Equal(__position));
356 return _Base::erase(__position);
363 this->_M_invalidate_if(
_Equal(__position.
base()));
364 _Base::erase(__position.
base());
369 erase(
const key_type& __x)
372 if (__victim == _Base::end())
376 this->_M_invalidate_if(
_Equal(__victim));
377 _Base::erase(__victim);
382#if __cplusplus >= 201103L
383 _GLIBCXX_ABI_TAG_CXX11
391 __victim != __last.
base(); ++__victim)
393 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
394 _M_message(__gnu_debug::__msg_valid_range)
395 ._M_iterator(__first,
"first")
396 ._M_iterator(__last,
"last"));
397 this->_M_invalidate_if(
_Equal(__victim));
400 return { _Base::erase(__first.base(), __last.
base()),
this };
410 __victim != __last.
base(); ++__victim)
412 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
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));
418 _Base::erase(__first.base(), __last.
base());
424 _GLIBCXX_NOEXCEPT_IF(
noexcept(declval<_Base&>().swap(__x)) )
431 clear() _GLIBCXX_NOEXCEPT
433 this->_M_invalidate_all();
438 using _Base::key_comp;
439 using _Base::value_comp;
443 find(
const key_type& __x)
444 {
return iterator(_Base::find(__x),
this); }
449 find(
const key_type& __x)
const
452#if __cplusplus > 201103L
453 template<
typename _Kt,
455 typename __has_is_transparent<_Compare, _Kt>::type>
458 {
return { _Base::find(__x),
this }; }
460 template<
typename _Kt,
462 typename __has_is_transparent<_Compare, _Kt>::type>
464 find(
const _Kt& __x)
const
465 {
return { _Base::find(__x),
this }; }
471 lower_bound(
const key_type& __x)
472 {
return iterator(_Base::lower_bound(__x),
this); }
477 lower_bound(
const key_type& __x)
const
480#if __cplusplus > 201103L
481 template<
typename _Kt,
483 typename __has_is_transparent<_Compare, _Kt>::type>
485 lower_bound(
const _Kt& __x)
486 {
return { _Base::lower_bound(__x),
this }; }
488 template<
typename _Kt,
490 typename __has_is_transparent<_Compare, _Kt>::type>
492 lower_bound(
const _Kt& __x)
const
493 {
return { _Base::lower_bound(__x),
this }; }
497 upper_bound(
const key_type& __x)
498 {
return iterator(_Base::upper_bound(__x),
this); }
503 upper_bound(
const key_type& __x)
const
506#if __cplusplus > 201103L
507 template<
typename _Kt,
509 typename __has_is_transparent<_Compare, _Kt>::type>
511 upper_bound(
const _Kt& __x)
512 {
return { _Base::upper_bound(__x),
this }; }
514 template<
typename _Kt,
516 typename __has_is_transparent<_Compare, _Kt>::type>
518 upper_bound(
const _Kt& __x)
const
519 {
return { _Base::upper_bound(__x),
this }; }
523 equal_range(
const key_type& __x)
526 _Base::equal_range(__x);
534 equal_range(
const key_type& __x)
const
537 _Base::equal_range(__x);
542#if __cplusplus > 201103L
543 template<
typename _Kt,
545 typename __has_is_transparent<_Compare, _Kt>::type>
547 equal_range(
const _Kt& __x)
549 auto __res = _Base::equal_range(__x);
550 return { { __res.first,
this }, { __res.second,
this } };
553 template<
typename _Kt,
555 typename __has_is_transparent<_Compare, _Kt>::type>
557 equal_range(
const _Kt& __x)
const
559 auto __res = _Base::equal_range(__x);
560 return { { __res.first,
this }, { __res.second,
this } };
565 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
568 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
571#if __cpp_deduction_guides >= 201606
573 template<
typename _InputIterator,
576 typename _Allocator =
578 typename = _RequireInputIter<_InputIterator>,
579 typename = _RequireNotAllocator<_Compare>,
580 typename = _RequireAllocator<_Allocator>>
581 set(_InputIterator, _InputIterator,
582 _Compare = _Compare(), _Allocator = _Allocator())
584 _Compare, _Allocator>;
586 template<
typename _Key,
typename _Compare = less<_Key>,
587 typename _Allocator = allocator<_Key>,
588 typename = _RequireNotAllocator<_Compare>,
589 typename = _RequireAllocator<_Allocator>>
591 _Compare = _Compare(), _Allocator = _Allocator())
594 template<
typename _InputIterator,
typename _Allocator,
595 typename = _RequireInputIter<_InputIterator>,
596 typename = _RequireAllocator<_Allocator>>
597 set(_InputIterator, _InputIterator, _Allocator)
602 template<
typename _Key,
typename _Allocator,
603 typename = _RequireAllocator<_Allocator>>
609 template<
typename _Key,
typename _Compare,
typename _Allocator>
613 {
return __lhs._M_base() == __rhs._M_base(); }
615#if __cpp_lib_three_way_comparison
616 template<
typename _Key,
typename _Compare,
typename _Alloc>
617 inline __detail::__synth3way_t<_Key>
620 {
return __lhs._M_base() <=> __rhs._M_base(); }
622 template<
typename _Key,
typename _Compare,
typename _Allocator>
624 operator!=(
const set<_Key, _Compare, _Allocator>& __lhs,
625 const set<_Key, _Compare, _Allocator>& __rhs)
626 {
return __lhs._M_base() != __rhs._M_base(); }
628 template<
typename _Key,
typename _Compare,
typename _Allocator>
630 operator<(
const set<_Key, _Compare, _Allocator>& __lhs,
631 const set<_Key, _Compare, _Allocator>& __rhs)
632 {
return __lhs._M_base() < __rhs._M_base(); }
634 template<
typename _Key,
typename _Compare,
typename _Allocator>
636 operator<=(
const set<_Key, _Compare, _Allocator>& __lhs,
637 const set<_Key, _Compare, _Allocator>& __rhs)
638 {
return __lhs._M_base() <= __rhs._M_base(); }
640 template<
typename _Key,
typename _Compare,
typename _Allocator>
642 operator>=(
const set<_Key, _Compare, _Allocator>& __lhs,
643 const set<_Key, _Compare, _Allocator>& __rhs)
644 {
return __lhs._M_base() >= __rhs._M_base(); }
646 template<
typename _Key,
typename _Compare,
typename _Allocator>
648 operator>(
const set<_Key, _Compare, _Allocator>& __lhs,
649 const set<_Key, _Compare, _Allocator>& __rhs)
650 {
return __lhs._M_base() > __rhs._M_base(); }
653 template<
typename _Key,
typename _Compare,
typename _Allocator>
655 swap(set<_Key, _Compare, _Allocator>& __x,
656 set<_Key, _Compare, _Allocator>& __y)
657 _GLIBCXX_NOEXCEPT_IF(
noexcept(__x.swap(__y)))
658 {
return __x.swap(__y); }
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_erase(_Position)
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
ISO C++ entities toplevel namespace is std.
constexpr _Iterator __base(_Iterator __it)
The standard allocator, as per C++03 [20.4.1].
_Iterator & base() noexcept
Return the underlying iterator.
Return type of insert(node_handle&&) on unique maps/sets.
One of the comparison functors.
Struct holding two objects of arbitrary type.
_T1 first
The first member.
_T2 second
The second member.
A standard container made up of unique keys, which can be retrieved in logarithmic time.
Safe class dealing with some allocator dependent operations.
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
Class std::set with safety/checking/debug instrumentation.