29 #ifndef _GLIBCXX_DEBUG_LIST
30 #define _GLIBCXX_DEBUG_LIST 1
36 namespace std _GLIBCXX_VISIBILITY(default)
41 template<
typename _Tp,
typename _Allocator = std::allocator<_Tp> >
43 :
public _GLIBCXX_STD_C::list<_Tp, _Allocator>,
46 typedef _GLIBCXX_STD_C::list<_Tp, _Allocator>
_Base;
53 typedef typename _Base::reference reference;
54 typedef typename _Base::const_reference const_reference;
61 typedef typename _Base::size_type size_type;
62 typedef typename _Base::difference_type difference_type;
64 typedef _Tp value_type;
65 typedef _Allocator allocator_type;
66 typedef typename _Base::pointer pointer;
67 typedef typename _Base::const_pointer const_pointer;
73 list(
const _Allocator& __a = _Allocator()) _GLIBCXX_NOEXCEPT
76 #if __cplusplus >= 201103L
81 list(size_type __n,
const _Tp& __value,
82 const _Allocator& __a = _Allocator())
83 :
_Base(__n, __value, __a) { }
86 list(size_type __n,
const _Tp& __value = _Tp(),
87 const _Allocator& __a = _Allocator())
88 :
_Base(__n, __value, __a) { }
91 #if __cplusplus >= 201103L
92 template<
class _InputIterator,
93 typename = std::_RequireInputIter<_InputIterator>>
95 template<
class _InputIterator>
97 list(_InputIterator __first, _InputIterator __last,
98 const _Allocator& __a = _Allocator())
104 list(
const list& __x)
107 list(
const _Base& __x)
110 #if __cplusplus >= 201103L
111 list(list&& __x) noexcept
112 :
_Base(std::move(__x))
116 const allocator_type& __a = allocator_type())
117 :
_Base(__l, __a) { }
120 ~list() _GLIBCXX_NOEXCEPT { }
123 operator=(
const list& __x)
125 static_cast<_Base&
>(*this) = __x;
126 this->_M_invalidate_all();
130 #if __cplusplus >= 201103L
132 operator=(list&& __x)
136 __glibcxx_check_self_move_assign(__x);
145 static_cast<_Base&
>(*this) = __l;
146 this->_M_invalidate_all();
154 this->_M_invalidate_all();
158 #if __cplusplus >= 201103L
159 template<
class _InputIterator,
160 typename = std::_RequireInputIter<_InputIterator>>
162 template<
class _InputIterator>
165 assign(_InputIterator __first, _InputIterator __last)
167 __glibcxx_check_valid_range(__first, __last);
170 this->_M_invalidate_all();
174 assign(size_type __n,
const _Tp& __t)
176 _Base::assign(__n, __t);
177 this->_M_invalidate_all();
180 using _Base::get_allocator;
184 begin() _GLIBCXX_NOEXCEPT
185 {
return iterator(_Base::begin(),
this); }
188 begin()
const _GLIBCXX_NOEXCEPT
192 end() _GLIBCXX_NOEXCEPT
193 {
return iterator(_Base::end(),
this); }
196 end()
const _GLIBCXX_NOEXCEPT
200 rbegin() _GLIBCXX_NOEXCEPT
204 rbegin()
const _GLIBCXX_NOEXCEPT
208 rend() _GLIBCXX_NOEXCEPT
212 rend()
const _GLIBCXX_NOEXCEPT
215 #if __cplusplus >= 201103L
217 cbegin()
const noexcept
221 cend()
const noexcept
225 crbegin()
const noexcept
229 crend()
const noexcept
236 using _Base::max_size;
238 #if __cplusplus >= 201103L
240 resize(size_type __sz)
247 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
250 for (; __victim != __end; ++__victim)
262 __throw_exception_again;
267 resize(size_type __sz,
const _Tp& __c)
274 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
277 for (; __victim != __end; ++__victim)
284 _Base::resize(__sz, __c);
289 __throw_exception_again;
294 resize(size_type __sz, _Tp __c = _Tp())
301 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
304 for (; __victim != __end; ++__victim)
311 _Base::resize(__sz, __c);
316 __throw_exception_again;
323 front() _GLIBCXX_NOEXCEPT
325 __glibcxx_check_nonempty();
326 return _Base::front();
330 front()
const _GLIBCXX_NOEXCEPT
332 __glibcxx_check_nonempty();
333 return _Base::front();
337 back() _GLIBCXX_NOEXCEPT
339 __glibcxx_check_nonempty();
340 return _Base::back();
344 back()
const _GLIBCXX_NOEXCEPT
346 __glibcxx_check_nonempty();
347 return _Base::back();
351 using _Base::push_front;
353 #if __cplusplus >= 201103L
354 using _Base::emplace_front;
358 pop_front() _GLIBCXX_NOEXCEPT
360 __glibcxx_check_nonempty();
365 using _Base::push_back;
367 #if __cplusplus >= 201103L
368 using _Base::emplace_back;
372 pop_back() _GLIBCXX_NOEXCEPT
374 __glibcxx_check_nonempty();
379 #if __cplusplus >= 201103L
380 template<
typename... _Args>
386 std::forward<_Args>(__args)...),
this);
391 #if __cplusplus >= 201103L
394 insert(
iterator __position,
const _Tp& __x)
398 return iterator(_Base::insert(__position.
base(), __x),
this);
401 #if __cplusplus >= 201103L
404 {
return emplace(__position, std::move(__x)); }
414 #if __cplusplus >= 201103L
419 return iterator(_Base::insert(__position.
base(), __n, __x),
this);
423 insert(
iterator __position, size_type __n,
const _Tp& __x)
426 _Base::insert(__position.
base(), __n, __x);
430 #if __cplusplus >= 201103L
431 template<
class _InputIterator,
432 typename = std::_RequireInputIter<_InputIterator>>
435 _InputIterator __last)
444 template<
class _InputIterator>
446 insert(
iterator __position, _InputIterator __first,
447 _InputIterator __last)
457 #if __cplusplus >= 201103L
464 return _Base::erase(__position);
469 #if __cplusplus >= 201103L
480 #if __cplusplus >= 201103L
490 __victim != __last.
base(); ++__victim)
492 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
493 _M_message(__gnu_debug::__msg_valid_range)
494 ._M_iterator(__first,
"position")
495 ._M_iterator(__last,
"last"));
509 clear() _GLIBCXX_NOEXCEPT
512 this->_M_invalidate_all();
517 #if __cplusplus >= 201103L
520 splice(
iterator __position, list& __x)
523 _GLIBCXX_DEBUG_VERIFY(&__x !=
this,
524 _M_message(__gnu_debug::__msg_self_splice)
525 ._M_sequence(*
this,
"this"));
527 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()));
530 #if __cplusplus >= 201103L
533 { splice(__position, std::move(__x)); }
537 #if __cplusplus >= 201103L
549 _M_message(__gnu_debug::__msg_splice_bad)
550 ._M_iterator(__i,
"__i"));
552 _M_message(__gnu_debug::__msg_splice_other)
553 ._M_iterator(__i,
"__i")._M_sequence(__x,
"__x"));
558 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
562 #if __cplusplus >= 201103L
565 { splice(__position, std::move(__x), __i); }
569 #if __cplusplus >= 201103L
578 __glibcxx_check_valid_range(__first, __last);
580 _M_message(__gnu_debug::__msg_splice_other)
581 ._M_sequence(__x,
"x")
582 ._M_iterator(__first,
"first"));
588 __tmp != __last.
base(); ++__tmp)
590 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
591 _M_message(__gnu_debug::__msg_valid_range)
592 ._M_iterator(__first,
"first")
593 ._M_iterator(__last,
"last"));
594 _GLIBCXX_DEBUG_VERIFY(&__x !=
this || __tmp != __position.
base(),
595 _M_message(__gnu_debug::__msg_splice_overlap)
596 ._M_iterator(__tmp,
"position")
597 ._M_iterator(__first,
"first")
598 ._M_iterator(__last,
"last"));
604 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
608 #if __cplusplus >= 201103L
612 { splice(__position, std::move(__x), __first, __last); }
616 remove(
const _Tp& __value)
627 template<
class _Predicate>
629 remove_if(_Predicate __pred)
645 if (__first == __last)
648 while (__next != __last)
650 if (*__first == *__next)
651 __next = _M_erase(__next);
657 template<
class _BinaryPredicate>
659 unique(_BinaryPredicate __binary_pred)
663 if (__first == __last)
666 while (__next != __last)
668 if (__binary_pred(*__first, *__next))
669 __next = _M_erase(__next);
676 #if __cplusplus >= 201103L
686 __glibcxx_check_sorted(_Base::begin(), _Base::end());
687 __glibcxx_check_sorted(__x.begin().
base(), __x.end().
base());
689 _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
693 #if __cplusplus >= 201103L
696 { merge(std::move(__x)); }
699 template<
class _Compare>
701 #if __cplusplus >= 201103L
702 merge(list&& __x, _Compare __comp)
704 merge(list& __x, _Compare __comp)
716 _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
720 #if __cplusplus >= 201103L
721 template<
typename _Compare>
723 merge(list& __x, _Compare __comp)
724 { merge(std::move(__x), __comp); }
728 sort() { _Base::sort(); }
730 template<
typename _StrictWeakOrdering>
732 sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
734 using _Base::reverse;
737 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
740 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
750 template<
typename _Tp,
typename _Alloc>
754 {
return __lhs._M_base() == __rhs._M_base(); }
756 template<
typename _Tp,
typename _Alloc>
760 {
return __lhs._M_base() != __rhs._M_base(); }
762 template<
typename _Tp,
typename _Alloc>
764 operator<(const list<_Tp, _Alloc>& __lhs,
765 const list<_Tp, _Alloc>& __rhs)
766 {
return __lhs._M_base() < __rhs._M_base(); }
768 template<
typename _Tp,
typename _Alloc>
770 operator<=(const list<_Tp, _Alloc>& __lhs,
771 const list<_Tp, _Alloc>& __rhs)
772 {
return __lhs._M_base() <= __rhs._M_base(); }
774 template<
typename _Tp,
typename _Alloc>
776 operator>=(
const list<_Tp, _Alloc>& __lhs,
777 const list<_Tp, _Alloc>& __rhs)
778 {
return __lhs._M_base() >= __rhs._M_base(); }
780 template<
typename _Tp,
typename _Alloc>
782 operator>(
const list<_Tp, _Alloc>& __lhs,
783 const list<_Tp, _Alloc>& __rhs)
784 {
return __lhs._M_base() > __rhs._M_base(); }
786 template<
typename _Tp,
typename _Alloc>
788 swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
789 { __lhs.swap(__rhs); }
794 #ifndef _GLIBCXX_DEBUG_PEDANTIC
795 namespace __gnu_debug
797 template<
class _Tp,
class _Alloc>
798 struct _Insert_range_from_self_is_safe<std::__debug::list<_Tp, _Alloc> >
799 {
enum { __value = 1 }; };
void _M_revalidate_singular()
#define __glibcxx_check_insert_range(_Position, _First, _Last)
void _M_swap(_Safe_sequence_base &__x)
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_insert(_Position)
void _M_detach_singular()
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
constexpr size_t size() const noexcept
Returns the total number of bits.
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
_Iterator base() const noexcept
Return the underlying iterator.
#define __glibcxx_check_erase(_Position)
#define __glibcxx_check_sorted_pred(_First, _Last, _Pred)
bool _M_dereferenceable() const
Is the iterator dereferenceable?
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
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)