29 #ifndef _GLIBCXX_DEBUG_SET_H 30 #define _GLIBCXX_DEBUG_SET_H 1 37 namespace 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;
60 typedef _Key key_type;
61 typedef _Key value_type;
62 typedef _Compare key_compare;
63 typedef _Compare value_compare;
64 typedef _Allocator allocator_type;
65 typedef typename _Base::reference reference;
66 typedef typename _Base::const_reference const_reference;
73 typedef typename _Base::size_type size_type;
74 typedef typename _Base::difference_type difference_type;
75 typedef typename _Base::pointer pointer;
76 typedef typename _Base::const_pointer const_pointer;
82 #if __cplusplus < 201103L 91 set(
const set&) =
default;
95 const _Compare& __comp = _Compare(),
96 const allocator_type& __a = allocator_type())
97 :
_Base(__l, __comp, __a) { }
100 set(
const allocator_type& __a)
103 set(
const set& __x,
const allocator_type& __a)
104 :
_Base(__x, __a) { }
106 set(
set&& __x,
const allocator_type& __a)
107 :
_Safe(std::move(__x._M_safe()), __a),
108 _Base(std::move(__x._M_base()), __a) { }
111 :
_Base(__l, __a) { }
113 template<
typename _InputIterator>
114 set(_InputIterator __first, _InputIterator __last,
115 const allocator_type& __a)
116 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
118 __gnu_debug::__base(__last), __a) { }
123 explicit set(
const _Compare& __comp,
124 const _Allocator& __a = _Allocator())
125 :
_Base(__comp, __a) { }
127 template<
typename _InputIterator>
128 set(_InputIterator __first, _InputIterator __last,
129 const _Compare& __comp = _Compare(),
130 const _Allocator& __a = _Allocator())
131 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
133 __gnu_debug::__base(__last),
136 set(
const _Base& __x)
139 #if __cplusplus < 201103L 141 operator=(
const set& __x)
143 this->_M_safe() = __x;
149 operator=(
const set&) =
default;
152 operator=(
set&&) =
default;
158 this->_M_invalidate_all();
163 using _Base::get_allocator;
167 begin() _GLIBCXX_NOEXCEPT
168 {
return iterator(_Base::begin(),
this); }
171 begin()
const _GLIBCXX_NOEXCEPT
175 end() _GLIBCXX_NOEXCEPT
176 {
return iterator(_Base::end(),
this); }
179 end()
const _GLIBCXX_NOEXCEPT
183 rbegin() _GLIBCXX_NOEXCEPT
187 rbegin()
const _GLIBCXX_NOEXCEPT
191 rend() _GLIBCXX_NOEXCEPT
195 rend()
const _GLIBCXX_NOEXCEPT
198 #if __cplusplus >= 201103L 200 cbegin()
const noexcept
204 cend()
const noexcept
208 crbegin()
const noexcept
212 crend()
const noexcept
219 using _Base::max_size;
222 #if __cplusplus >= 201103L 223 template<
typename... _Args>
225 emplace(_Args&&... __args)
227 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
232 template<
typename... _Args>
238 std::forward<_Args>(__args)...),
244 insert(
const value_type& __x)
251 #if __cplusplus >= 201103L 253 insert(value_type&& __x)
256 = _Base::insert(std::move(__x));
266 return iterator(_Base::insert(__position.
base(), __x),
this);
269 #if __cplusplus >= 201103L 274 return iterator(_Base::insert(__position.
base(), std::move(__x)),
279 template <
typename _InputIterator>
281 insert(_InputIterator __first, _InputIterator __last)
284 __glibcxx_check_valid_range2(__first, __last, __dist);
286 if (__dist.
second >= __gnu_debug::__dp_sign)
287 _Base::insert(__gnu_debug::__unsafe(__first),
288 __gnu_debug::__unsafe(__last));
290 _Base::insert(__first, __last);
293 #if __cplusplus >= 201103L 296 { _Base::insert(__l); }
299 #if __cplusplus > 201402L 300 using node_type =
typename _Base::node_type;
301 using insert_return_type = _Node_insert_return<iterator, node_type>;
308 return _Base::extract(__position.
base());
312 extract(
const key_type& __key)
314 const auto __position = find(__key);
315 if (__position != end())
316 return extract(__position);
321 insert(node_type&& __nh)
323 auto __ret = _Base::insert(std::move(__nh));
325 return { __pos, __ret.inserted, std::move(__ret.node) };
332 return iterator(_Base::insert(__hint.
base(), std::move(__nh)),
this);
338 #if __cplusplus >= 201103L 352 _Base::erase(__position.
base());
357 erase(
const key_type& __x)
360 if (__victim == _Base::end())
365 _Base::erase(__victim);
370 #if __cplusplus >= 201103L 378 __victim != __last.
base(); ++__victim)
380 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
381 _M_message(__gnu_debug::__msg_valid_range)
382 ._M_iterator(__first,
"first")
383 ._M_iterator(__last,
"last"));
396 __victim != __last.
base(); ++__victim)
398 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
399 _M_message(__gnu_debug::__msg_valid_range)
400 ._M_iterator(__first,
"first")
401 ._M_iterator(__last,
"last"));
404 _Base::erase(__first.
base(), __last.
base());
410 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
417 clear() _GLIBCXX_NOEXCEPT
419 this->_M_invalidate_all();
424 using _Base::key_comp;
425 using _Base::value_comp;
429 find(
const key_type& __x)
430 {
return iterator(_Base::find(__x),
this); }
435 find(
const key_type& __x)
const 438 #if __cplusplus > 201103L 439 template<
typename _Kt,
441 typename __has_is_transparent<_Compare, _Kt>::type>
444 {
return { _Base::find(__x),
this }; }
446 template<
typename _Kt,
448 typename __has_is_transparent<_Compare, _Kt>::type>
450 find(
const _Kt& __x)
const 451 {
return { _Base::find(__x),
this }; }
457 lower_bound(
const key_type& __x)
458 {
return iterator(_Base::lower_bound(__x),
this); }
463 lower_bound(
const key_type& __x)
const 466 #if __cplusplus > 201103L 467 template<
typename _Kt,
469 typename __has_is_transparent<_Compare, _Kt>::type>
471 lower_bound(
const _Kt& __x)
472 {
return { _Base::lower_bound(__x),
this }; }
474 template<
typename _Kt,
476 typename __has_is_transparent<_Compare, _Kt>::type>
478 lower_bound(
const _Kt& __x)
const 479 {
return { _Base::lower_bound(__x),
this }; }
483 upper_bound(
const key_type& __x)
484 {
return iterator(_Base::upper_bound(__x),
this); }
489 upper_bound(
const key_type& __x)
const 492 #if __cplusplus > 201103L 493 template<
typename _Kt,
495 typename __has_is_transparent<_Compare, _Kt>::type>
497 upper_bound(
const _Kt& __x)
498 {
return { _Base::upper_bound(__x),
this }; }
500 template<
typename _Kt,
502 typename __has_is_transparent<_Compare, _Kt>::type>
504 upper_bound(
const _Kt& __x)
const 505 {
return { _Base::upper_bound(__x),
this }; }
509 equal_range(
const key_type& __x)
512 _Base::equal_range(__x);
520 equal_range(
const key_type& __x)
const 523 _Base::equal_range(__x);
528 #if __cplusplus > 201103L 529 template<
typename _Kt,
531 typename __has_is_transparent<_Compare, _Kt>::type>
533 equal_range(
const _Kt& __x)
535 auto __res = _Base::equal_range(__x);
536 return { { __res.first,
this }, { __res.second,
this } };
539 template<
typename _Kt,
541 typename __has_is_transparent<_Compare, _Kt>::type>
543 equal_range(
const _Kt& __x)
const 545 auto __res = _Base::equal_range(__x);
546 return { { __res.first,
this }, { __res.second,
this } };
551 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
554 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
557 #if __cpp_deduction_guides >= 201606 559 template<
typename _InputIterator,
562 typename _Allocator =
564 typename = _RequireInputIter<_InputIterator>,
565 typename = _RequireAllocator<_Allocator>>
566 set(_InputIterator, _InputIterator,
567 _Compare = _Compare(), _Allocator = _Allocator())
568 ->
set<
typename iterator_traits<_InputIterator>::value_type,
569 _Compare, _Allocator>;
571 template<
typename _Key,
typename _Compare = less<_Key>,
572 typename _Allocator = allocator<_Key>,
573 typename = _RequireAllocator<_Allocator>>
575 _Compare = _Compare(), _Allocator = _Allocator())
578 template<
typename _InputIterator,
typename _Allocator,
579 typename = _RequireInputIter<_InputIterator>,
580 typename = _RequireAllocator<_Allocator>>
581 set(_InputIterator, _InputIterator, _Allocator)
582 ->
set<
typename iterator_traits<_InputIterator>::value_type,
583 less<
typename iterator_traits<_InputIterator>::value_type>,
586 template<
typename _Key,
typename _Allocator,
587 typename = _RequireAllocator<_Allocator>>
593 template<
typename _Key,
typename _Compare,
typename _Allocator>
597 {
return __lhs._M_base() == __rhs._M_base(); }
599 template<
typename _Key,
typename _Compare,
typename _Allocator>
603 {
return __lhs._M_base() != __rhs._M_base(); }
605 template<
typename _Key,
typename _Compare,
typename _Allocator>
607 operator<(const set<_Key, _Compare, _Allocator>& __lhs,
608 const set<_Key, _Compare, _Allocator>& __rhs)
609 {
return __lhs._M_base() < __rhs._M_base(); }
611 template<
typename _Key,
typename _Compare,
typename _Allocator>
613 operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
614 const set<_Key, _Compare, _Allocator>& __rhs)
615 {
return __lhs._M_base() <= __rhs._M_base(); }
617 template<
typename _Key,
typename _Compare,
typename _Allocator>
619 operator>=(
const set<_Key, _Compare, _Allocator>& __lhs,
620 const set<_Key, _Compare, _Allocator>& __rhs)
621 {
return __lhs._M_base() >= __rhs._M_base(); }
623 template<
typename _Key,
typename _Compare,
typename _Allocator>
625 operator>(
const set<_Key, _Compare, _Allocator>& __lhs,
626 const set<_Key, _Compare, _Allocator>& __rhs)
627 {
return __lhs._M_base() > __rhs._M_base(); }
629 template<
typename _Key,
typename _Compare,
typename _Allocator>
631 swap(set<_Key, _Compare, _Allocator>& __x,
632 set<_Key, _Compare, _Allocator>& __y)
633 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
634 {
return __x.swap(__y); }
#define __glibcxx_check_erase_range(_First, _Last)
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
_T2 second
first is a copy of the first object
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
A standard container made up of unique keys, which can be retrieved in logarithmic time...
_T1 first
second_type is the second bound type
_Iterator & base() noexcept
Return the underlying iterator.
One of the comparison functors.
ISO C++ entities toplevel namespace is std.
The standard allocator, as per [20.4].
void _M_invalidate_if(_Predicate __pred)
Class std::set with safety/checking/debug instrumentation.
Safe class dealing with some allocator dependent operations.
#define __glibcxx_check_erase(_Position)
Struct holding two objects of arbitrary type.
#define __glibcxx_check_insert(_Position)