54 list<_Tp, _Allocator>, _Allocator,
55 __gnu_debug::_Safe_node_sequence>,
56 public _GLIBCXX_STD_C::list<_Tp, _Allocator>
58 typedef _GLIBCXX_STD_C::list<_Tp, _Allocator>
_Base;
67 template<
typename _ItT,
typename _SeqT,
typename _CatT>
68 friend class ::__gnu_debug::_Safe_iterator;
75 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
81 typedef typename _Base::reference reference;
82 typedef typename _Base::const_reference const_reference;
89 typedef typename _Base::size_type size_type;
90 typedef typename _Base::difference_type difference_type;
92 typedef _Tp value_type;
93 typedef _Allocator allocator_type;
94 typedef typename _Base::pointer pointer;
95 typedef typename _Base::const_pointer const_pointer;
101#if __cplusplus < 201103L
115 const allocator_type& __a = allocator_type())
116 :
_Base(__l, __a) { }
120 list(
const list& __x,
const __type_identity_t<allocator_type>& __a)
121 :
_Base(__x, __a) { }
123 list(
list&& __x,
const __type_identity_t<allocator_type>& __a)
126 _Base,
const allocator_type&>::value )
132 list(
const _Allocator& __a) _GLIBCXX_NOEXCEPT
135#if __cplusplus >= 201103L
137 list(size_type __n,
const allocator_type& __a = allocator_type())
138 :
_Base(__n, __a) { }
140 list(size_type __n,
const __type_identity_t<_Tp>& __value,
141 const _Allocator& __a = _Allocator())
142 :
_Base(__n, __value, __a) { }
145 list(size_type __n,
const _Tp& __value = _Tp(),
146 const _Allocator& __a = _Allocator())
147 :
_Base(__n, __value, __a) { }
150#if __cplusplus >= 201103L
151 template<
class _InputIterator,
152 typename = std::_RequireInputIter<_InputIterator>>
154 template<
class _InputIterator>
156 list(_InputIterator __first, _InputIterator __last,
157 const _Allocator& __a = _Allocator())
159 __glibcxx_check_valid_constructor_range(__first, __last)),
163#if __glibcxx_containers_ranges
164 template<__detail::__container_compatible_range<_Tp> _Rg>
165 list(from_range_t, _Rg&& __rg,
const _Allocator& __a = _Allocator())
166 :
_Base(std::from_range, std::forward<_Rg>(__rg), __a)
171 :
_Base(__x._M_ref) { }
173#if __cplusplus >= 201103L
175 operator=(
const list&) =
default;
178 operator=(
list&&) =
default;
183 this->_M_invalidate_all();
184 _Base::operator=(__l);
192 this->_M_invalidate_all();
196#if __cplusplus >= 201103L
197 template<
class _InputIterator,
198 typename = std::_RequireInputIter<_InputIterator>>
200 template<
class _InputIterator>
203 assign(_InputIterator __first, _InputIterator __last)
206 __glibcxx_check_valid_range2(__first, __last, __dist);
208 if (__dist.
second >= __gnu_debug::__dp_sign)
209 _Base::assign(__gnu_debug::__unsafe(__first),
210 __gnu_debug::__unsafe(__last));
212 _Base::assign(__first, __last);
214 this->_M_invalidate_all();
217#if __glibcxx_containers_ranges
218 template<__detail::__container_compatible_range<_Tp> _Rg>
220 assign_range(_Rg&& __rg)
225 static_assert(assignable_from<_Tp&, ranges::range_reference_t<_Rg>>);
227 auto __first1 = _Base::begin();
228 const auto __last1 = _Base::end();
229 auto __first2 = ranges::begin(__rg);
230 const auto __last2 = ranges::end(__rg);
231 for (; __first1 != __last1 && __first2 != __last2;
232 ++__first1, (void)++__first2)
233 *__first1 = *__first2;
234 if (__first2 == __last2)
238 _Base::insert_range(__last1,
244 assign(size_type __n,
const _Tp& __t)
246 _Base::assign(__n, __t);
247 this->_M_invalidate_all();
250 using _Base::get_allocator;
255 begin() _GLIBCXX_NOEXCEPT
256 {
return iterator(_Base::begin(),
this); }
260 begin()
const _GLIBCXX_NOEXCEPT
265 end() _GLIBCXX_NOEXCEPT
266 {
return iterator(_Base::end(),
this); }
270 end()
const _GLIBCXX_NOEXCEPT
275 rbegin() _GLIBCXX_NOEXCEPT
280 rbegin()
const _GLIBCXX_NOEXCEPT
285 rend() _GLIBCXX_NOEXCEPT
290 rend()
const _GLIBCXX_NOEXCEPT
293#if __cplusplus >= 201103L
296 cbegin()
const noexcept
301 cend()
const noexcept
306 crbegin()
const noexcept
311 crend()
const noexcept
318 using _Base::max_size;
320#if __cplusplus >= 201103L
322 resize(size_type __sz)
324 this->_M_detach_singular();
329 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
332 for (; __victim != __end; ++__victim)
333 this->_M_invalidate_if(
_Equal(__victim));
341 this->_M_revalidate_singular();
342 __throw_exception_again;
347 resize(size_type __sz,
const _Tp& __c)
349 this->_M_detach_singular();
354 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
357 for (; __victim != __end; ++__victim)
358 this->_M_invalidate_if(
_Equal(__victim));
362 _Base::resize(__sz, __c);
366 this->_M_revalidate_singular();
367 __throw_exception_again;
372 resize(size_type __sz, _Tp __c = _Tp())
374 this->_M_detach_singular();
379 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
382 for (; __victim != __end; ++__victim)
383 this->_M_invalidate_if(
_Equal(__victim));
387 _Base::resize(__sz, __c);
391 this->_M_revalidate_singular();
392 __throw_exception_again;
400 front() _GLIBCXX_NOEXCEPT
402 __glibcxx_check_nonempty();
403 return _Base::front();
408 front()
const _GLIBCXX_NOEXCEPT
410 __glibcxx_check_nonempty();
411 return _Base::front();
416 back() _GLIBCXX_NOEXCEPT
418 __glibcxx_check_nonempty();
419 return _Base::back();
424 back()
const _GLIBCXX_NOEXCEPT
426 __glibcxx_check_nonempty();
427 return _Base::back();
431 using _Base::push_front;
433#if __cplusplus >= 201103L
434 using _Base::emplace_front;
437#if __glibcxx_containers_ranges
438 using _Base::prepend_range;
439 using _Base::append_range;
443 pop_front() _GLIBCXX_NOEXCEPT
445 __glibcxx_check_nonempty();
446 this->_M_invalidate_if(
_Equal(_Base::begin()));
450 using _Base::push_back;
452#if __cplusplus >= 201103L
453 using _Base::emplace_back;
457 pop_back() _GLIBCXX_NOEXCEPT
459 __glibcxx_check_nonempty();
460 this->_M_invalidate_if(
_Equal(--_Base::end()));
464#if __cplusplus >= 201103L
465 template<
typename... _Args>
470 return { _Base::emplace(__position.
base(),
471 std::forward<_Args>(__args)...),
this };
476#if __cplusplus >= 201103L
479 insert(
iterator __position,
const _Tp& __x)
483 return iterator(_Base::insert(__position.
base(), __x),
this);
486#if __cplusplus >= 201103L
489 {
return emplace(__position,
std::move(__x)); }
495 return { _Base::insert(__p.
base(), __l),
this };
499#if __cplusplus >= 201103L
504 return { _Base::insert(__position.
base(), __n, __x),
this };
508 insert(
iterator __position, size_type __n,
const _Tp& __x)
511 _Base::insert(__position.
base(), __n, __x);
515#if __cplusplus >= 201103L
516 template<
class _InputIterator,
517 typename = std::_RequireInputIter<_InputIterator>>
520 _InputIterator __last)
524 if (__dist.
second >= __gnu_debug::__dp_sign)
527 _Base::insert(__position.
base(),
528 __gnu_debug::__unsafe(__first),
529 __gnu_debug::__unsafe(__last)),
533 return { _Base::insert(__position.
base(), __first, __last),
this };
536 template<
class _InputIterator>
538 insert(
iterator __position, _InputIterator __first,
539 _InputIterator __last)
544 if (__dist.
second >= __gnu_debug::__dp_sign)
545 _Base::insert(__position.
base(), __gnu_debug::__unsafe(__first),
546 __gnu_debug::__unsafe(__last));
548 _Base::insert(__position.
base(), __first, __last);
552#if __glibcxx_containers_ranges
553 template<__detail::__container_compatible_range<_Tp> _Rg>
557 auto __ret = _Base::insert_range(__position.
base(),
558 std::forward<_Rg>(__rg));
559 return { __ret,
this };
565#if __cplusplus >= 201103L
571 this->_M_invalidate_if(
_Equal(__position));
572 return _Base::erase(__position);
577#if __cplusplus >= 201103L
588#if __cplusplus >= 201103L
598 __victim != __last.base(); ++__victim)
600 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
601 _M_message(__gnu_debug::__msg_valid_range)
602 ._M_iterator(__first,
"position")
603 ._M_iterator(__last,
"last"));
604 this->_M_invalidate_if(
_Equal(__victim));
607 return iterator(_Base::erase(__first.base(), __last.base()),
this);
612 _GLIBCXX_NOEXCEPT_IF(
noexcept(declval<_Base&>().swap(__x)) )
619 clear() _GLIBCXX_NOEXCEPT
622 this->_M_invalidate_all();
627#if __cplusplus >= 201103L
634 _M_message(__gnu_debug::__msg_self_splice)
635 ._M_sequence(*
this,
"this"));
636 this->_M_transfer_from_if(__x,
_Not_equal(__x._M_base().end()));
637 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x));
640#if __cplusplus >= 201103L
647#if __cplusplus >= 201103L
659 _M_message(__gnu_debug::__msg_splice_bad)
660 ._M_iterator(__i,
"__i"));
662 _M_message(__gnu_debug::__msg_splice_other)
663 ._M_iterator(__i,
"__i")._M_sequence(__x,
"__x"));
667 this->_M_transfer_from_if(__x,
_Equal(__i.
base()));
668 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x),
672#if __cplusplus >= 201103L
675 { splice(__position,
std::move(__x), __i); }
679#if __cplusplus >= 201103L
688 __glibcxx_check_valid_range(__first, __last);
690 _M_message(__gnu_debug::__msg_splice_other)
691 ._M_sequence(__x,
"x")
692 ._M_iterator(__first,
"first"));
698 __tmp != __last.base(); ++__tmp)
700 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
701 _M_message(__gnu_debug::__msg_valid_range)
702 ._M_iterator(__first,
"first")
703 ._M_iterator(__last,
"last"));
705 || __tmp != __position.
base(),
706 _M_message(__gnu_debug::__msg_splice_overlap)
707 ._M_iterator(__tmp,
"position")
708 ._M_iterator(__first,
"first")
709 ._M_iterator(__last,
"last"));
713 this->_M_transfer_from_if(__x,
_Equal(__tmp));
716 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x),
717 __first.base(), __last.base());
720#if __cplusplus >= 201103L
724 { splice(__position,
std::move(__x), __first, __last); }
728#if __cplusplus > 201703L
729 typedef size_type __remove_return_type;
730# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG \
731 __attribute__((__abi_tag__("__cxx20")))
732# define _GLIBCXX20_ONLY(__expr) __expr
734 typedef void __remove_return_type;
735# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
736# define _GLIBCXX20_ONLY(__expr)
740 _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
742 remove(
const _Tp& __value)
744 if (!this->_M_iterators && !this->_M_const_iterators)
745 return _Base::remove(__value);
747#if !_GLIBCXX_USE_CXX11_ABI
748 size_type __removed __attribute__((__unused__)) = 0;
750 _Base __to_destroy(get_allocator());
753 while (__first != __last)
757 if (*__first == __value)
762 this->_M_invalidate_if(
_Equal(__first));
763 __to_destroy.splice(__to_destroy.begin(), *
this, __first);
764#if !_GLIBCXX_USE_CXX11_ABI
765 _GLIBCXX20_ONLY( __removed++ );
772#if !_GLIBCXX_USE_CXX11_ABI
773 return _GLIBCXX20_ONLY( __removed );
775 return _GLIBCXX20_ONLY( __to_destroy.size() );
779 template<
class _Predicate>
781 remove_if(_Predicate __pred)
783 if (!this->_M_iterators && !this->_M_const_iterators)
784 return _Base::remove_if(__pred);
786#if !_GLIBCXX_USE_CXX11_ABI
787 size_type __removed __attribute__((__unused__)) = 0;
789 _Base __to_destroy(get_allocator());
796 this->_M_invalidate_if(
_Equal(__x));
797 __to_destroy.splice(__to_destroy.begin(), *
this, __x);
798#if !_GLIBCXX_USE_CXX11_ABI
799 _GLIBCXX20_ONLY( __removed++ );
806#if !_GLIBCXX_USE_CXX11_ABI
807 return _GLIBCXX20_ONLY( __removed );
809 return _GLIBCXX20_ONLY( __to_destroy.size() );
813 _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
817 if (!this->_M_iterators && !this->_M_const_iterators)
818 return _Base::unique();
821 return _GLIBCXX20_ONLY(0);
823#if !_GLIBCXX_USE_CXX11_ABI
824 size_type __removed __attribute__((__unused__)) = 0;
826 _Base __to_destroy(get_allocator());
830 while (++__next != __last)
831 if (*__first == *__next)
833 this->_M_invalidate_if(
_Equal(__next));
834 __to_destroy.splice(__to_destroy.begin(), *
this, __next);
836#if !_GLIBCXX_USE_CXX11_ABI
837 _GLIBCXX20_ONLY( __removed++ );
843#if !_GLIBCXX_USE_CXX11_ABI
844 return _GLIBCXX20_ONLY( __removed );
846 return _GLIBCXX20_ONLY( __to_destroy.size() );
850 template<
class _BinaryPredicate>
852 unique(_BinaryPredicate __binary_pred)
854 if (!this->_M_iterators && !this->_M_const_iterators)
855 return _Base::unique(__binary_pred);
858 return _GLIBCXX20_ONLY(0);
861#if !_GLIBCXX_USE_CXX11_ABI
862 size_type __removed __attribute__((__unused__)) = 0;
864 _Base __to_destroy(get_allocator());
868 while (++__next != __last)
869 if (__binary_pred(*__first, *__next))
871 this->_M_invalidate_if(
_Equal(__next));
872 __to_destroy.splice(__to_destroy.begin(), *
this, __next);
874#if !_GLIBCXX_USE_CXX11_ABI
875 _GLIBCXX20_ONLY( __removed++ );
881#if !_GLIBCXX_USE_CXX11_ABI
882 return _GLIBCXX20_ONLY( __removed );
884 return _GLIBCXX20_ONLY( __to_destroy.size() );
888#undef _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
889#undef _GLIBCXX20_ONLY
892#if __cplusplus >= 201103L
902 __glibcxx_check_sorted(_Base::begin(), _Base::end());
903 __glibcxx_check_sorted(__x.begin().
base(), __x.end().
base());
904 this->_M_transfer_from_if(__x,
_Not_equal(__x._M_base().end()));
905 _Base::merge(_GLIBCXX_MOVE(__x));
909#if __cplusplus >= 201103L
915 template<
class _Compare>
917#if __cplusplus >= 201103L
918 merge(
list&& __x, _Compare __comp)
920 merge(
list& __x, _Compare __comp)
931 this->_M_transfer_from_if(__x,
_Not_equal(__x._M_base().end()));
932 _Base::merge(_GLIBCXX_MOVE(__x), __comp);
936#if __cplusplus >= 201103L
937 template<
typename _Compare>
939 merge(
list& __x, _Compare __comp)
944 sort() { _Base::sort(); }
946 template<
typename _StrictWeakOrdering>
948 sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
950 using _Base::reverse;
953 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
956 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }