29 #ifndef _GLIBCXX_DEBUG_LIST
30 #define _GLIBCXX_DEBUG_LIST 1
37 namespace std _GLIBCXX_VISIBILITY(default)
42 template<
typename _Tp,
typename _Allocator = std::allocator<_Tp> >
45 list<_Tp, _Allocator>, _Allocator,
46 __gnu_debug::_Safe_node_sequence, false>,
47 public _GLIBCXX_STD_C::list<_Tp, _Allocator>
49 typedef _GLIBCXX_STD_C::list<_Tp, _Allocator>
_Base;
59 typedef typename _Base::reference reference;
60 typedef typename _Base::const_reference const_reference;
67 typedef typename _Base::size_type size_type;
68 typedef typename _Base::difference_type difference_type;
70 typedef _Tp value_type;
71 typedef _Allocator allocator_type;
72 typedef typename _Base::pointer pointer;
73 typedef typename _Base::const_pointer const_pointer;
79 #if __cplusplus < 201103L
93 const allocator_type& __a = allocator_type())
100 list(
const _Allocator& __a) _GLIBCXX_NOEXCEPT
103 #if __cplusplus >= 201103L
108 list(size_type __n,
const _Tp& __value,
109 const _Allocator& __a = _Allocator())
110 :
_Base(__n, __value, __a) { }
113 list(size_type __n,
const _Tp& __value = _Tp(),
114 const _Allocator& __a = _Allocator())
115 :
_Base(__n, __value, __a) { }
118 #if __cplusplus >= 201103L
119 template<
class _InputIterator,
120 typename = std::_RequireInputIter<_InputIterator>>
122 template<
class _InputIterator>
124 list(_InputIterator __first, _InputIterator __last,
125 const _Allocator& __a = _Allocator())
131 list(
const _Base& __x)
134 #if __cplusplus < 201103L
136 operator=(
const list& __x)
138 this->_M_safe() = __x;
144 operator=(
const list&) =
default;
147 operator=(list&&) =
default;
152 this->_M_invalidate_all();
161 this->_M_invalidate_all();
165 #if __cplusplus >= 201103L
166 template<
class _InputIterator,
167 typename = std::_RequireInputIter<_InputIterator>>
169 template<
class _InputIterator>
172 assign(_InputIterator __first, _InputIterator __last)
174 __glibcxx_check_valid_range(__first, __last);
177 this->_M_invalidate_all();
181 assign(size_type __n,
const _Tp& __t)
183 _Base::assign(__n, __t);
184 this->_M_invalidate_all();
187 using _Base::get_allocator;
191 begin() _GLIBCXX_NOEXCEPT
192 {
return iterator(_Base::begin(),
this); }
195 begin()
const _GLIBCXX_NOEXCEPT
199 end() _GLIBCXX_NOEXCEPT
200 {
return iterator(_Base::end(),
this); }
203 end()
const _GLIBCXX_NOEXCEPT
207 rbegin() _GLIBCXX_NOEXCEPT
211 rbegin()
const _GLIBCXX_NOEXCEPT
215 rend() _GLIBCXX_NOEXCEPT
219 rend()
const _GLIBCXX_NOEXCEPT
222 #if __cplusplus >= 201103L
224 cbegin()
const noexcept
228 cend()
const noexcept
232 crbegin()
const noexcept
236 crend()
const noexcept
243 using _Base::max_size;
245 #if __cplusplus >= 201103L
247 resize(size_type __sz)
254 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
257 for (; __victim != __end; ++__victim)
267 __throw_exception_again;
272 resize(size_type __sz,
const _Tp& __c)
279 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
282 for (; __victim != __end; ++__victim)
287 _Base::resize(__sz, __c);
292 __throw_exception_again;
297 resize(size_type __sz, _Tp __c = _Tp())
304 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
307 for (; __victim != __end; ++__victim)
312 _Base::resize(__sz, __c);
317 __throw_exception_again;
324 front() _GLIBCXX_NOEXCEPT
326 __glibcxx_check_nonempty();
327 return _Base::front();
331 front()
const _GLIBCXX_NOEXCEPT
333 __glibcxx_check_nonempty();
334 return _Base::front();
338 back() _GLIBCXX_NOEXCEPT
340 __glibcxx_check_nonempty();
341 return _Base::back();
345 back()
const _GLIBCXX_NOEXCEPT
347 __glibcxx_check_nonempty();
348 return _Base::back();
352 using _Base::push_front;
354 #if __cplusplus >= 201103L
355 using _Base::emplace_front;
359 pop_front() _GLIBCXX_NOEXCEPT
361 __glibcxx_check_nonempty();
366 using _Base::push_back;
368 #if __cplusplus >= 201103L
369 using _Base::emplace_back;
373 pop_back() _GLIBCXX_NOEXCEPT
375 __glibcxx_check_nonempty();
380 #if __cplusplus >= 201103L
381 template<
typename... _Args>
387 std::forward<_Args>(__args)...),
this);
392 #if __cplusplus >= 201103L
395 insert(
iterator __position,
const _Tp& __x)
399 return iterator(_Base::insert(__position.
base(), __x),
this);
402 #if __cplusplus >= 201103L
405 {
return emplace(__position, std::move(__x)); }
415 #if __cplusplus >= 201103L
420 return iterator(_Base::insert(__position.
base(), __n, __x),
this);
424 insert(
iterator __position, size_type __n,
const _Tp& __x)
427 _Base::insert(__position.
base(), __n, __x);
431 #if __cplusplus >= 201103L
432 template<
class _InputIterator,
433 typename = std::_RequireInputIter<_InputIterator>>
436 _InputIterator __last)
445 template<
class _InputIterator>
447 insert(
iterator __position, _InputIterator __first,
448 _InputIterator __last)
458 #if __cplusplus >= 201103L
465 return _Base::erase(__position);
470 #if __cplusplus >= 201103L
481 #if __cplusplus >= 201103L
491 __victim != __last.
base(); ++__victim)
493 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
494 _M_message(__gnu_debug::__msg_valid_range)
495 ._M_iterator(__first,
"position")
496 ._M_iterator(__last,
"last"));
504 #if __cplusplus >= 201103L
505 noexcept( noexcept(declval<_Base>().
swap(__x)) )
513 clear() _GLIBCXX_NOEXCEPT
516 this->_M_invalidate_all();
521 #if __cplusplus >= 201103L
524 splice(
iterator __position, list& __x)
527 _GLIBCXX_DEBUG_VERIFY(&__x !=
this,
528 _M_message(__gnu_debug::__msg_self_splice)
529 ._M_sequence(*
this,
"this"));
531 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()));
534 #if __cplusplus >= 201103L
537 { splice(__position, std::move(__x)); }
541 #if __cplusplus >= 201103L
553 _M_message(__gnu_debug::__msg_splice_bad)
554 ._M_iterator(__i,
"__i"));
556 _M_message(__gnu_debug::__msg_splice_other)
557 ._M_iterator(__i,
"__i")._M_sequence(__x,
"__x"));
562 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
566 #if __cplusplus >= 201103L
569 { splice(__position, std::move(__x), __i); }
573 #if __cplusplus >= 201103L
582 __glibcxx_check_valid_range(__first, __last);
584 _M_message(__gnu_debug::__msg_splice_other)
585 ._M_sequence(__x,
"x")
586 ._M_iterator(__first,
"first"));
592 __tmp != __last.
base(); ++__tmp)
594 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
595 _M_message(__gnu_debug::__msg_valid_range)
596 ._M_iterator(__first,
"first")
597 ._M_iterator(__last,
"last"));
598 _GLIBCXX_DEBUG_VERIFY(&__x !=
this || __tmp != __position.
base(),
599 _M_message(__gnu_debug::__msg_splice_overlap)
600 ._M_iterator(__tmp,
"position")
601 ._M_iterator(__first,
"first")
602 ._M_iterator(__last,
"last"));
608 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
612 #if __cplusplus >= 201103L
616 { splice(__position, std::move(__x), __first, __last); }
620 remove(
const _Tp& __value)
631 template<
class _Predicate>
633 remove_if(_Predicate __pred)
649 if (__first == __last)
652 while (__next != __last)
654 if (*__first == *__next)
655 __next = _M_erase(__next);
661 template<
class _BinaryPredicate>
663 unique(_BinaryPredicate __binary_pred)
667 if (__first == __last)
670 while (__next != __last)
672 if (__binary_pred(*__first, *__next))
673 __next = _M_erase(__next);
680 #if __cplusplus >= 201103L
690 __glibcxx_check_sorted(_Base::begin(), _Base::end());
691 __glibcxx_check_sorted(__x.begin().
base(), __x.end().
base());
693 _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
697 #if __cplusplus >= 201103L
700 { merge(std::move(__x)); }
703 template<
class _Compare>
705 #if __cplusplus >= 201103L
706 merge(list&& __x, _Compare __comp)
708 merge(list& __x, _Compare __comp)
720 _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
724 #if __cplusplus >= 201103L
725 template<
typename _Compare>
727 merge(list& __x, _Compare __comp)
728 { merge(std::move(__x), __comp); }
732 sort() { _Base::sort(); }
734 template<
typename _StrictWeakOrdering>
736 sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
738 using _Base::reverse;
741 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
744 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
747 template<
typename _Tp,
typename _Alloc>
751 {
return __lhs._M_base() == __rhs._M_base(); }
753 template<
typename _Tp,
typename _Alloc>
757 {
return __lhs._M_base() != __rhs._M_base(); }
759 template<
typename _Tp,
typename _Alloc>
761 operator<(const list<_Tp, _Alloc>& __lhs,
762 const list<_Tp, _Alloc>& __rhs)
763 {
return __lhs._M_base() < __rhs._M_base(); }
765 template<
typename _Tp,
typename _Alloc>
767 operator<=(const list<_Tp, _Alloc>& __lhs,
768 const list<_Tp, _Alloc>& __rhs)
769 {
return __lhs._M_base() <= __rhs._M_base(); }
771 template<
typename _Tp,
typename _Alloc>
773 operator>=(
const list<_Tp, _Alloc>& __lhs,
774 const list<_Tp, _Alloc>& __rhs)
775 {
return __lhs._M_base() >= __rhs._M_base(); }
777 template<
typename _Tp,
typename _Alloc>
779 operator>(
const list<_Tp, _Alloc>& __lhs,
780 const list<_Tp, _Alloc>& __rhs)
781 {
return __lhs._M_base() > __rhs._M_base(); }
783 template<
typename _Tp,
typename _Alloc>
785 swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
786 { __lhs.swap(__rhs); }
791 #ifndef _GLIBCXX_DEBUG_PEDANTIC
792 namespace __gnu_debug
794 template<
class _Tp,
class _Alloc>
795 struct _Insert_range_from_self_is_safe<std::__debug::list<_Tp, _Alloc> >
796 {
enum { __value = 1 }; };
bool _M_dereferenceable() const
Is the iterator dereferenceable?
void _M_revalidate_singular()
_Iterator & base() noexcept
Return the underlying iterator.
bool _M_attached_to(const _Safe_sequence_base *__seq) const
void _M_invalidate_if(_Predicate __pred)
Class std::list with safety/checking/debug instrumentation.
#define __glibcxx_check_erase_range(_First, _Last)
void _M_detach_singular()
#define __glibcxx_check_sorted_pred(_First, _Last, _Pred)
#define __glibcxx_check_erase(_Position)
void _M_transfer_from_if(_Safe_sequence &__from, _Predicate __pred)
#define __glibcxx_check_insert_range(_Position, _First, _Last)
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
Safe class dealing with some allocator dependent operations.
#define __glibcxx_check_insert(_Position)
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
void swap(basic_filebuf< _CharT, _Traits > &__x, basic_filebuf< _CharT, _Traits > &__y)
Swap specialization for filebufs.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)