30 #ifndef _GLIBCXX_DEBUG_SET_H
31 #define _GLIBCXX_DEBUG_SET_H 1
41 template<
typename _Key,
typename _Compare = std::less<_Key>,
42 typename _Allocator = std::allocator<_Key> >
44 :
public _GLIBCXX_STD_D::set<_Key,_Compare,_Allocator>,
47 typedef _GLIBCXX_STD_D::set<_Key, _Compare, _Allocator> _Base;
52 typedef _Key key_type;
53 typedef _Key value_type;
54 typedef _Compare key_compare;
55 typedef _Compare value_compare;
56 typedef _Allocator allocator_type;
57 typedef typename _Base::reference reference;
58 typedef typename _Base::const_reference const_reference;
65 typedef typename _Base::size_type size_type;
66 typedef typename _Base::difference_type difference_type;
67 typedef typename _Base::pointer pointer;
68 typedef typename _Base::const_pointer const_pointer;
73 explicit set(
const _Compare& __comp = _Compare(),
74 const _Allocator& __a = _Allocator())
75 : _Base(__comp, __a) { }
77 template<
typename _InputIterator>
78 set(_InputIterator __first, _InputIterator __last,
79 const _Compare& __comp = _Compare(),
80 const _Allocator& __a = _Allocator())
81 : _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
85 : _Base(__x), _Safe_base() { }
88 : _Base(__x), _Safe_base() { }
90 #ifdef __GXX_EXPERIMENTAL_CXX0X__
92 : _Base(std::forward<set>(__x)), _Safe_base()
95 set(initializer_list<value_type> __l,
96 const _Compare& __comp = _Compare(),
97 const allocator_type& __a = allocator_type())
98 : _Base(__l, __comp, __a), _Safe_base() { }
104 operator=(
const set& __x)
106 *
static_cast<_Base*
>(
this) = __x;
111 #ifdef __GXX_EXPERIMENTAL_CXX0X__
122 operator=(initializer_list<value_type> __l)
130 using _Base::get_allocator;
135 {
return iterator(_Base::begin(),
this); }
139 {
return const_iterator(_Base::begin(),
this); }
143 {
return iterator(_Base::end(),
this); }
147 {
return const_iterator(_Base::end(),
this); }
151 {
return reverse_iterator(end()); }
153 const_reverse_iterator
155 {
return const_reverse_iterator(end()); }
159 {
return reverse_iterator(begin()); }
161 const_reverse_iterator
163 {
return const_reverse_iterator(begin()); }
165 #ifdef __GXX_EXPERIMENTAL_CXX0X__
168 {
return const_iterator(_Base::begin(),
this); }
172 {
return const_iterator(_Base::end(),
this); }
174 const_reverse_iterator
176 {
return const_reverse_iterator(end()); }
178 const_reverse_iterator
180 {
return const_reverse_iterator(begin()); }
186 using _Base::max_size;
190 insert(
const value_type& __x)
192 typedef typename _Base::iterator _Base_iterator;
199 insert(iterator __position,
const value_type& __x)
202 return iterator(_Base::insert(__position.base(), __x),
this);
205 template <
typename _InputIterator>
207 insert(_InputIterator __first, _InputIterator __last)
209 __glibcxx_check_valid_range(__first, __last);
210 _Base::insert(__first, __last);
213 #ifdef __GXX_EXPERIMENTAL_CXX0X__
215 insert(initializer_list<value_type> __l)
216 { _Base::insert(__l); }
220 erase(iterator __position)
223 __position._M_invalidate();
224 _Base::erase(__position.base());
228 erase(
const key_type& __x)
230 iterator __victim = find(__x);
231 if (__victim == end())
235 __victim._M_invalidate();
236 _Base::erase(__victim.base());
242 erase(iterator __first, iterator __last)
248 while (__first != __last)
249 this->erase(__first++);
253 #ifdef __GXX_EXPERIMENTAL_CXX0X__
265 { this->erase(begin(), end()); }
268 using _Base::key_comp;
269 using _Base::value_comp;
273 find(
const key_type& __x)
274 {
return iterator(_Base::find(__x),
this); }
279 find(
const key_type& __x)
const
280 {
return const_iterator(_Base::find(__x),
this); }
285 lower_bound(
const key_type& __x)
286 {
return iterator(_Base::lower_bound(__x),
this); }
291 lower_bound(
const key_type& __x)
const
292 {
return const_iterator(_Base::lower_bound(__x),
this); }
295 upper_bound(
const key_type& __x)
296 {
return iterator(_Base::upper_bound(__x),
this); }
301 upper_bound(
const key_type& __x)
const
302 {
return const_iterator(_Base::upper_bound(__x),
this); }
305 equal_range(
const key_type& __x)
307 typedef typename _Base::iterator _Base_iterator;
309 _Base::equal_range(__x);
310 return std::make_pair(iterator(__res.
first,
this),
311 iterator(__res.
second,
this));
317 equal_range(
const key_type& __x)
const
319 typedef typename _Base::const_iterator _Base_iterator;
321 _Base::equal_range(__x);
322 return std::make_pair(const_iterator(__res.
first,
this),
323 const_iterator(__res.
second,
this));
327 _M_base() {
return *
this; }
330 _M_base()
const {
return *
this; }
336 typedef typename _Base::const_iterator _Base_const_iterator;
342 template<
typename _Key,
typename _Compare,
typename _Allocator>
344 operator==(
const set<_Key, _Compare, _Allocator>& __lhs,
345 const set<_Key, _Compare, _Allocator>& __rhs)
346 {
return __lhs._M_base() == __rhs._M_base(); }
348 template<
typename _Key,
typename _Compare,
typename _Allocator>
350 operator!=(
const set<_Key, _Compare, _Allocator>& __lhs,
351 const set<_Key, _Compare, _Allocator>& __rhs)
352 {
return __lhs._M_base() != __rhs._M_base(); }
354 template<
typename _Key,
typename _Compare,
typename _Allocator>
356 operator<(const set<_Key, _Compare, _Allocator>& __lhs,
357 const set<_Key, _Compare, _Allocator>& __rhs)
358 {
return __lhs._M_base() < __rhs._M_base(); }
360 template<
typename _Key,
typename _Compare,
typename _Allocator>
362 operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
363 const set<_Key, _Compare, _Allocator>& __rhs)
364 {
return __lhs._M_base() <= __rhs._M_base(); }
366 template<
typename _Key,
typename _Compare,
typename _Allocator>
368 operator>=(
const set<_Key, _Compare, _Allocator>& __lhs,
369 const set<_Key, _Compare, _Allocator>& __rhs)
370 {
return __lhs._M_base() >= __rhs._M_base(); }
372 template<
typename _Key,
typename _Compare,
typename _Allocator>
374 operator>(
const set<_Key, _Compare, _Allocator>& __lhs,
375 const set<_Key, _Compare, _Allocator>& __rhs)
376 {
return __lhs._M_base() > __rhs._M_base(); }
378 template<
typename _Key,
typename _Compare,
typename _Allocator>
380 swap(set<_Key, _Compare, _Allocator>& __x,
381 set<_Key, _Compare, _Allocator>& __y)
382 {
return __x.swap(__y); }
384 #ifdef __GXX_EXPERIMENTAL_CXX0X__
385 template<
typename _Key,
typename _Compare,
typename _Allocator>
387 swap(set<_Key, _Compare, _Allocator>&& __x,
388 set<_Key, _Compare, _Allocator>& __y)
389 {
return __x.swap(__y); }
391 template<
typename _Key,
typename _Compare,
typename _Allocator>
393 swap(set<_Key, _Compare, _Allocator>& __x,
394 set<_Key, _Compare, _Allocator>&& __y)
395 {
return __x.swap(__y); }
void _M_invalidate_if(_Predicate __pred)
pair holds two objects of arbitrary type.
#define __glibcxx_check_erase(_Position)
_T2 second
second is a copy of the second object
Base class for constructing a "safe" sequence type that tracks iterators that reference it...
_T1 first
first is a copy of the first object
void _M_invalidate_all() const
#define __glibcxx_check_erase_range(_First, _Last)
void _M_swap(_Safe_sequence_base &__x)
#define __glibcxx_check_insert(_Position)