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)
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())
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
172 {
return const_iterator(_Base::begin(),
this); }
175 end() _GLIBCXX_NOEXCEPT
176 {
return iterator(_Base::end(),
this); }
179 end()
const _GLIBCXX_NOEXCEPT
180 {
return const_iterator(_Base::end(),
this); }
183 rbegin() _GLIBCXX_NOEXCEPT
184 {
return reverse_iterator(end()); }
186 const_reverse_iterator
187 rbegin()
const _GLIBCXX_NOEXCEPT
188 {
return const_reverse_iterator(end()); }
191 rend() _GLIBCXX_NOEXCEPT
192 {
return reverse_iterator(begin()); }
194 const_reverse_iterator
195 rend()
const _GLIBCXX_NOEXCEPT
196 {
return const_reverse_iterator(begin()); }
198 #if __cplusplus >= 201103L 200 cbegin()
const noexcept
201 {
return const_iterator(_Base::begin(),
this); }
204 cend()
const noexcept
205 {
return const_iterator(_Base::end(),
this); }
207 const_reverse_iterator
208 crbegin()
const noexcept
209 {
return const_reverse_iterator(end()); }
211 const_reverse_iterator
212 crend()
const noexcept
213 {
return const_reverse_iterator(begin()); }
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>
234 emplace_hint(const_iterator __pos, _Args&&... __args)
237 return iterator(_Base::emplace_hint(__pos.
base(),
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));
263 insert(const_iterator __position,
const value_type& __x)
266 return iterator(_Base::insert(__position.
base(), __x),
this);
269 #if __cplusplus >= 201103L 271 insert(const_iterator __position, value_type&& __x)
274 return iterator(_Base::insert(__position.
base(), std::move(__x)),
279 template <
typename _InputIterator>
281 insert(_InputIterator __first, _InputIterator __last)
283 __glibcxx_check_valid_range(__first, __last);
288 #if __cplusplus >= 201103L 291 { _Base::insert(__l); }
294 #if __cplusplus >= 201103L 296 erase(const_iterator __position)
300 return iterator(_Base::erase(__position.
base()),
this);
304 erase(iterator __position)
308 _Base::erase(__position.
base());
313 erase(
const key_type& __x)
315 _Base_iterator __victim = _Base::find(__x);
316 if (__victim == _Base::end())
321 _Base::erase(__victim);
326 #if __cplusplus >= 201103L 328 erase(const_iterator __first, const_iterator __last)
333 for (_Base_const_iterator __victim = __first.
base();
334 __victim != __last.
base(); ++__victim)
336 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
337 _M_message(__gnu_debug::__msg_valid_range)
338 ._M_iterator(__first,
"first")
339 ._M_iterator(__last,
"last"));
342 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
346 erase(iterator __first, iterator __last)
351 for (_Base_iterator __victim = __first.
base();
352 __victim != __last.
base(); ++__victim)
354 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
355 _M_message(__gnu_debug::__msg_valid_range)
356 ._M_iterator(__first,
"first")
357 ._M_iterator(__last,
"last"));
360 _Base::erase(__first.
base(), __last.
base());
366 #if __cplusplus >= 201103L 367 noexcept( noexcept(declval<_Base>().swap(__x)) )
375 clear() _GLIBCXX_NOEXCEPT
377 this->_M_invalidate_all();
382 using _Base::key_comp;
383 using _Base::value_comp;
387 find(
const key_type& __x)
388 {
return iterator(_Base::find(__x),
this); }
393 find(
const key_type& __x)
const 394 {
return const_iterator(_Base::find(__x),
this); }
399 lower_bound(
const key_type& __x)
400 {
return iterator(_Base::lower_bound(__x),
this); }
405 lower_bound(
const key_type& __x)
const 406 {
return const_iterator(_Base::lower_bound(__x),
this); }
409 upper_bound(
const key_type& __x)
410 {
return iterator(_Base::upper_bound(__x),
this); }
415 upper_bound(
const key_type& __x)
const 416 {
return const_iterator(_Base::upper_bound(__x),
this); }
419 equal_range(
const key_type& __x)
422 _Base::equal_range(__x);
424 iterator(__res.
second,
this));
430 equal_range(
const key_type& __x)
const 433 _Base::equal_range(__x);
435 const_iterator(__res.
second,
this));
439 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
442 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
445 template<
typename _Key,
typename _Compare,
typename _Allocator>
449 {
return __lhs._M_base() == __rhs._M_base(); }
451 template<
typename _Key,
typename _Compare,
typename _Allocator>
455 {
return __lhs._M_base() != __rhs._M_base(); }
457 template<
typename _Key,
typename _Compare,
typename _Allocator>
459 operator<(const set<_Key, _Compare, _Allocator>& __lhs,
461 {
return __lhs._M_base() < __rhs._M_base(); }
463 template<
typename _Key,
typename _Compare,
typename _Allocator>
465 operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
467 {
return __lhs._M_base() <= __rhs._M_base(); }
469 template<
typename _Key,
typename _Compare,
typename _Allocator>
473 {
return __lhs._M_base() >= __rhs._M_base(); }
475 template<
typename _Key,
typename _Compare,
typename _Allocator>
479 {
return __lhs._M_base() > __rhs._M_base(); }
481 template<
typename _Key,
typename _Compare,
typename _Allocator>
485 {
return __x.swap(__y); }
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
Class std::set with safety/checking/debug instrumentation.
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(_Position)
Safe class dealing with some allocator dependent operations.
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_erase_range(_First, _Last)
_T2 second
first is a copy of the first object
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Struct holding two objects of arbitrary type.
_T1 first
second_type is the second bound type
ISO C++ entities toplevel namespace is std.
#define __glibcxx_check_insert(_Position)