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
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),
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;
302 struct insert_return_type
314 return _Base::extract(__position.
base());
318 extract(
const key_type& __key)
320 const auto __position = find(__key);
321 if (__position != end())
322 return extract(__position);
327 insert(node_type&& __nh)
329 auto __ret = _Base::insert(std::move(__nh));
331 return { __ret.inserted, __pos, std::move(__ret.node) };
338 return iterator(_Base::insert(__hint.
base(), std::move(__nh)),
this);
344 #if __cplusplus >= 201103L
358 _Base::erase(__position.
base());
363 erase(
const key_type& __x)
366 if (__victim == _Base::end())
371 _Base::erase(__victim);
376 #if __cplusplus >= 201103L
384 __victim != __last.
base(); ++__victim)
386 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
387 _M_message(__gnu_debug::__msg_valid_range)
388 ._M_iterator(__first,
"first")
389 ._M_iterator(__last,
"last"));
402 __victim != __last.
base(); ++__victim)
404 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
405 _M_message(__gnu_debug::__msg_valid_range)
406 ._M_iterator(__first,
"first")
407 ._M_iterator(__last,
"last"));
410 _Base::erase(__first.
base(), __last.
base());
416 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
423 clear() _GLIBCXX_NOEXCEPT
425 this->_M_invalidate_all();
430 using _Base::key_comp;
431 using _Base::value_comp;
435 find(
const key_type& __x)
436 {
return iterator(_Base::find(__x),
this); }
441 find(
const key_type& __x)
const
444 #if __cplusplus > 201103L
445 template<
typename _Kt,
447 typename __has_is_transparent<_Compare, _Kt>::type>
450 {
return { _Base::find(__x),
this }; }
452 template<
typename _Kt,
454 typename __has_is_transparent<_Compare, _Kt>::type>
456 find(
const _Kt& __x)
const
457 {
return { _Base::find(__x),
this }; }
463 lower_bound(
const key_type& __x)
464 {
return iterator(_Base::lower_bound(__x),
this); }
469 lower_bound(
const key_type& __x)
const
472 #if __cplusplus > 201103L
473 template<
typename _Kt,
475 typename __has_is_transparent<_Compare, _Kt>::type>
477 lower_bound(
const _Kt& __x)
478 {
return { _Base::lower_bound(__x),
this }; }
480 template<
typename _Kt,
482 typename __has_is_transparent<_Compare, _Kt>::type>
484 lower_bound(
const _Kt& __x)
const
485 {
return { _Base::lower_bound(__x),
this }; }
489 upper_bound(
const key_type& __x)
490 {
return iterator(_Base::upper_bound(__x),
this); }
495 upper_bound(
const key_type& __x)
const
498 #if __cplusplus > 201103L
499 template<
typename _Kt,
501 typename __has_is_transparent<_Compare, _Kt>::type>
503 upper_bound(
const _Kt& __x)
504 {
return { _Base::upper_bound(__x),
this }; }
506 template<
typename _Kt,
508 typename __has_is_transparent<_Compare, _Kt>::type>
510 upper_bound(
const _Kt& __x)
const
511 {
return { _Base::upper_bound(__x),
this }; }
515 equal_range(
const key_type& __x)
518 _Base::equal_range(__x);
526 equal_range(
const key_type& __x)
const
529 _Base::equal_range(__x);
534 #if __cplusplus > 201103L
535 template<
typename _Kt,
537 typename __has_is_transparent<_Compare, _Kt>::type>
539 equal_range(
const _Kt& __x)
541 auto __res = _Base::equal_range(__x);
542 return { { __res.first,
this }, { __res.second,
this } };
545 template<
typename _Kt,
547 typename __has_is_transparent<_Compare, _Kt>::type>
549 equal_range(
const _Kt& __x)
const
551 auto __res = _Base::equal_range(__x);
552 return { { __res.first,
this }, { __res.second,
this } };
557 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
560 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
563 template<
typename _Key,
typename _Compare,
typename _Allocator>
567 {
return __lhs._M_base() == __rhs._M_base(); }
569 template<
typename _Key,
typename _Compare,
typename _Allocator>
573 {
return __lhs._M_base() != __rhs._M_base(); }
575 template<
typename _Key,
typename _Compare,
typename _Allocator>
577 operator<(const set<_Key, _Compare, _Allocator>& __lhs,
578 const set<_Key, _Compare, _Allocator>& __rhs)
579 {
return __lhs._M_base() < __rhs._M_base(); }
581 template<
typename _Key,
typename _Compare,
typename _Allocator>
583 operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
584 const set<_Key, _Compare, _Allocator>& __rhs)
585 {
return __lhs._M_base() <= __rhs._M_base(); }
587 template<
typename _Key,
typename _Compare,
typename _Allocator>
589 operator>=(
const set<_Key, _Compare, _Allocator>& __lhs,
590 const set<_Key, _Compare, _Allocator>& __rhs)
591 {
return __lhs._M_base() >= __rhs._M_base(); }
593 template<
typename _Key,
typename _Compare,
typename _Allocator>
595 operator>(
const set<_Key, _Compare, _Allocator>& __lhs,
596 const set<_Key, _Compare, _Allocator>& __rhs)
597 {
return __lhs._M_base() > __rhs._M_base(); }
599 template<
typename _Key,
typename _Compare,
typename _Allocator>
601 swap(set<_Key, _Compare, _Allocator>& __x,
602 set<_Key, _Compare, _Allocator>& __y)
603 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
604 {
return __x.swap(__y); }
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...
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.
_Iterator & base() noexcept
Return the underlying iterator.
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_insert(_Position)
Safe class dealing with some allocator dependent operations.
void _M_invalidate_if(_Predicate __pred)
_T2 second
first is a copy of the first object
Struct holding two objects of arbitrary type.
Class std::set with safety/checking/debug instrumentation.
_T1 first
second_type is the second bound type
#define __glibcxx_check_erase(_Position)