29 #ifndef _GLIBCXX_DEBUG_SET_H
30 #define _GLIBCXX_DEBUG_SET_H 1
36 namespace std _GLIBCXX_VISIBILITY(default)
41 template<
typename _Key,
typename _Compare = std::less<_Key>,
42 typename _Allocator = std::allocator<_Key> >
47 typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator>
_Base;
52 #if __cplusplus >= 201103L
58 typedef _Key key_type;
59 typedef _Key value_type;
60 typedef _Compare key_compare;
61 typedef _Compare value_compare;
62 typedef _Allocator allocator_type;
63 typedef typename _Base::reference reference;
64 typedef typename _Base::const_reference const_reference;
71 typedef typename _Base::size_type size_type;
72 typedef typename _Base::difference_type difference_type;
73 typedef typename _Base::pointer pointer;
74 typedef typename _Base::const_pointer const_pointer;
82 explicit set(
const _Compare& __comp,
83 const _Allocator& __a = _Allocator())
84 :
_Base(__comp, __a) { }
86 template<
typename _InputIterator>
87 set(_InputIterator __first, _InputIterator __last,
88 const _Compare& __comp = _Compare(),
89 const _Allocator& __a = _Allocator())
101 #if __cplusplus >= 201103L
103 noexcept(is_nothrow_copy_constructible<_Compare>::value)
104 :
_Base(std::move(__x))
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 allocator_type& __a)
117 :
_Base(__x, __a) { }
119 set(
set&& __x,
const allocator_type& __a)
120 :
_Base(std::move(__x._M_base()), __a) { }
126 template<
typename _InputIterator>
127 set(_InputIterator __first, _InputIterator __last,
128 const allocator_type& __a)
135 ~
set() _GLIBCXX_NOEXCEPT { }
138 operator=(
const set& __x)
141 this->_M_invalidate_all();
145 #if __cplusplus >= 201103L
148 noexcept(_Alloc_traits::_S_nothrow_move())
150 __glibcxx_check_self_move_assign(__x);
151 bool __xfer_memory = _Alloc_traits::_S_propagate_on_move_assign()
152 || __x.get_allocator() == this->get_allocator();
153 _M_base() = std::move(__x._M_base());
157 this->_M_invalidate_all();
158 __x._M_invalidate_all();
166 this->_M_invalidate_all();
171 using _Base::get_allocator;
175 begin() _GLIBCXX_NOEXCEPT
176 {
return iterator(_Base::begin(),
this); }
179 begin()
const _GLIBCXX_NOEXCEPT
183 end() _GLIBCXX_NOEXCEPT
184 {
return iterator(_Base::end(),
this); }
187 end()
const _GLIBCXX_NOEXCEPT
191 rbegin() _GLIBCXX_NOEXCEPT
195 rbegin()
const _GLIBCXX_NOEXCEPT
199 rend() _GLIBCXX_NOEXCEPT
203 rend()
const _GLIBCXX_NOEXCEPT
206 #if __cplusplus >= 201103L
208 cbegin()
const noexcept
212 cend()
const noexcept
216 crbegin()
const noexcept
220 crend()
const noexcept
227 using _Base::max_size;
230 #if __cplusplus >= 201103L
231 template<
typename... _Args>
233 emplace(_Args&&... __args)
235 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
240 template<
typename... _Args>
246 std::forward<_Args>(__args)...),
252 insert(
const value_type& __x)
259 #if __cplusplus >= 201103L
261 insert(value_type&& __x)
264 = _Base::insert(std::move(__x));
274 return iterator(_Base::insert(__position.
base(), __x),
this);
277 #if __cplusplus >= 201103L
282 return iterator(_Base::insert(__position.
base(), std::move(__x)),
287 template <
typename _InputIterator>
289 insert(_InputIterator __first, _InputIterator __last)
291 __glibcxx_check_valid_range(__first, __last);
296 #if __cplusplus >= 201103L
299 { _Base::insert(__l); }
302 #if __cplusplus >= 201103L
316 _Base::erase(__position.
base());
321 erase(
const key_type& __x)
324 if (__victim == _Base::end())
329 _Base::erase(__victim);
334 #if __cplusplus >= 201103L
342 __victim != __last.
base(); ++__victim)
344 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
345 _M_message(__gnu_debug::__msg_valid_range)
346 ._M_iterator(__first,
"first")
347 ._M_iterator(__last,
"last"));
360 __victim != __last.
base(); ++__victim)
362 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
363 _M_message(__gnu_debug::__msg_valid_range)
364 ._M_iterator(__first,
"first")
365 ._M_iterator(__last,
"last"));
368 _Base::erase(__first.
base(), __last.
base());
374 #if __cplusplus >= 201103L
375 noexcept(_Alloc_traits::_S_nothrow_swap())
378 #if __cplusplus >= 201103L
379 if (!_Alloc_traits::_S_propagate_on_swap())
380 __glibcxx_check_equal_allocs(__x);
387 clear() _GLIBCXX_NOEXCEPT
389 this->_M_invalidate_all();
394 using _Base::key_comp;
395 using _Base::value_comp;
399 find(
const key_type& __x)
400 {
return iterator(_Base::find(__x),
this); }
405 find(
const key_type& __x)
const
411 lower_bound(
const key_type& __x)
412 {
return iterator(_Base::lower_bound(__x),
this); }
417 lower_bound(
const key_type& __x)
const
421 upper_bound(
const key_type& __x)
422 {
return iterator(_Base::upper_bound(__x),
this); }
427 upper_bound(
const key_type& __x)
const
431 equal_range(
const key_type& __x)
434 _Base::equal_range(__x);
442 equal_range(
const key_type& __x)
const
445 _Base::equal_range(__x);
451 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
454 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
465 template<
typename _Key,
typename _Compare,
typename _Allocator>
469 {
return __lhs._M_base() == __rhs._M_base(); }
471 template<
typename _Key,
typename _Compare,
typename _Allocator>
475 {
return __lhs._M_base() != __rhs._M_base(); }
477 template<
typename _Key,
typename _Compare,
typename _Allocator>
479 operator<(const set<_Key, _Compare, _Allocator>& __lhs,
480 const set<_Key, _Compare, _Allocator>& __rhs)
481 {
return __lhs._M_base() < __rhs._M_base(); }
483 template<
typename _Key,
typename _Compare,
typename _Allocator>
485 operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
486 const set<_Key, _Compare, _Allocator>& __rhs)
487 {
return __lhs._M_base() <= __rhs._M_base(); }
489 template<
typename _Key,
typename _Compare,
typename _Allocator>
491 operator>=(
const set<_Key, _Compare, _Allocator>& __lhs,
492 const set<_Key, _Compare, _Allocator>& __rhs)
493 {
return __lhs._M_base() >= __rhs._M_base(); }
495 template<
typename _Key,
typename _Compare,
typename _Allocator>
497 operator>(
const set<_Key, _Compare, _Allocator>& __lhs,
498 const set<_Key, _Compare, _Allocator>& __rhs)
499 {
return __lhs._M_base() > __rhs._M_base(); }
501 template<
typename _Key,
typename _Compare,
typename _Allocator>
503 swap(set<_Key, _Compare, _Allocator>& __x,
504 set<_Key, _Compare, _Allocator>& __y)
505 {
return __x.swap(__y); }
void _M_swap(_Safe_sequence_base &__x)
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_insert(_Position)
Uniform interface to C++98 and C++0x allocators.
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
constexpr size_t size() const noexcept
Returns the total number of bits.
_T1 first
second_type is the second bound type
A standard container made up of unique keys, which can be retrieved in logarithmic time...
size_t count() const noexcept
Returns the number of bits which are set.
Class std::set with safety/checking/debug instrumentation.
_Iterator base() const noexcept
Return the underlying iterator.
bitset< _Nb > & set() noexcept
Sets every bit to true.
Struct holding two objects of arbitrary type.
#define __glibcxx_check_erase(_Position)
Base class for constructing a safe sequence type that tracks iterators that reference it...
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
#define __glibcxx_check_erase_range(_First, _Last)