52 list<_Tp, _Allocator>, _Allocator,
53 __gnu_debug::_Safe_node_sequence>,
54 public _GLIBCXX_STD_C::list<_Tp, _Allocator>
56 typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base;
60 typedef typename _Base::iterator _Base_iterator;
61 typedef typename _Base::const_iterator _Base_const_iterator;
65 template<
typename _ItT,
typename _SeqT,
typename _CatT>
66 friend class ::__gnu_debug::_Safe_iterator;
73 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
79 typedef typename _Base::reference reference;
80 typedef typename _Base::const_reference const_reference;
87 typedef typename _Base::size_type size_type;
88 typedef typename _Base::difference_type difference_type;
90 typedef _Tp value_type;
91 typedef _Allocator allocator_type;
92 typedef typename _Base::pointer pointer;
93 typedef typename _Base::const_pointer const_pointer;
99#if __cplusplus < 201103L
103 list(
const list& __x)
109 list(
const list&) =
default;
110 list(list&&) =
default;
113 const allocator_type& __a = allocator_type())
114 : _Base(__l, __a) { }
118 list(
const list& __x,
const allocator_type& __a)
119 : _Base(__x, __a) { }
121 list(list&& __x,
const allocator_type& __a)
124 _Base,
const allocator_type&>::value )
130 list(
const _Allocator& __a) _GLIBCXX_NOEXCEPT
133#if __cplusplus >= 201103L
135 list(size_type __n,
const allocator_type& __a = allocator_type())
136 : _Base(__n, __a) { }
138 list(size_type __n,
const __type_identity_t<_Tp>& __value,
139 const _Allocator& __a = _Allocator())
140 : _Base(__n, __value, __a) { }
143 list(size_type __n,
const _Tp& __value = _Tp(),
144 const _Allocator& __a = _Allocator())
145 : _Base(__n, __value, __a) { }
148#if __cplusplus >= 201103L
149 template<
class _InputIterator,
150 typename = std::_RequireInputIter<_InputIterator>>
152 template<
class _InputIterator>
154 list(_InputIterator __first, _InputIterator __last,
155 const _Allocator& __a = _Allocator())
157 __glibcxx_check_valid_constructor_range(__first, __last)),
162 : _Base(__x._M_ref) { }
164#if __cplusplus < 201103L
166 operator=(
const list& __x)
168 this->_M_safe() = __x;
174 operator=(
const list&) =
default;
177 operator=(list&&) =
default;
182 this->_M_invalidate_all();
191 this->_M_invalidate_all();
195#if __cplusplus >= 201103L
196 template<
class _InputIterator,
197 typename = std::_RequireInputIter<_InputIterator>>
199 template<
class _InputIterator>
202 assign(_InputIterator __first, _InputIterator __last)
204 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
205 __glibcxx_check_valid_range2(__first, __last, __dist);
207 if (__dist.second >= __gnu_debug::__dp_sign)
208 _Base::assign(__gnu_debug::__unsafe(__first),
209 __gnu_debug::__unsafe(__last));
211 _Base::assign(__first, __last);
213 this->_M_invalidate_all();
217 assign(size_type __n,
const _Tp& __t)
219 _Base::assign(__n, __t);
220 this->_M_invalidate_all();
223 using _Base::get_allocator;
227 begin() _GLIBCXX_NOEXCEPT
228 {
return iterator(_Base::begin(),
this); }
231 begin()
const _GLIBCXX_NOEXCEPT
232 {
return const_iterator(_Base::begin(),
this); }
235 end() _GLIBCXX_NOEXCEPT
236 {
return iterator(_Base::end(),
this); }
239 end()
const _GLIBCXX_NOEXCEPT
240 {
return const_iterator(_Base::end(),
this); }
243 rbegin() _GLIBCXX_NOEXCEPT
244 {
return reverse_iterator(end()); }
246 const_reverse_iterator
247 rbegin()
const _GLIBCXX_NOEXCEPT
248 {
return const_reverse_iterator(end()); }
251 rend() _GLIBCXX_NOEXCEPT
252 {
return reverse_iterator(begin()); }
254 const_reverse_iterator
255 rend()
const _GLIBCXX_NOEXCEPT
256 {
return const_reverse_iterator(begin()); }
258#if __cplusplus >= 201103L
260 cbegin()
const noexcept
261 {
return const_iterator(_Base::begin(),
this); }
264 cend()
const noexcept
265 {
return const_iterator(_Base::end(),
this); }
267 const_reverse_iterator
268 crbegin()
const noexcept
269 {
return const_reverse_iterator(end()); }
271 const_reverse_iterator
272 crend()
const noexcept
273 {
return const_reverse_iterator(begin()); }
279 using _Base::max_size;
281#if __cplusplus >= 201103L
283 resize(size_type __sz)
285 this->_M_detach_singular();
288 _Base_iterator __victim = _Base::begin();
289 _Base_iterator __end = _Base::end();
290 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
293 for (; __victim != __end; ++__victim)
294 this->_M_invalidate_if(_Equal(__victim));
302 this->_M_revalidate_singular();
303 __throw_exception_again;
308 resize(size_type __sz,
const _Tp& __c)
310 this->_M_detach_singular();
313 _Base_iterator __victim = _Base::begin();
314 _Base_iterator __end = _Base::end();
315 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
318 for (; __victim != __end; ++__victim)
319 this->_M_invalidate_if(_Equal(__victim));
323 _Base::resize(__sz, __c);
327 this->_M_revalidate_singular();
328 __throw_exception_again;
333 resize(size_type __sz, _Tp __c = _Tp())
335 this->_M_detach_singular();
338 _Base_iterator __victim = _Base::begin();
339 _Base_iterator __end = _Base::end();
340 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
343 for (; __victim != __end; ++__victim)
344 this->_M_invalidate_if(_Equal(__victim));
348 _Base::resize(__sz, __c);
352 this->_M_revalidate_singular();
353 __throw_exception_again;
360 front() _GLIBCXX_NOEXCEPT
362 __glibcxx_check_nonempty();
363 return _Base::front();
367 front()
const _GLIBCXX_NOEXCEPT
369 __glibcxx_check_nonempty();
370 return _Base::front();
374 back() _GLIBCXX_NOEXCEPT
376 __glibcxx_check_nonempty();
377 return _Base::back();
381 back()
const _GLIBCXX_NOEXCEPT
383 __glibcxx_check_nonempty();
384 return _Base::back();
388 using _Base::push_front;
390#if __cplusplus >= 201103L
391 using _Base::emplace_front;
395 pop_front() _GLIBCXX_NOEXCEPT
397 __glibcxx_check_nonempty();
398 this->_M_invalidate_if(_Equal(_Base::begin()));
402 using _Base::push_back;
404#if __cplusplus >= 201103L
405 using _Base::emplace_back;
409 pop_back() _GLIBCXX_NOEXCEPT
411 __glibcxx_check_nonempty();
412 this->_M_invalidate_if(_Equal(--_Base::end()));
416#if __cplusplus >= 201103L
417 template<
typename... _Args>
419 emplace(const_iterator __position, _Args&&... __args)
422 return { _Base::emplace(__position.
base(),
428#if __cplusplus >= 201103L
429 insert(const_iterator __position,
const _Tp& __x)
431 insert(iterator __position,
const _Tp& __x)
435 return iterator(_Base::insert(__position.
base(), __x),
this);
438#if __cplusplus >= 201103L
440 insert(const_iterator __position, _Tp&& __x)
441 {
return emplace(__position,
std::move(__x)); }
447 return { _Base::insert(__p.
base(), __l),
this };
451#if __cplusplus >= 201103L
453 insert(const_iterator __position, size_type __n,
const _Tp& __x)
456 return { _Base::insert(__position.
base(), __n, __x),
this };
460 insert(iterator __position, size_type __n,
const _Tp& __x)
463 _Base::insert(__position.
base(), __n, __x);
467#if __cplusplus >= 201103L
468 template<
class _InputIterator,
469 typename = std::_RequireInputIter<_InputIterator>>
471 insert(const_iterator __position, _InputIterator __first,
472 _InputIterator __last)
474 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
476 if (__dist.second >= __gnu_debug::__dp_sign)
479 _Base::insert(__position.
base(),
480 __gnu_debug::__unsafe(__first),
481 __gnu_debug::__unsafe(__last)),
485 return { _Base::insert(__position.
base(), __first, __last),
this };
488 template<
class _InputIterator>
490 insert(iterator __position, _InputIterator __first,
491 _InputIterator __last)
493 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
496 if (__dist.second >= __gnu_debug::__dp_sign)
497 _Base::insert(__position.
base(), __gnu_debug::__unsafe(__first),
498 __gnu_debug::__unsafe(__last));
500 _Base::insert(__position.
base(), __first, __last);
506#if __cplusplus >= 201103L
507 _M_erase(_Base_const_iterator __position)
noexcept
509 _M_erase(_Base_iterator __position)
512 this->_M_invalidate_if(_Equal(__position));
513 return _Base::erase(__position);
518#if __cplusplus >= 201103L
519 erase(const_iterator __position)
noexcept
521 erase(iterator __position)
525 return iterator(_M_erase(__position.
base()),
this);
529#if __cplusplus >= 201103L
530 erase(const_iterator __first, const_iterator __last)
noexcept
532 erase(iterator __first, iterator __last)
538 for (_Base_const_iterator __victim = __first.base();
539 __victim != __last.base(); ++__victim)
541 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
542 _M_message(__gnu_debug::__msg_valid_range)
543 ._M_iterator(__first,
"position")
544 ._M_iterator(__last,
"last"));
545 this->_M_invalidate_if(_Equal(__victim));
548 return iterator(_Base::erase(__first.base(), __last.base()),
this);
560 clear() _GLIBCXX_NOEXCEPT
563 this->_M_invalidate_all();
568#if __cplusplus >= 201103L
569 splice(const_iterator __position, list&& __x)
noexcept
571 splice(iterator __position, list& __x)
575 _M_message(__gnu_debug::__msg_self_splice)
576 ._M_sequence(*
this,
"this"));
577 this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
578 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()));
581#if __cplusplus >= 201103L
583 splice(const_iterator __position, list& __x)
noexcept
588#if __cplusplus >= 201103L
589 splice(const_iterator __position, list&& __x, const_iterator __i)
noexcept
591 splice(iterator __position, list& __x, iterator __i)
600 _M_message(__gnu_debug::__msg_splice_bad)
601 ._M_iterator(__i,
"__i"));
603 _M_message(__gnu_debug::__msg_splice_other)
604 ._M_iterator(__i,
"__i")._M_sequence(__x,
"__x"));
608 this->_M_transfer_from_if(__x, _Equal(__i.
base()));
609 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
613#if __cplusplus >= 201103L
615 splice(const_iterator __position, list& __x, const_iterator __i)
noexcept
616 { splice(__position,
std::move(__x), __i); }
620#if __cplusplus >= 201103L
621 splice(const_iterator __position, list&& __x, const_iterator __first,
622 const_iterator __last)
noexcept
624 splice(iterator __position, list& __x, iterator __first,
629 __glibcxx_check_valid_range(__first, __last);
631 _M_message(__gnu_debug::__msg_splice_other)
632 ._M_sequence(__x,
"x")
633 ._M_iterator(__first,
"first"));
638 for (_Base_const_iterator __tmp = __first.base();
639 __tmp != __last.base(); ++__tmp)
641 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
642 _M_message(__gnu_debug::__msg_valid_range)
643 ._M_iterator(__first,
"first")
644 ._M_iterator(__last,
"last"));
646 || __tmp != __position.
base(),
647 _M_message(__gnu_debug::__msg_splice_overlap)
648 ._M_iterator(__tmp,
"position")
649 ._M_iterator(__first,
"first")
650 ._M_iterator(__last,
"last"));
654 this->_M_transfer_from_if(__x, _Equal(__tmp));
657 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x._M_base()),
661#if __cplusplus >= 201103L
663 splice(const_iterator __position, list& __x,
664 const_iterator __first, const_iterator __last)
noexcept
665 { splice(__position,
std::move(__x), __first, __last); }
669#if __cplusplus > 201703L
670 typedef size_type __remove_return_type;
671# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG \
672 __attribute__((__abi_tag__("__cxx20")))
673# define _GLIBCXX20_ONLY(__expr) __expr
675 typedef void __remove_return_type;
676# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
677# define _GLIBCXX20_ONLY(__expr)
681 _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
683 remove(
const _Tp& __value)
685 if (!this->_M_iterators && !this->_M_const_iterators)
686 return _Base::remove(__value);
688#if !_GLIBCXX_USE_CXX11_ABI
689 size_type __removed __attribute__((__unused__)) = 0;
691 _Base __to_destroy(get_allocator());
692 _Base_iterator __first = _Base::begin();
693 _Base_iterator __last = _Base::end();
694 while (__first != __last)
696 _Base_iterator __next = __first;
698 if (*__first == __value)
703 this->_M_invalidate_if(_Equal(__first));
704 __to_destroy.splice(__to_destroy.begin(), _M_base(), __first);
705#if !_GLIBCXX_USE_CXX11_ABI
706 _GLIBCXX20_ONLY( __removed++ );
713#if !_GLIBCXX_USE_CXX11_ABI
714 return _GLIBCXX20_ONLY( __removed );
716 return _GLIBCXX20_ONLY( __to_destroy.size() );
720 template<
class _Predicate>
722 remove_if(_Predicate __pred)
724 if (!this->_M_iterators && !this->_M_const_iterators)
725 return _Base::remove_if(__pred);
727#if !_GLIBCXX_USE_CXX11_ABI
728 size_type __removed __attribute__((__unused__)) = 0;
730 _Base __to_destroy(get_allocator());
731 for (_Base_iterator __x = _Base::begin(); __x != _Base::end(); )
733 _Base_iterator __next = __x;
737 this->_M_invalidate_if(_Equal(__x));
738 __to_destroy.splice(__to_destroy.begin(), _M_base(), __x);
739#if !_GLIBCXX_USE_CXX11_ABI
740 _GLIBCXX20_ONLY( __removed++ );
747#if !_GLIBCXX_USE_CXX11_ABI
748 return _GLIBCXX20_ONLY( __removed );
750 return _GLIBCXX20_ONLY( __to_destroy.size() );
754 _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
758 if (!this->_M_iterators && !this->_M_const_iterators)
759 return _Base::unique();
762 return _GLIBCXX20_ONLY(0);
764#if !_GLIBCXX_USE_CXX11_ABI
765 size_type __removed __attribute__((__unused__)) = 0;
767 _Base __to_destroy(get_allocator());
768 _Base_iterator __first = _Base::begin();
769 _Base_iterator __last = _Base::end();
770 _Base_iterator __next = __first;
771 while (++__next != __last)
772 if (*__first == *__next)
774 this->_M_invalidate_if(_Equal(__next));
775 __to_destroy.splice(__to_destroy.begin(), _M_base(), __next);
777#if !_GLIBCXX_USE_CXX11_ABI
778 _GLIBCXX20_ONLY( __removed++ );
784#if !_GLIBCXX_USE_CXX11_ABI
785 return _GLIBCXX20_ONLY( __removed );
787 return _GLIBCXX20_ONLY( __to_destroy.size() );
791 template<
class _BinaryPredicate>
793 unique(_BinaryPredicate __binary_pred)
795 if (!this->_M_iterators && !this->_M_const_iterators)
796 return _Base::unique(__binary_pred);
799 return _GLIBCXX20_ONLY(0);
802#if !_GLIBCXX_USE_CXX11_ABI
803 size_type __removed __attribute__((__unused__)) = 0;
805 _Base __to_destroy(get_allocator());
806 _Base_iterator __first = _Base::begin();
807 _Base_iterator __last = _Base::end();
808 _Base_iterator __next = __first;
809 while (++__next != __last)
810 if (__binary_pred(*__first, *__next))
812 this->_M_invalidate_if(_Equal(__next));
813 __to_destroy.splice(__to_destroy.begin(), _M_base(), __next);
815#if !_GLIBCXX_USE_CXX11_ABI
816 _GLIBCXX20_ONLY( __removed++ );
822#if !_GLIBCXX_USE_CXX11_ABI
823 return _GLIBCXX20_ONLY( __removed );
825 return _GLIBCXX20_ONLY( __to_destroy.size() );
829#undef _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
830#undef _GLIBCXX20_ONLY
833#if __cplusplus >= 201103L
843 __glibcxx_check_sorted(_Base::begin(), _Base::end());
844 __glibcxx_check_sorted(__x.begin().
base(), __x.end().
base());
845 this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
846 _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
850#if __cplusplus >= 201103L
856 template<
class _Compare>
858#if __cplusplus >= 201103L
859 merge(list&& __x, _Compare __comp)
861 merge(list& __x, _Compare __comp)
872 this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
873 _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
877#if __cplusplus >= 201103L
878 template<
typename _Compare>
880 merge(list& __x, _Compare __comp)
885 sort() { _Base::sort(); }
887 template<
typename _StrictWeakOrdering>
889 sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
891 using _Base::reverse;
894 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
897 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }