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;
55 typedef typename _Base::reference reference;
56 typedef typename _Base::const_reference const_reference;
63 typedef typename _Base::size_type size_type;
64 typedef typename _Base::difference_type difference_type;
66 typedef _Tp value_type;
67 typedef _Allocator allocator_type;
68 typedef typename _Base::pointer pointer;
69 typedef typename _Base::const_pointer const_pointer;
75 list(
const _Allocator& __a = _Allocator())
78 #ifdef __GXX_EXPERIMENTAL_CXX0X__
83 list(size_type __n,
const _Tp& __value,
84 const _Allocator& __a = _Allocator())
85 :
_Base(__n, __value, __a) { }
88 list(size_type __n,
const _Tp& __value = _Tp(),
89 const _Allocator& __a = _Allocator())
90 :
_Base(__n, __value, __a) { }
93 template<
class _InputIterator>
94 list(_InputIterator __first, _InputIterator __last,
95 const _Allocator& __a = _Allocator())
108 #ifdef __GXX_EXPERIMENTAL_CXX0X__
114 const allocator_type& __a = allocator_type())
121 operator=(
const list& __x)
123 static_cast<_Base&
>(*this) = __x;
124 this->_M_invalidate_all();
128 #ifdef __GXX_EXPERIMENTAL_CXX0X__
130 operator=(
list&& __x)
142 static_cast<_Base&
>(*this) = __l;
143 this->_M_invalidate_all();
151 this->_M_invalidate_all();
155 template<
class _InputIterator>
157 assign(_InputIterator __first, _InputIterator __last)
159 __glibcxx_check_valid_range(__first, __last);
162 this->_M_invalidate_all();
166 assign(size_type __n,
const _Tp& __t)
168 _Base::assign(__n, __t);
169 this->_M_invalidate_all();
172 using _Base::get_allocator;
177 {
return iterator(_Base::begin(),
this); }
185 {
return iterator(_Base::end(),
this); }
207 #ifdef __GXX_EXPERIMENTAL_CXX0X__
228 using _Base::max_size;
230 #ifdef __GXX_EXPERIMENTAL_CXX0X__
232 resize(size_type __sz)
239 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
242 for (; __victim != __end; ++__victim)
254 __throw_exception_again;
259 resize(size_type __sz,
const _Tp& __c)
266 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
269 for (; __victim != __end; ++__victim)
276 _Base::resize(__sz, __c);
281 __throw_exception_again;
286 resize(size_type __sz, _Tp __c = _Tp())
293 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
296 for (; __victim != __end; ++__victim)
303 _Base::resize(__sz, __c);
308 __throw_exception_again;
317 __glibcxx_check_nonempty();
318 return _Base::front();
324 __glibcxx_check_nonempty();
325 return _Base::front();
331 __glibcxx_check_nonempty();
332 return _Base::back();
338 __glibcxx_check_nonempty();
339 return _Base::back();
343 using _Base::push_front;
345 #ifdef __GXX_EXPERIMENTAL_CXX0X__
346 using _Base::emplace_front;
352 __glibcxx_check_nonempty();
357 using _Base::push_back;
359 #ifdef __GXX_EXPERIMENTAL_CXX0X__
360 using _Base::emplace_back;
366 __glibcxx_check_nonempty();
371 #ifdef __GXX_EXPERIMENTAL_CXX0X__
372 template<
typename... _Args>
374 emplace(
iterator __position, _Args&&... __args)
378 std::forward<_Args>(__args)...),
this);
383 insert(
iterator __position,
const _Tp& __x)
386 return iterator(_Base::insert(__position.
base(), __x),
this);
389 #ifdef __GXX_EXPERIMENTAL_CXX0X__
391 insert(
iterator __position, _Tp&& __x)
392 {
return emplace(__position, std::move(__x)); }
398 _Base::insert(__p, __l);
403 insert(
iterator __position, size_type __n,
const _Tp& __x)
406 _Base::insert(__position.
base(), __n, __x);
409 template<
class _InputIterator>
411 insert(
iterator __position, _InputIterator __first,
412 _InputIterator __last)
424 return _Base::erase(__position);
441 __victim != __last.
base(); ++__victim)
444 _M_message(__gnu_debug::__msg_valid_range)
445 ._M_iterator(__position,
"position")
446 ._M_iterator(__last,
"last"));
463 this->_M_invalidate_all();
468 #ifdef __GXX_EXPERIMENTAL_CXX0X__
475 _M_message(__gnu_debug::__msg_self_splice)
476 ._M_sequence(*
this,
"this"));
478 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()));
481 #ifdef __GXX_EXPERIMENTAL_CXX0X__
484 { splice(__position, std::move(__x)); }
488 #ifdef __GXX_EXPERIMENTAL_CXX0X__
500 _M_message(__gnu_debug::__msg_splice_bad)
501 ._M_iterator(__i,
"__i"));
503 _M_message(__gnu_debug::__msg_splice_other)
504 ._M_iterator(__i,
"__i")._M_sequence(__x,
"__x"));
509 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
513 #ifdef __GXX_EXPERIMENTAL_CXX0X__
516 { splice(__position, std::move(__x), __i); }
520 #ifdef __GXX_EXPERIMENTAL_CXX0X__
529 __glibcxx_check_valid_range(__first, __last);
531 _M_message(__gnu_debug::__msg_splice_other)
532 ._M_sequence(__x,
"x")
533 ._M_iterator(__first,
"first"));
539 __tmp != __last.
base(); ++__tmp)
542 _M_message(__gnu_debug::__msg_valid_range)
543 ._M_iterator(__first,
"first")
544 ._M_iterator(__last,
"last"));
546 _M_message(__gnu_debug::__msg_splice_overlap)
547 ._M_iterator(__tmp,
"position")
548 ._M_iterator(__first,
"first")
549 ._M_iterator(__last,
"last"));
555 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
559 #ifdef __GXX_EXPERIMENTAL_CXX0X__
562 { splice(__position, std::move(__x), __first, __last); }
566 remove(
const _Tp& __value)
577 template<
class _Predicate>
579 remove_if(_Predicate __pred)
595 if (__first == __last)
598 while (__next != __last)
600 if (*__first == *__next)
601 __next = _M_erase(__next);
607 template<
class _BinaryPredicate>
609 unique(_BinaryPredicate __binary_pred)
613 if (__first == __last)
616 while (__next != __last)
618 if (__binary_pred(*__first, *__next))
619 __next = _M_erase(__next);
626 #ifdef __GXX_EXPERIMENTAL_CXX0X__
636 __glibcxx_check_sorted(_Base::begin(), _Base::end());
637 __glibcxx_check_sorted(__x.begin().
base(), __x.end().
base());
639 _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
643 #ifdef __GXX_EXPERIMENTAL_CXX0X__
646 { merge(std::move(__x)); }
649 template<
class _Compare>
651 #ifdef __GXX_EXPERIMENTAL_CXX0X__
652 merge(
list&& __x, _Compare __comp)
654 merge(
list& __x, _Compare __comp)
666 _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
670 #ifdef __GXX_EXPERIMENTAL_CXX0X__
671 template<
typename _Compare>
673 merge(
list& __x, _Compare __comp)
674 { merge(std::move(__x), __comp); }
678 sort() { _Base::sort(); }
680 template<
typename _StrictWeakOrdering>
682 sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
684 using _Base::reverse;
687 _M_base() {
return *
this; }
690 _M_base()
const {
return *
this; }
700 template<
typename _Tp,
typename _Alloc>
704 {
return __lhs._M_base() == __rhs._M_base(); }
706 template<
typename _Tp,
typename _Alloc>
710 {
return __lhs._M_base() != __rhs._M_base(); }
712 template<
typename _Tp,
typename _Alloc>
714 operator<(const list<_Tp, _Alloc>& __lhs,
715 const list<_Tp, _Alloc>& __rhs)
716 {
return __lhs._M_base() < __rhs._M_base(); }
718 template<
typename _Tp,
typename _Alloc>
720 operator<=(const list<_Tp, _Alloc>& __lhs,
721 const list<_Tp, _Alloc>& __rhs)
722 {
return __lhs._M_base() <= __rhs._M_base(); }
724 template<
typename _Tp,
typename _Alloc>
726 operator>=(
const list<_Tp, _Alloc>& __lhs,
727 const list<_Tp, _Alloc>& __rhs)
728 {
return __lhs._M_base() >= __rhs._M_base(); }
730 template<
typename _Tp,
typename _Alloc>
732 operator>(
const list<_Tp, _Alloc>& __lhs,
733 const list<_Tp, _Alloc>& __rhs)
734 {
return __lhs._M_base() > __rhs._M_base(); }
736 template<
typename _Tp,
typename _Alloc>
738 swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
739 { __lhs.swap(__rhs); }
#define __glibcxx_check_insert_range(_Position, _First, _Last)
void _M_swap(_Safe_sequence_base &__x)
#define __glibcxx_check_insert(_Position)
void _M_detach_singular()
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_sorted_pred(_First, _Last, _Pred)
Class std::list with safety/checking/debug instrumentation.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
constexpr size_t size() const
Returns the total number of bits.
bool _M_dereferenceable() const
Is the iterator dereferenceable?
#define __glibcxx_check_erase(_Position)
void _M_revalidate_singular()
bool _M_attached_to(const _Safe_sequence_base *__seq) const
Base class for constructing a safe sequence type that tracks iterators that reference it...
#define _GLIBCXX_DEBUG_VERIFY(_Condition, _ErrorMessage)
_Iterator base() const
Return the underlying iterator.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
void _M_transfer_from_if(_Safe_sequence &__from, _Predicate __pred)
#define __glibcxx_check_erase_range(_First, _Last)