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;
62 typedef typename _Base::iterator _Base_iterator;
63 typedef typename _Base::const_iterator _Base_const_iterator;
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
105 list(
const list& __x)
111 list(
const list&) =
default;
112 list(list&&) =
default;
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())
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)
205 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
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)
235 erase(const_iterator(__first1,
this),
236 const_iterator(__last1,
this));
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
261 {
return const_iterator(_Base::begin(),
this); }
265 end() _GLIBCXX_NOEXCEPT
266 {
return iterator(_Base::end(),
this); }
270 end()
const _GLIBCXX_NOEXCEPT
271 {
return const_iterator(_Base::end(),
this); }
275 rbegin() _GLIBCXX_NOEXCEPT
276 {
return reverse_iterator(end()); }
279 const_reverse_iterator
280 rbegin()
const _GLIBCXX_NOEXCEPT
281 {
return const_reverse_iterator(end()); }
285 rend() _GLIBCXX_NOEXCEPT
286 {
return reverse_iterator(begin()); }
289 const_reverse_iterator
290 rend()
const _GLIBCXX_NOEXCEPT
291 {
return const_reverse_iterator(begin()); }
293#if __cplusplus >= 201103L
296 cbegin()
const noexcept
297 {
return const_iterator(_Base::begin(),
this); }
301 cend()
const noexcept
302 {
return const_iterator(_Base::end(),
this); }
305 const_reverse_iterator
306 crbegin()
const noexcept
307 {
return const_reverse_iterator(end()); }
310 const_reverse_iterator
311 crend()
const noexcept
312 {
return const_reverse_iterator(begin()); }
318 using _Base::max_size;
320#if __cplusplus >= 201103L
322 resize(size_type __sz)
324 const list* __this =
this;
325 __this->_M_detach_singular();
328 _Base_iterator __victim = _Base::begin();
329 _Base_iterator __end = _Base::end();
330 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
333 for (; __victim != __end; ++__victim)
334 this->_M_invalidate_if(_Equal(__victim));
342 __this->_M_revalidate_singular();
343 __throw_exception_again;
348 resize(size_type __sz,
const _Tp& __c)
350 const list* __this =
this;
351 __this->_M_detach_singular();
354 _Base_iterator __victim = _Base::begin();
355 _Base_iterator __end = _Base::end();
356 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
359 for (; __victim != __end; ++__victim)
360 this->_M_invalidate_if(_Equal(__victim));
364 _Base::resize(__sz, __c);
368 __this->_M_revalidate_singular();
369 __throw_exception_again;
374 resize(size_type __sz, _Tp __c = _Tp())
376 const list* __this =
this;
377 __this->_M_detach_singular();
380 _Base_iterator __victim = _Base::begin();
381 _Base_iterator __end = _Base::end();
382 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
385 for (; __victim != __end; ++__victim)
386 this->_M_invalidate_if(_Equal(__victim));
390 _Base::resize(__sz, __c);
394 __this->_M_revalidate_singular();
395 __throw_exception_again;
403 front() _GLIBCXX_NOEXCEPT
405 __glibcxx_check_nonempty();
406 return _Base::front();
411 front()
const _GLIBCXX_NOEXCEPT
413 __glibcxx_check_nonempty();
414 return _Base::front();
419 back() _GLIBCXX_NOEXCEPT
421 __glibcxx_check_nonempty();
422 return _Base::back();
427 back()
const _GLIBCXX_NOEXCEPT
429 __glibcxx_check_nonempty();
430 return _Base::back();
434 using _Base::push_front;
436#if __cplusplus >= 201103L
437 using _Base::emplace_front;
440#if __glibcxx_containers_ranges
441 using _Base::prepend_range;
442 using _Base::append_range;
446 pop_front() _GLIBCXX_NOEXCEPT
448 __glibcxx_check_nonempty();
449 this->_M_invalidate_if(_Equal(_Base::begin()));
453 using _Base::push_back;
455#if __cplusplus >= 201103L
456 using _Base::emplace_back;
460 pop_back() _GLIBCXX_NOEXCEPT
462 __glibcxx_check_nonempty();
463 this->_M_invalidate_if(_Equal(--_Base::end()));
467#if __cplusplus >= 201103L
468 template<
typename... _Args>
470 emplace(const_iterator __position, _Args&&... __args)
473 return { _Base::emplace(__position.
base(),
479#if __cplusplus >= 201103L
480 insert(const_iterator __position,
const _Tp& __x)
482 insert(iterator __position,
const _Tp& __x)
486 return iterator(_Base::insert(__position.
base(), __x),
this);
489#if __cplusplus >= 201103L
491 insert(const_iterator __position, _Tp&& __x)
492 {
return emplace(__position,
std::move(__x)); }
498 return { _Base::insert(__p.
base(), __l),
this };
502#if __cplusplus >= 201103L
504 insert(const_iterator __position, size_type __n,
const _Tp& __x)
507 return { _Base::insert(__position.
base(), __n, __x),
this };
511 insert(iterator __position, size_type __n,
const _Tp& __x)
514 _Base::insert(__position.
base(), __n, __x);
518#if __cplusplus >= 201103L
519 template<
class _InputIterator,
520 typename = std::_RequireInputIter<_InputIterator>>
522 insert(const_iterator __position, _InputIterator __first,
523 _InputIterator __last)
525 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
527 if (__dist.second >= __gnu_debug::__dp_sign)
530 _Base::insert(__position.
base(),
531 __gnu_debug::__unsafe(__first),
532 __gnu_debug::__unsafe(__last)),
536 return { _Base::insert(__position.
base(), __first, __last),
this };
539 template<
class _InputIterator>
541 insert(iterator __position, _InputIterator __first,
542 _InputIterator __last)
544 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
547 if (__dist.second >= __gnu_debug::__dp_sign)
548 _Base::insert(__position.
base(), __gnu_debug::__unsafe(__first),
549 __gnu_debug::__unsafe(__last));
551 _Base::insert(__position.
base(), __first, __last);
555#if __glibcxx_containers_ranges
556 template<__detail::__container_compatible_range<_Tp> _Rg>
558 insert_range(const_iterator __position, _Rg&& __rg)
560 auto __ret = _Base::insert_range(__position.
base(),
562 return { __ret,
this };
568#if __cplusplus >= 201103L
569 _M_erase(_Base_const_iterator __position)
noexcept
571 _M_erase(_Base_iterator __position)
574 this->_M_invalidate_if(_Equal(__position));
575 return _Base::erase(__position);
580#if __cplusplus >= 201103L
581 erase(const_iterator __position)
noexcept
583 erase(iterator __position)
587 return iterator(_M_erase(__position.
base()),
this);
591#if __cplusplus >= 201103L
592 erase(const_iterator __first, const_iterator __last)
noexcept
594 erase(iterator __first, iterator __last)
600 for (_Base_const_iterator __victim = __first.base();
601 __victim != __last.base(); ++__victim)
603 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
604 _M_message(__gnu_debug::__msg_valid_range)
605 ._M_iterator(__first,
"position")
606 ._M_iterator(__last,
"last"));
607 this->_M_invalidate_if(_Equal(__victim));
610 return iterator(_Base::erase(__first.base(), __last.base()),
this);
622 clear() _GLIBCXX_NOEXCEPT
625 this->_M_invalidate_all();
630#if __cplusplus >= 201103L
631 splice(const_iterator __position, list&& __x)
noexcept
633 splice(iterator __position, list& __x)
637 _M_message(__gnu_debug::__msg_self_splice)
638 ._M_sequence(*
this,
"this"));
639 this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
640 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x));
643#if __cplusplus >= 201103L
645 splice(const_iterator __position, list& __x)
noexcept
650#if __cplusplus >= 201103L
651 splice(const_iterator __position, list&& __x, const_iterator __i)
noexcept
653 splice(iterator __position, list& __x, iterator __i)
662 _M_message(__gnu_debug::__msg_splice_bad)
663 ._M_iterator(__i,
"__i"));
665 _M_message(__gnu_debug::__msg_splice_other)
666 ._M_iterator(__i,
"__i")._M_sequence(__x,
"__x"));
670 this->_M_transfer_from_if(__x, _Equal(__i.
base()));
671 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x),
675#if __cplusplus >= 201103L
677 splice(const_iterator __position, list& __x, const_iterator __i)
noexcept
678 { splice(__position,
std::move(__x), __i); }
682#if __cplusplus >= 201103L
683 splice(const_iterator __position, list&& __x, const_iterator __first,
684 const_iterator __last)
noexcept
686 splice(iterator __position, list& __x, iterator __first,
691 __glibcxx_check_valid_range(__first, __last);
693 _M_message(__gnu_debug::__msg_splice_other)
694 ._M_sequence(__x,
"x")
695 ._M_iterator(__first,
"first"));
700 for (_Base_const_iterator __tmp = __first.base();
701 __tmp != __last.base(); ++__tmp)
703 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
704 _M_message(__gnu_debug::__msg_valid_range)
705 ._M_iterator(__first,
"first")
706 ._M_iterator(__last,
"last"));
708 || __tmp != __position.
base(),
709 _M_message(__gnu_debug::__msg_splice_overlap)
710 ._M_iterator(__tmp,
"position")
711 ._M_iterator(__first,
"first")
712 ._M_iterator(__last,
"last"));
716 this->_M_transfer_from_if(__x, _Equal(__tmp));
719 _Base::splice(__position.
base(), _GLIBCXX_MOVE(__x),
723#if __cplusplus >= 201103L
725 splice(const_iterator __position, list& __x,
726 const_iterator __first, const_iterator __last)
noexcept
727 { splice(__position,
std::move(__x), __first, __last); }
731#if __cplusplus > 201703L
732 typedef size_type __remove_return_type;
733# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG \
734 __attribute__((__abi_tag__("__cxx20")))
735# define _GLIBCXX20_ONLY(__expr) __expr
737 typedef void __remove_return_type;
738# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
739# define _GLIBCXX20_ONLY(__expr)
743 _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
745 remove(
const _Tp& __value)
747 if (!this->_M_iterators && !this->_M_const_iterators)
748 return _Base::remove(__value);
750#if !_GLIBCXX_USE_CXX11_ABI
751 size_type __removed __attribute__((__unused__)) = 0;
753 _Base __to_destroy(get_allocator());
754 _Base_iterator __first = _Base::begin();
755 _Base_iterator __last = _Base::end();
756 while (__first != __last)
758 _Base_iterator __next = __first;
760 if (*__first == __value)
765 this->_M_invalidate_if(_Equal(__first));
766 __to_destroy.splice(__to_destroy.begin(), *
this, __first);
767#if !_GLIBCXX_USE_CXX11_ABI
768 _GLIBCXX20_ONLY( __removed++ );
775#if !_GLIBCXX_USE_CXX11_ABI
776 return _GLIBCXX20_ONLY( __removed );
778 return _GLIBCXX20_ONLY( __to_destroy.size() );
782 template<
class _Predicate>
784 remove_if(_Predicate __pred)
786 if (!this->_M_iterators && !this->_M_const_iterators)
787 return _Base::remove_if(__pred);
789#if !_GLIBCXX_USE_CXX11_ABI
790 size_type __removed __attribute__((__unused__)) = 0;
792 _Base __to_destroy(get_allocator());
793 for (_Base_iterator __x = _Base::begin(); __x != _Base::end(); )
795 _Base_iterator __next = __x;
799 this->_M_invalidate_if(_Equal(__x));
800 __to_destroy.splice(__to_destroy.begin(), *
this, __x);
801#if !_GLIBCXX_USE_CXX11_ABI
802 _GLIBCXX20_ONLY( __removed++ );
809#if !_GLIBCXX_USE_CXX11_ABI
810 return _GLIBCXX20_ONLY( __removed );
812 return _GLIBCXX20_ONLY( __to_destroy.size() );
816 _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
820 if (!this->_M_iterators && !this->_M_const_iterators)
821 return _Base::unique();
824 return _GLIBCXX20_ONLY(0);
826#if !_GLIBCXX_USE_CXX11_ABI
827 size_type __removed __attribute__((__unused__)) = 0;
829 _Base __to_destroy(get_allocator());
830 _Base_iterator __first = _Base::begin();
831 _Base_iterator __last = _Base::end();
832 _Base_iterator __next = __first;
833 while (++__next != __last)
834 if (*__first == *__next)
836 this->_M_invalidate_if(_Equal(__next));
837 __to_destroy.splice(__to_destroy.begin(), *
this, __next);
839#if !_GLIBCXX_USE_CXX11_ABI
840 _GLIBCXX20_ONLY( __removed++ );
846#if !_GLIBCXX_USE_CXX11_ABI
847 return _GLIBCXX20_ONLY( __removed );
849 return _GLIBCXX20_ONLY( __to_destroy.size() );
853 template<
class _BinaryPredicate>
855 unique(_BinaryPredicate __binary_pred)
857 if (!this->_M_iterators && !this->_M_const_iterators)
858 return _Base::unique(__binary_pred);
861 return _GLIBCXX20_ONLY(0);
864#if !_GLIBCXX_USE_CXX11_ABI
865 size_type __removed __attribute__((__unused__)) = 0;
867 _Base __to_destroy(get_allocator());
868 _Base_iterator __first = _Base::begin();
869 _Base_iterator __last = _Base::end();
870 _Base_iterator __next = __first;
871 while (++__next != __last)
872 if (__binary_pred(*__first, *__next))
874 this->_M_invalidate_if(_Equal(__next));
875 __to_destroy.splice(__to_destroy.begin(), *
this, __next);
877#if !_GLIBCXX_USE_CXX11_ABI
878 _GLIBCXX20_ONLY( __removed++ );
884#if !_GLIBCXX_USE_CXX11_ABI
885 return _GLIBCXX20_ONLY( __removed );
887 return _GLIBCXX20_ONLY( __to_destroy.size() );
891#undef _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
892#undef _GLIBCXX20_ONLY
895#if __cplusplus >= 201103L
905 __glibcxx_check_sorted(_Base::begin(), _Base::end());
906 __glibcxx_check_sorted(__x.begin().
base(), __x.end().
base());
907 this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
908 _Base::merge(_GLIBCXX_MOVE(__x));
912#if __cplusplus >= 201103L
918 template<
class _Compare>
920#if __cplusplus >= 201103L
921 merge(list&& __x, _Compare __comp)
923 merge(list& __x, _Compare __comp)
934 this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
935 _Base::merge(_GLIBCXX_MOVE(__x), __comp);
939#if __cplusplus >= 201103L
940 template<
typename _Compare>
942 merge(list& __x, _Compare __comp)
947 sort() { _Base::sort(); }
949 template<
typename _StrictWeakOrdering>
951 sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
953 using _Base::reverse;
956 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
959 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }