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> >
44 :
public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>,
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)
107 set(initializer_list<value_type> __l,
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) { }
122 set(initializer_list<value_type> __l,
const allocator_type& __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();
157 this->_M_invalidate_all();
158 __x._M_invalidate_all();
163 operator=(initializer_list<value_type> __l)
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
180 {
return const_iterator(_Base::begin(),
this); }
183 end() _GLIBCXX_NOEXCEPT
184 {
return iterator(_Base::end(),
this); }
187 end()
const _GLIBCXX_NOEXCEPT
188 {
return const_iterator(_Base::end(),
this); }
191 rbegin() _GLIBCXX_NOEXCEPT
192 {
return reverse_iterator(end()); }
194 const_reverse_iterator
195 rbegin()
const _GLIBCXX_NOEXCEPT
196 {
return const_reverse_iterator(end()); }
199 rend() _GLIBCXX_NOEXCEPT
200 {
return reverse_iterator(begin()); }
202 const_reverse_iterator
203 rend()
const _GLIBCXX_NOEXCEPT
204 {
return const_reverse_iterator(begin()); }
206 #if __cplusplus >= 201103L
208 cbegin()
const noexcept
209 {
return const_iterator(_Base::begin(),
this); }
212 cend()
const noexcept
213 {
return const_iterator(_Base::end(),
this); }
215 const_reverse_iterator
216 crbegin()
const noexcept
217 {
return const_reverse_iterator(end()); }
219 const_reverse_iterator
220 crend()
const noexcept
221 {
return const_reverse_iterator(begin()); }
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>
242 emplace_hint(const_iterator __pos, _Args&&... __args)
245 return iterator(_Base::emplace_hint(__pos.
base(),
246 std::forward<_Args>(__args)...),
252 insert(
const value_type& __x)
259 #if __cplusplus >= 201103L
261 insert(value_type&& __x)
271 insert(const_iterator __position,
const value_type& __x)
274 return iterator(_Base::insert(__position.
base(), __x),
this);
277 #if __cplusplus >= 201103L
279 insert(const_iterator __position, value_type&& __x)
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
298 insert(initializer_list<value_type> __l)
299 { _Base::insert(__l); }
302 #if __cplusplus >= 201103L
304 erase(const_iterator __position)
308 return iterator(_Base::erase(__position.
base()),
this);
312 erase(iterator __position)
316 _Base::erase(__position.
base());
321 erase(
const key_type& __x)
323 _Base_iterator __victim = _Base::find(__x);
324 if (__victim == _Base::end())
329 _Base::erase(__victim);
334 #if __cplusplus >= 201103L
336 erase(const_iterator __first, const_iterator __last)
341 for (_Base_const_iterator __victim = __first.
base();
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"));
350 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
354 erase(iterator __first, iterator __last)
359 for (_Base_iterator __victim = __first.
base();
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
406 {
return const_iterator(_Base::find(__x),
this); }
411 lower_bound(
const key_type& __x)
412 {
return iterator(_Base::lower_bound(__x),
this); }
417 lower_bound(
const key_type& __x)
const
418 {
return const_iterator(_Base::lower_bound(__x),
this); }
421 upper_bound(
const key_type& __x)
422 {
return iterator(_Base::upper_bound(__x),
this); }
427 upper_bound(
const key_type& __x)
const
428 {
return const_iterator(_Base::upper_bound(__x),
this); }
431 equal_range(
const key_type& __x)
434 _Base::equal_range(__x);
436 iterator(__res.
second,
this));
442 equal_range(
const key_type& __x)
const
445 _Base::equal_range(__x);
447 const_iterator(__res.
second,
this));
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); }
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
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.
Uniform interface to C++98 and C++0x allocators.
#define __glibcxx_check_insert(_Position)
Base class for constructing a safe sequence type that tracks iterators that reference it...
void _M_invalidate_if(_Predicate __pred)
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Class std::set with safety/checking/debug instrumentation.
void _M_swap(_Safe_sequence_base &__x)
_T1 first
second_type is the second bound type
ISO C++ entities toplevel namespace is std.
#define __glibcxx_check_erase(_Position)
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
A standard container made up of unique keys, which can be retrieved in logarithmic time...
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
Struct holding two objects of arbitrary type.
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
_Iterator base() const noexcept
Return the underlying iterator.
_T2 second
first is a copy of the first object
#define __glibcxx_check_erase_range(_First, _Last)