30 #ifndef _GLIBCXX_DEBUG_LIST
31 #define _GLIBCXX_DEBUG_LIST 1
37 namespace std _GLIBCXX_VISIBILITY(default)
42 template<
typename _Tp,
typename _Allocator = std::allocator<_Tp> >
44 :
public _GLIBCXX_STD_C::list<_Tp, _Allocator>,
47 typedef _GLIBCXX_STD_C::list<_Tp, _Allocator>
_Base;
54 typedef typename _Base::reference reference;
55 typedef typename _Base::const_reference const_reference;
62 typedef typename _Base::size_type size_type;
63 typedef typename _Base::difference_type difference_type;
65 typedef _Tp value_type;
66 typedef _Allocator allocator_type;
67 typedef typename _Base::pointer pointer;
68 typedef typename _Base::const_pointer const_pointer;
74 list(
const _Allocator& __a = _Allocator())
77 #ifdef __GXX_EXPERIMENTAL_CXX0X__
82 list(size_type __n,
const _Tp& __value,
83 const _Allocator& __a = _Allocator())
84 :
_Base(__n, __value, __a) { }
87 list(size_type __n,
const _Tp& __value = _Tp(),
88 const _Allocator& __a = _Allocator())
89 :
_Base(__n, __value, __a) { }
92 template<
class _InputIterator>
93 list(_InputIterator __first, _InputIterator __last,
94 const _Allocator& __a = _Allocator())
107 #ifdef __GXX_EXPERIMENTAL_CXX0X__
109 :
_Base(std::move(__x))
113 const allocator_type& __a = allocator_type())
114 :
_Base(__l, __a) { }
117 ~
list() _GLIBCXX_NOEXCEPT { }
120 operator=(
const list& __x)
122 static_cast<_Base&
>(*this) = __x;
123 this->_M_invalidate_all();
127 #ifdef __GXX_EXPERIMENTAL_CXX0X__
129 operator=(
list&& __x)
141 static_cast<_Base&
>(*this) = __l;
142 this->_M_invalidate_all();
150 this->_M_invalidate_all();
154 template<
class _InputIterator>
156 assign(_InputIterator __first, _InputIterator __last)
158 __glibcxx_check_valid_range(__first, __last);
161 this->_M_invalidate_all();
165 assign(size_type __n,
const _Tp& __t)
167 _Base::assign(__n, __t);
168 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 #ifdef __GXX_EXPERIMENTAL_CXX0X__
208 cbegin()
const noexcept
212 cend()
const noexcept
216 crbegin()
const noexcept
220 crend()
const noexcept
227 using _Base::max_size;
229 #ifdef __GXX_EXPERIMENTAL_CXX0X__
231 resize(size_type __sz)
238 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
241 for (; __victim != __end; ++__victim)
253 __throw_exception_again;
258 resize(size_type __sz,
const _Tp& __c)
265 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
268 for (; __victim != __end; ++__victim)
275 _Base::resize(__sz, __c);
280 __throw_exception_again;
285 resize(size_type __sz, _Tp __c = _Tp())
292 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
295 for (; __victim != __end; ++__victim)
302 _Base::resize(__sz, __c);
307 __throw_exception_again;
316 __glibcxx_check_nonempty();
317 return _Base::front();
323 __glibcxx_check_nonempty();
324 return _Base::front();
330 __glibcxx_check_nonempty();
331 return _Base::back();
337 __glibcxx_check_nonempty();
338 return _Base::back();
342 using _Base::push_front;
344 #ifdef __GXX_EXPERIMENTAL_CXX0X__
345 using _Base::emplace_front;
351 __glibcxx_check_nonempty();
356 using _Base::push_back;
358 #ifdef __GXX_EXPERIMENTAL_CXX0X__
359 using _Base::emplace_back;
365 __glibcxx_check_nonempty();
370 #ifdef __GXX_EXPERIMENTAL_CXX0X__
371 template<
typename... _Args>
373 emplace(
iterator __position, _Args&&... __args)
377 std::forward<_Args>(__args)...),
this);
382 insert(
iterator __position,
const _Tp& __x)
385 return iterator(_Base::insert(__position.
base(), __x),
this);
388 #ifdef __GXX_EXPERIMENTAL_CXX0X__
390 insert(
iterator __position, _Tp&& __x)
391 {
return emplace(__position, std::move(__x)); }
397 _Base::insert(__p.
base(), __l);
402 insert(
iterator __position, size_type __n,
const _Tp& __x)
405 _Base::insert(__position.
base(), __n, __x);
408 template<
class _InputIterator>
410 insert(
iterator __position, _InputIterator __first,
411 _InputIterator __last)
423 return _Base::erase(__position);
440 __victim != __last.
base(); ++__victim)
442 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
443 _M_message(__gnu_debug::__msg_valid_range)
444 ._M_iterator(__position,
"position")
445 ._M_iterator(__last,
"last"));
459 clear() _GLIBCXX_NOEXCEPT
462 this->_M_invalidate_all();
467 #ifdef __GXX_EXPERIMENTAL_CXX0X__
473 _GLIBCXX_DEBUG_VERIFY(&__x !=
this,
474 _M_message(__gnu_debug::__msg_self_splice)
475 ._M_sequence(*
this,
"this"));
477 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()));
480 #ifdef __GXX_EXPERIMENTAL_CXX0X__
483 { splice(__position, std::move(__x)); }
487 #ifdef __GXX_EXPERIMENTAL_CXX0X__
499 _M_message(__gnu_debug::__msg_splice_bad)
500 ._M_iterator(__i,
"__i"));
502 _M_message(__gnu_debug::__msg_splice_other)
503 ._M_iterator(__i,
"__i")._M_sequence(__x,
"__x"));
508 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
512 #ifdef __GXX_EXPERIMENTAL_CXX0X__
515 { splice(__position, std::move(__x), __i); }
519 #ifdef __GXX_EXPERIMENTAL_CXX0X__
528 __glibcxx_check_valid_range(__first, __last);
530 _M_message(__gnu_debug::__msg_splice_other)
531 ._M_sequence(__x,
"x")
532 ._M_iterator(__first,
"first"));
538 __tmp != __last.
base(); ++__tmp)
540 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
541 _M_message(__gnu_debug::__msg_valid_range)
542 ._M_iterator(__first,
"first")
543 ._M_iterator(__last,
"last"));
544 _GLIBCXX_DEBUG_VERIFY(&__x !=
this || __tmp != __position,
545 _M_message(__gnu_debug::__msg_splice_overlap)
546 ._M_iterator(__tmp,
"position")
547 ._M_iterator(__first,
"first")
548 ._M_iterator(__last,
"last"));
554 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
558 #ifdef __GXX_EXPERIMENTAL_CXX0X__
561 { splice(__position, std::move(__x), __first, __last); }
565 remove(
const _Tp& __value)
576 template<
class _Predicate>
578 remove_if(_Predicate __pred)
594 if (__first == __last)
597 while (__next != __last)
599 if (*__first == *__next)
600 __next = _M_erase(__next);
606 template<
class _BinaryPredicate>
608 unique(_BinaryPredicate __binary_pred)
612 if (__first == __last)
615 while (__next != __last)
617 if (__binary_pred(*__first, *__next))
618 __next = _M_erase(__next);
625 #ifdef __GXX_EXPERIMENTAL_CXX0X__
635 __glibcxx_check_sorted(_Base::begin(), _Base::end());
636 __glibcxx_check_sorted(__x.begin().
base(), __x.end().
base());
638 _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
642 #ifdef __GXX_EXPERIMENTAL_CXX0X__
645 { merge(std::move(__x)); }
648 template<
class _Compare>
650 #ifdef __GXX_EXPERIMENTAL_CXX0X__
651 merge(
list&& __x, _Compare __comp)
653 merge(
list& __x, _Compare __comp)
665 _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
669 #ifdef __GXX_EXPERIMENTAL_CXX0X__
670 template<
typename _Compare>
672 merge(
list& __x, _Compare __comp)
673 { merge(std::move(__x), __comp); }
677 sort() { _Base::sort(); }
679 template<
typename _StrictWeakOrdering>
681 sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
683 using _Base::reverse;
686 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
689 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
699 template<
typename _Tp,
typename _Alloc>
703 {
return __lhs._M_base() == __rhs._M_base(); }
705 template<
typename _Tp,
typename _Alloc>
709 {
return __lhs._M_base() != __rhs._M_base(); }
711 template<
typename _Tp,
typename _Alloc>
713 operator<(const list<_Tp, _Alloc>& __lhs,
714 const list<_Tp, _Alloc>& __rhs)
715 {
return __lhs._M_base() < __rhs._M_base(); }
717 template<
typename _Tp,
typename _Alloc>
719 operator<=(const list<_Tp, _Alloc>& __lhs,
720 const list<_Tp, _Alloc>& __rhs)
721 {
return __lhs._M_base() <= __rhs._M_base(); }
723 template<
typename _Tp,
typename _Alloc>
725 operator>=(
const list<_Tp, _Alloc>& __lhs,
726 const list<_Tp, _Alloc>& __rhs)
727 {
return __lhs._M_base() >= __rhs._M_base(); }
729 template<
typename _Tp,
typename _Alloc>
731 operator>(
const list<_Tp, _Alloc>& __lhs,
732 const list<_Tp, _Alloc>& __rhs)
733 {
return __lhs._M_base() > __rhs._M_base(); }
735 template<
typename _Tp,
typename _Alloc>
737 swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
738 { __lhs.swap(__rhs); }
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
void _M_revalidate_singular()
#define __glibcxx_check_erase_range(_First, _Last)
void _M_swap(_Safe_sequence_base &__x)
void _M_invalidate_if(_Predicate __pred)
_Iterator base() const
Return the underlying iterator.
#define __glibcxx_check_erase(_Position)
void _M_detach_singular()
Class std::list with safety/checking/debug instrumentation.
void _M_transfer_from_if(_Safe_sequence &__from, _Predicate __pred)
bool _M_attached_to(const _Safe_sequence_base *__seq) const
#define __glibcxx_check_insert_range(_Position, _First, _Last)
#define __glibcxx_check_insert(_Position)
bool _M_dereferenceable() const
Is the iterator dereferenceable?
Base class for constructing a safe sequence type that tracks iterators that reference it...
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
#define __glibcxx_check_sorted_pred(_First, _Last, _Pred)
constexpr size_t size() const _GLIBCXX_NOEXCEPT
Returns the total number of bits.