30#ifndef _FORWARD_LIST_H
31#define _FORWARD_LIST_H 1
34#pragma GCC system_header
49#if __glibcxx_containers_ranges
54#if ! defined _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
55# define _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST 1
58namespace std _GLIBCXX_VISIBILITY(default)
60_GLIBCXX_BEGIN_NAMESPACE_VERSION
61_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
69 struct _Fwd_list_node_base
71 using _Base_ptr = _Fwd_list_node_base*;
73 _Fwd_list_node_base() =
default;
74 _Fwd_list_node_base(_Fwd_list_node_base&& __x) noexcept
75 : _M_next(__x._M_next)
76 { __x._M_next =
nullptr; }
78 _Fwd_list_node_base(
const _Fwd_list_node_base&) =
delete;
79 _Fwd_list_node_base& operator=(
const _Fwd_list_node_base&) =
delete;
82 operator=(_Fwd_list_node_base&& __x)
noexcept
84 _M_next = __x._M_next;
85 __x._M_next =
nullptr;
89 _Fwd_list_node_base* _M_next =
nullptr;
92 _M_transfer_after(_Fwd_list_node_base* __begin,
93 _Fwd_list_node_base* __end)
noexcept
95 _Fwd_list_node_base* __keep = __begin->_M_next;
98 __begin->_M_next = __end->_M_next;
99 __end->_M_next = _M_next;
102 __begin->_M_next =
nullptr;
108 _M_reverse_after()
noexcept
110 _Fwd_list_node_base* __tail = _M_next;
113 while (_Fwd_list_node_base* __temp = __tail->_M_next)
115 _Fwd_list_node_base* __keep = _M_next;
117 __tail->_M_next = __temp->_M_next;
118 _M_next->_M_next = __keep;
122 _Fwd_list_node_base* _M_base_ptr() {
return this; }
123 const _Fwd_list_node_base* _M_base_ptr()
const {
return this; }
132 template<
typename _Tp>
133 struct _Fwd_list_node
134 :
public _Fwd_list_node_base
136 using _Node_ptr = _Fwd_list_node*;
138 _Fwd_list_node() =
default;
140 __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
144 {
return _M_storage._M_ptr(); }
147 _M_valptr()
const noexcept
148 {
return _M_storage._M_ptr(); }
162 template<
typename _Tp>
163 struct _Fwd_list_iterator
165 typedef _Fwd_list_iterator<_Tp> _Self;
168 typedef _Tp value_type;
169 typedef _Tp* pointer;
170 typedef _Tp& reference;
171 typedef ptrdiff_t difference_type;
174 _Fwd_list_iterator() noexcept
183 operator*()
const noexcept
184 {
return *
static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
188 operator->()
const noexcept
189 {
return static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
192 operator++()
noexcept
194 _M_node = _M_node->_M_next;
199 operator++(
int)
noexcept
202 _M_node = _M_node->_M_next;
212 {
return __x._M_node == __y._M_node; }
214#if __cpp_impl_three_way_comparison < 201907L
220 operator!=(
const _Self& __x,
const _Self& __y)
noexcept
221 {
return __x._M_node != __y._M_node; }
225 template<
typename,
typename>
226 friend class forward_list;
227 template<
typename,
typename>
228 friend struct _Fwd_list_base;
229 friend struct _Fwd_list_const_iterator<_Tp>;
232 _M_next() const noexcept
235 return _Fwd_list_iterator(_M_node->_M_next);
237 return _Fwd_list_iterator(
nullptr);
240 _Fwd_list_node_base* _M_node;
248 template<
typename _Tp>
249 struct _Fwd_list_const_iterator
251 typedef _Fwd_list_const_iterator<_Tp> _Self;
255 typedef _Tp value_type;
256 typedef const _Tp* pointer;
257 typedef const _Tp& reference;
258 typedef ptrdiff_t difference_type;
261 _Fwd_list_const_iterator() noexcept
268 _Fwd_list_const_iterator(
const iterator& __iter) noexcept
269 : _M_node(__iter._M_node) { }
273 operator*()
const noexcept
274 {
return *
static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
278 operator->()
const noexcept
279 {
return static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
282 operator++()
noexcept
284 _M_node = _M_node->_M_next;
289 operator++(
int)
noexcept
292 _M_node = _M_node->_M_next;
302 {
return __x._M_node == __y._M_node; }
304#if __cpp_impl_three_way_comparison < 201907L
310 operator!=(
const _Self& __x,
const _Self& __y)
noexcept
311 {
return __x._M_node != __y._M_node; }
315 template<
typename,
typename>
316 friend class forward_list;
317 template<
typename,
typename>
318 friend struct _Fwd_list_base;
321 _M_next() const noexcept
324 return _Fwd_list_const_iterator(_M_node->_M_next);
326 return _Fwd_list_const_iterator(
nullptr);
329 _Fwd_list_iterator<_Tp>
330 _M_const_cast() const noexcept
332 return _Fwd_list_iterator<_Tp>(
333 const_cast<_Fwd_list_node_base*
>(_M_node));
336 const _Fwd_list_node_base* _M_node;
339 template<
typename _Tp,
typename _Allocator>
class forward_list;
340 template<
typename _Tp,
typename _Allocator>
struct _Fwd_list_base;
344#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
346 template<
typename _Vo
idPtr>
351 _Node_base() =
default;
353 _Node_base(_Node_base&& __x) noexcept
354 : _M_next(__x._M_next)
355 { __x._M_next =
nullptr; }
357 _Node_base(
const _Node_base&) =
delete;
358 _Node_base& operator=(
const _Node_base&) =
delete;
361 operator=(_Node_base&& __x)
noexcept
363 _M_next = __x._M_next;
364 __x._M_next =
nullptr;
368 _Base_ptr _M_next =
nullptr;
372 _M_transfer_after(_Base_ptr __begin, _Base_ptr __end)
noexcept
374 _Base_ptr __keep = __begin->_M_next;
377 __begin->_M_next = __end->_M_next;
378 __end->_M_next = _M_next;
381 __begin->_M_next =
nullptr;
387 _M_reverse_after()
noexcept
389 _Base_ptr __tail = _M_next;
392 while (_Base_ptr __temp = __tail->_M_next)
394 _Base_ptr __keep = _M_next;
396 __tail->_M_next = __temp->_M_next;
397 _M_next->_M_next = __keep;
416 template<
typename _ValPtr>
418 :
public _Node_base<__ptr_rebind<_ValPtr, void>>
420 using value_type =
typename pointer_traits<_ValPtr>::element_type;
425 _Node(_Node&&) =
delete;
427 union _Uninit_storage
429 _Uninit_storage()
noexcept { }
430 ~_Uninit_storage() { }
432#if ! _GLIBCXX_INLINE_VERSION
434 alignas(__alignof__(value_type))
438 _Uninit_storage _M_u;
445 _M_valptr()
const noexcept
450 {
return pointer_traits<_Node_ptr>::pointer_to(*
this); }
454 template<
bool _Const,
typename _Ptr>
461 template<
typename _Tp>
462 using __maybe_const = __conditional_t<_Const, const _Tp, _Tp>;
465 using value_type =
typename pointer_traits<_Ptr>::element_type;
466 using difference_type = ptrdiff_t;
468 using pointer = __maybe_const<value_type>*;
469 using reference = __maybe_const<value_type>&;
471 constexpr _Iterator() noexcept : _M_node() { }
473 _Iterator(
const _Iterator&) =
default;
474 _Iterator& operator=(
const _Iterator&) =
default;
476#ifdef __glibcxx_concepts
478 _Iterator(
const _Iterator<false, _Ptr>& __i)
requires _Const
480 template<
bool _OtherConst,
481 typename = __enable_if_t<_Const && !_OtherConst>>
483 _Iterator(
const _Iterator<_OtherConst, _Ptr>& __i)
485 : _M_node(__i._M_node) { }
488 _Iterator(_Base_ptr __x) noexcept
493 operator*()
const noexcept
494 {
return static_cast<_Node&
>(*this->_M_node)._M_u._M_data; }
498 operator->()
const noexcept
499 {
return static_cast<_Node&
>(*this->_M_node)._M_valptr(); }
501 _GLIBCXX14_CONSTEXPR _Iterator&
502 operator++()
noexcept
504 _M_node = _M_node->_M_next;
508 _GLIBCXX14_CONSTEXPR _Iterator
509 operator++(
int)
noexcept
511 _Iterator __tmp(*
this);
512 _M_node = _M_node->_M_next;
520 friend constexpr bool
521 operator==(
const _Iterator& __x,
const _Iterator& __y)
noexcept
522 {
return __x._M_node == __y._M_node; }
524#if __cpp_impl_three_way_comparison < 201907L
529 friend constexpr bool
531 {
return __x._M_node != __y._M_node; }
535 template<
typename _Tp,
typename _Allocator>
536 friend class _GLIBCXX_STD_C::forward_list;
537 template<
typename _Tp,
typename _Allocator>
538 friend struct _GLIBCXX_STD_C::_Fwd_list_base;
540 constexpr _Iterator<false, _Ptr>
541 _M_const_cast() const noexcept
542 {
return _Iterator<false, _Ptr>(_M_node); }
544 friend _Iterator<!_Const, _Ptr>;
547 _M_next() const noexcept
548 {
return _Iterator(_M_node ? _M_node->_M_next :
nullptr); }
555 template<
typename _Tp,
typename _Ptr>
558#if _GLIBCXX_USE_ALLOC_PTR_FOR_LIST <= 9000
562 template<
typename _Tp>
563 struct _Node_traits<_Tp, _Tp*>
566 using _Node = _Fwd_list_node<_Tp>;
567 using _Iterator = _Fwd_list_iterator<_Tp>;
568 using _Const_iterator = _Fwd_list_const_iterator<_Tp>;
572#if ! _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
574 template<
typename _Tp,
typename _Ptr>
576 : _Node_traits<_Tp, _Tp*>
580 template<
typename _Tp,
typename _Ptr>
585 using _ValPtr = __ptr_rebind<_Ptr, _Tp>;
588 using _Node_base = __fwdlist::_Node_base<_VoidPtr>;
589 using _Node = __fwdlist::_Node<_ValPtr>;
590 using _Iterator = __fwdlist::_Iterator<false, _ValPtr>;
591 using _Const_iterator = __fwdlist::_Iterator<true, _ValPtr>;
599 template<
typename _Tp,
typename _Alloc>
600 struct _Fwd_list_base
602#if __cplusplus > 201703L || defined __STRICT_ANSI__
606 using _Tp_alloc_traits
608 using pointer =
typename _Tp_alloc_traits::pointer;
612 using _Node_traits = __fwdlist::_Node_traits<_Tp, pointer>;
613 using _Node =
typename _Node_traits::_Node;
614 using _Node_alloc_type = __alloc_rebind<_Alloc, _Node>;
616 using _Node_ptr =
typename _Node_alloc_traits::pointer;
617 using _Base_ptr =
typename _Node_traits::_Node_base::_Base_ptr;
619 struct _Fwd_list_impl
620 :
public _Node_alloc_type
622 typename _Node_traits::_Node_base _M_head;
626 : _Node_alloc_type(), _M_head()
629 _Fwd_list_impl(_Fwd_list_impl&&) =
default;
631 _Fwd_list_impl(_Fwd_list_impl&& __fl, _Node_alloc_type&& __a)
635 _Fwd_list_impl(_Node_alloc_type&& __a)
636 : _Node_alloc_type(
std::move(__a)), _M_head()
640 _Fwd_list_impl _M_impl;
643 using iterator =
typename _Node_traits::_Iterator;
644 using const_iterator =
typename _Node_traits::_Const_iterator;
647 _M_get_Node_allocator()
noexcept
648 {
return this->_M_impl; }
650 const _Node_alloc_type&
651 _M_get_Node_allocator()
const noexcept
652 {
return this->_M_impl; }
654 _Fwd_list_base() =
default;
656 _Fwd_list_base(_Node_alloc_type&& __a)
660 _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a,
666 _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a);
668 _Fwd_list_base(_Fwd_list_base&&) =
default;
671 { _M_erase_after(_M_impl._M_head._M_base_ptr(),
nullptr); }
674#if ! _GLIBCXX_INLINE_VERSION
680 return std::__to_address(__ptr);
685 _M_put_node(_Node_ptr __p)
687#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
690 typedef typename _Node_alloc_traits::pointer _Ptr;
691 auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__p);
696 template<
typename... _Args>
698 _M_create_node(_Args&&... __args)
700 auto& __alloc = _M_get_Node_allocator();
701 auto __guard = std::__allocate_guarded_obj(__alloc);
702 _Node_alloc_traits::construct(__alloc, __guard->_M_valptr(),
704 auto __p = __guard.release();
705#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
708 return std::__to_address(__p);
712#pragma GCC diagnostic push
713#pragma GCC diagnostic ignored "-Wc++17-extensions"
715 _M_destroy_node(_Node_ptr __p)
717 auto& __alloc = _M_get_Node_allocator();
719 _Node_alloc_traits::destroy(__alloc, __p->_M_valptr());
725#pragma GCC diagnostic pop
727 template<
typename... _Args>
729 _M_insert_after(const_iterator __pos, _Args&&... __args);
732 _M_erase_after(_Base_ptr __pos);
735 _M_erase_after(_Base_ptr __pos, _Base_ptr __last);
766 template<
typename _Tp,
typename _Alloc = allocator<_Tp>>
770 "std::forward_list must have a non-const, non-volatile value_type");
771#if __cplusplus > 201703L || defined __STRICT_ANSI__
773 "std::forward_list must have the same value_type as its allocator");
777 typedef _Fwd_list_base<_Tp, _Alloc> _Base;
779 typedef typename _Base::_Node _Node;
780 typedef typename _Base::_Node_alloc_type _Node_alloc_type;
781 typedef typename _Base::_Node_alloc_traits _Node_alloc_traits;
786 typedef _Tp value_type;
789 typedef value_type& reference;
790 typedef const value_type& const_reference;
792 typedef typename _Base::iterator iterator;
793 typedef typename _Base::const_iterator const_iterator;
794 typedef std::size_t size_type;
795 typedef std::ptrdiff_t difference_type;
796 typedef _Alloc allocator_type;
811 : _Base(_Node_alloc_type(__al))
820 const __type_identity_t<_Alloc>& __al)
821 : _Base(_Node_alloc_type(__al))
822 { _M_range_initialize(__list.begin(), __list.end()); }
832 std::__make_move_if_noexcept_iterator(__list.begin()),
833 std::__make_move_if_noexcept_iterator(__list.end()));
836 forward_list(forward_list&& __list, _Node_alloc_type&& __al,
839 : _Base(
std::move(__list), _Node_alloc_type(__al), true_type{})
849 const __type_identity_t<_Alloc>& __al)
850 noexcept(_Node_alloc_traits::_S_always_equal())
852 typename _Node_alloc_traits::is_always_equal{})
865 : _Base(_Node_alloc_type(__al))
866 { _M_default_initialize(__n); }
878 const _Alloc& __al = _Alloc())
879 : _Base(_Node_alloc_type(__al))
880 { _M_fill_initialize(__n, __value); }
892 template<
typename _InputIterator,
893 typename = std::_RequireInputIter<_InputIterator>>
895 const _Alloc& __al = _Alloc())
896 : _Base(_Node_alloc_type(__al))
897 { _M_range_initialize(__first, __last); }
899#if __glibcxx_containers_ranges
908 template<__detail::__container_compatible_range<_Tp> _Rg>
909 forward_list(from_range_t, _Rg&& __rg,
const _Alloc& __a = _Alloc())
910 : _Base(_Node_alloc_type(__a))
912 auto __to = this->_M_impl._M_head._M_base_ptr();
913 auto __first = ranges::begin(__rg);
914 const auto __last = ranges::end(__rg);
915 for (; __first != __last; ++__first)
917 __to->_M_next = this->_M_create_node(*__first)->_M_base_ptr();
918 __to = __to->_M_next;
929 : _Base(_Node_alloc_traits::_S_select_on_copy(
930 __list._M_get_Node_allocator()))
931 { _M_range_initialize(__list.begin(), __list.end()); }
953 const _Alloc& __al = _Alloc())
954 : _Base(_Node_alloc_type(__al))
955 { _M_range_initialize(__il.begin(), __il.end()); }
975#pragma GCC diagnostic push
976#pragma GCC diagnostic ignored "-Wc++17-extensions"
991 noexcept(_Node_alloc_traits::_S_nothrow_move())
993 constexpr bool __move_storage =
994 _Node_alloc_traits::_S_propagate_on_move_assign()
995 || _Node_alloc_traits::_S_always_equal();
996 if constexpr (!__move_storage)
998 if (__list._M_get_Node_allocator() != this->_M_get_Node_allocator())
1002 this->
assign(std::make_move_iterator(__list.begin()),
1003 std::make_move_iterator(__list.end()));
1009 this->_M_impl._M_head._M_next = __list._M_impl._M_head._M_next;
1010 __list._M_impl._M_head._M_next =
nullptr;
1011 if constexpr (_Node_alloc_traits::_S_propagate_on_move_assign())
1012 this->_M_get_Node_allocator()
1013 =
std::move(__list._M_get_Node_allocator());
1044 template<
typename _InputIterator,
1045 typename = std::_RequireInputIter<_InputIterator>>
1047 assign(_InputIterator __first, _InputIterator __last)
1049 if constexpr (
is_assignable<_Tp,
decltype(*__first)>::value)
1052 auto __curr =
begin();
1054 while (__curr != __end && __first != __last)
1061 if (__first != __last)
1063 else if (__curr != __end)
1072#pragma GCC diagnostic pop
1074#if __glibcxx_containers_ranges
1079 template<__detail::__container_compatible_range<_Tp> _Rg>
1081 assign_range(_Rg&& __rg)
1083 static_assert(assignable_from<_Tp&, ranges::range_reference_t<_Rg>>);
1085 auto __first = ranges::begin(__rg);
1086 const auto __last = ranges::end(__rg);
1091 while (__curr != __end && __first != __last)
1099 if (__curr != __end)
1102 insert_range_after(__prev,
1103 ranges::subrange(
std::move(__first), __last));
1107#pragma GCC diagnostic push
1108#pragma GCC diagnostic ignored "-Wc++17-extensions"
1125 auto __curr =
begin();
1127 while (__curr != __end && __n > 0)
1136 else if (__curr != __end)
1145#pragma GCC diagnostic pop
1157 {
assign(__il.begin(), __il.end()); }
1162 {
return allocator_type(this->_M_get_Node_allocator()); }
1173 {
return iterator(this->_M_impl._M_head._M_base_ptr()); }
1183 {
return const_iterator(this->_M_impl._M_head._M_base_ptr()); }
1192 {
return iterator(this->_M_impl._M_head._M_next); }
1202 {
return const_iterator(this->_M_impl._M_head._M_next); }
1212 {
return iterator(
nullptr); }
1222 {
return const_iterator(
nullptr); }
1232 {
return const_iterator(this->_M_impl._M_head._M_next); }
1242 {
return const_iterator(this->_M_impl._M_head._M_base_ptr()); }
1252 {
return const_iterator(
nullptr); }
1261 {
return this->_M_impl._M_head._M_next ==
nullptr; }
1281 __glibcxx_requires_nonempty();
1282 _Node& __front =
static_cast<_Node&
>(*this->_M_impl._M_head._M_next);
1283 return *__front._M_valptr();
1294 __glibcxx_requires_nonempty();
1295 _Node& __front =
static_cast<_Node&
>(*this->_M_impl._M_head._M_next);
1296 return *__front._M_valptr();
1312 template<
typename... _Args>
1313#if __cplusplus > 201402L
1322#if __cplusplus > 201402L
1348#if __glibcxx_containers_ranges
1364 template<__detail::__container_compatible_range<_Tp> _Rg>
1366 prepend_range(_Rg&& __rg)
1390 __glibcxx_requires_nonempty();
1391 this->_M_erase_after(this->_M_impl._M_head._M_base_ptr());
1407 template<
typename... _Args>
1410 {
return iterator(this->_M_insert_after(__pos,
1427 {
return iterator(this->_M_insert_after(__pos, __val)); }
1469 template<
typename _InputIterator,
1470 typename = std::_RequireInputIter<_InputIterator>>
1473 _InputIterator __first, _InputIterator __last);
1492 {
return insert_after(__pos, __il.begin(), __il.end()); }
1494#if __glibcxx_containers_ranges
1510 template<__detail::__container_compatible_range<_Tp> _Rg>
1512 insert_range_after(const_iterator __position, _Rg&& __rg)
1516 return _M_splice_after(__position, __tmp.before_begin(), __tmp.end());
1539 {
return iterator(this->_M_erase_after(__pos._M_const_cast()._M_node)); }
1563 return iterator(this->_M_erase_after(__pos._M_const_cast()._M_node,
1564 __last._M_const_cast()._M_node));
1582 std::swap(this->_M_impl._M_head._M_next,
1583 __list._M_impl._M_head._M_next);
1584 _Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(),
1585 __list._M_get_Node_allocator());
1615 resize(size_type __sz,
const value_type& __val);
1627 { this->_M_erase_after(this->_M_impl._M_head._M_base_ptr(),
nullptr); }
1645 if (!__list.empty())
1646 _M_splice_after(__pos, __list.before_begin(), __list.end());
1665 const_iterator __i)
noexcept;
1669 const_iterator __i)
noexcept
1688 const_iterator __before, const_iterator __last)
noexcept
1689 { _M_splice_after(__pos, __before, __last); }
1693 const_iterator __before, const_iterator __last)
noexcept
1694 { _M_splice_after(__pos, __before, __last); }
1698#ifdef __glibcxx_list_remove_return_type
1700# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG \
1701 __attribute__((__abi_tag__("__cxx20")))
1703 using __remove_return_type = void;
1704# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG
1719 _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG
1720 __remove_return_type
1734 template<
typename _Pred>
1735 __remove_return_type
1748 _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG
1749 __remove_return_type
1753#undef _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG
1767 template<
typename _BinPred>
1768 __remove_return_type
1799 template<
typename _Comp>
1803 template<
typename _Comp>
1824 template<
typename _Comp>
1835 { this->_M_impl._M_head._M_reverse_after(); }
1839 template<
typename _InputIterator>
1841 _M_range_initialize(_InputIterator __first, _InputIterator __last);
1850 _M_splice_after(const_iterator __pos, const_iterator __before,
1851 const_iterator __last);
1859 _M_default_insert_after(const_iterator __pos,
size_type __n);
1861#if ! _GLIBCXX_INLINE_VERSION
1862#pragma GCC diagnostic push
1863#pragma GCC diagnostic ignored "-Wc++17-extensions"
1879#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
1884 this->_M_impl._M_head._M_next = __list._M_impl._M_head._M_next;
1885 __list._M_impl._M_head._M_next =
nullptr;
1886 std::__alloc_on_move(this->_M_get_Node_allocator(),
1887 __list._M_get_Node_allocator());
1894#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
1895 if constexpr (is_same<typename _Alloc_traits::pointer, _Tp*>::value)
1898 if (__list._M_get_Node_allocator() == this->_M_get_Node_allocator())
1903 this->
assign(std::make_move_iterator(__list.
begin()),
1904 std::make_move_iterator(__list.
end()));
1909 _M_assign_n(size_type __n,
const _Tp& __val,
true_type)
1911#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
1912 if constexpr (is_same<typename _Alloc_traits::pointer, _Tp*>::value)
1916 auto __curr =
begin();
1918 while (__curr != __end && __n > 0)
1927 else if (__curr != __end)
1933 _M_assign_n(size_type __n,
const _Tp& __val,
false_type)
1935#if _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
1936 if constexpr (is_same<typename _Alloc_traits::pointer, _Tp*>::value)
1943#pragma GCC diagnostic pop
1947#if __cpp_deduction_guides >= 201606
1948 template<
typename _InputIterator,
typename _ValT
1951 typename = _RequireInputIter<_InputIterator>,
1952 typename = _RequireAllocator<_Allocator>>
1953 forward_list(_InputIterator, _InputIterator, _Allocator = _Allocator())
1956#if __glibcxx_containers_ranges
1957 template<ranges::input_range _Rg,
1959 forward_list(from_range_t, _Rg&&, _Allocator = _Allocator())
1974 template<
typename _Tp,
typename _Alloc>
1980#if __cpp_lib_three_way_comparison
1992 template<
typename _Tp,
typename _Alloc>
1994 inline __detail::__synth3way_t<_Tp>
2000 __detail::__synth3way);
2015 template<
typename _Tp,
typename _Alloc>
2018 operator<(
const forward_list<_Tp, _Alloc>& __lx,
2019 const forward_list<_Tp, _Alloc>& __ly)
2020 {
return std::lexicographical_compare(__lx.cbegin(), __lx.cend(),
2021 __ly.cbegin(), __ly.cend()); }
2024 template<
typename _Tp,
typename _Alloc>
2029 {
return !(__lx == __ly); }
2032 template<
typename _Tp,
typename _Alloc>
2037 {
return (__ly < __lx); }
2040 template<
typename _Tp,
typename _Alloc>
2045 {
return !(__lx < __ly); }
2048 template<
typename _Tp,
typename _Alloc>
2053 {
return !(__ly < __lx); }
2057 template<
typename _Tp,
typename _Alloc>
2061 noexcept(
noexcept(__lx.swap(__ly)))
2062 { __lx.swap(__ly); }
2064_GLIBCXX_END_NAMESPACE_CONTAINER
2065_GLIBCXX_END_NAMESPACE_VERSION
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
constexpr auto lexicographical_compare_three_way(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2, _Comp __comp) -> decltype(__comp(*__first1, *__first2))
Performs dictionary comparison on ranges.
ISO C++ entities toplevel namespace is std.
typename pointer_traits< _Ptr >::template rebind< _Tp > __ptr_rebind
Convenience alias for rebinding pointers.
is_nothrow_default_constructible
is_trivially_destructible
Uniform interface to all allocator types.
__detected_or_t< value_type *, __pointer, _Alloc > pointer
The allocator's pointer type.
typename _Ptr< __c_pointer, const value_type >::type const_pointer
The standard allocator, as per C++03 [20.4.1].
A helper basic node class for forward_list.
A helper node class for forward_list. This is just a linked list with uninitialized storage for a dat...
A forward_list::const_iterator.
friend bool operator==(const _Self &__x, const _Self &__y) noexcept
Forward list const_iterator equality comparison.
A forward_list::iterator.
friend bool operator==(const _Self &__x, const _Self &__y) noexcept
Forward list iterator equality comparison.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
iterator insert_after(const_iterator __pos, _InputIterator __first, _InputIterator __last)
Inserts a range into the forward_list.
__remove_return_type unique(_BinPred __binary_pred)
Remove consecutive elements satisfying a predicate.
void merge(forward_list &&__list, _Comp __comp)
Merge sorted lists according to comparison function.
iterator begin() noexcept
const_iterator before_begin() const noexcept
void reverse() noexcept
Reverse the elements in list.
forward_list()=default
Creates a forward_list with no elements.
~forward_list() noexcept
The forward_list dtor.
iterator erase_after(const_iterator __pos)
Removes the element pointed to by the iterator following pos.
void swap(forward_list &__list) noexcept
Swaps data with another forward_list.
void sort(_Comp __comp)
Sort the forward_list using a comparison function.
const_reference front() const
void merge(forward_list &&__list)
Merge sorted lists.
forward_list(const _Alloc &__al) noexcept
Creates a forward_list with no elements.
iterator insert_after(const_iterator __pos, size_type __n, const _Tp &__val)
Inserts a number of copies of given data into the forward_list.
void sort()
Sort the elements of the list.
iterator before_begin() noexcept
forward_list(const forward_list &__list, const __type_identity_t< _Alloc > &__al)
Copy constructor with allocator argument.
iterator emplace_after(const_iterator __pos, _Args &&... __args)
Constructs object in forward_list after the specified iterator.
forward_list(const forward_list &__list)
The forward_list copy constructor.
iterator insert_after(const_iterator __pos, const _Tp &__val)
Inserts given value into forward_list after specified iterator.
forward_list & operator=(forward_list &&__list) noexcept(_Node_alloc_traits::_S_nothrow_move())
The forward_list move assignment operator.
void resize(size_type __sz)
Resizes the forward_list to the specified number of elements.
forward_list & operator=(const forward_list &__list)
The forward_list assignment operator.
__remove_return_type remove_if(_Pred __pred)
Remove all elements satisfying a predicate.
forward_list(size_type __n, const _Tp &__value, const _Alloc &__al=_Alloc())
Creates a forward_list with copies of an exemplar element.
void assign(size_type __n, const _Tp &__val)
Assigns a given value to a forward_list.
const_iterator begin() const noexcept
void splice_after(const_iterator __pos, forward_list &&__list) noexcept
Insert contents of another forward_list.
const_iterator cbefore_begin() const noexcept
forward_list & operator=(std::initializer_list< _Tp > __il)
The forward_list initializer list assignment operator.
forward_list(std::initializer_list< _Tp > __il, const _Alloc &__al=_Alloc())
Builds a forward_list from an initializer_list.
reference emplace_front(_Args &&... __args)
Constructs object in forward_list at the front of the list.
forward_list(size_type __n, const _Alloc &__al=_Alloc())
Creates a forward_list with default constructed elements.
iterator insert_after(const_iterator __pos, std::initializer_list< _Tp > __il)
Inserts the contents of an initializer_list into forward_list after the specified iterator.
const_iterator end() const noexcept
void splice_after(const_iterator __pos, forward_list &&, const_iterator __before, const_iterator __last) noexcept
Insert range from another forward_list.
forward_list(forward_list &&__list, const __type_identity_t< _Alloc > &__al) noexcept(_Node_alloc_traits::_S_always_equal())
Move constructor with allocator argument.
void splice_after(const_iterator __pos, forward_list &&__list, const_iterator __i) noexcept
Insert element from another forward_list.
iterator erase_after(const_iterator __pos, const_iterator __last)
Remove a range of elements.
__remove_return_type unique()
Remove consecutive duplicate elements.
void clear() noexcept
Erases all the elements.
__remove_return_type remove(const _Tp &__val)
Remove all elements equal to value.
const_iterator cend() const noexcept
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a forward_list.
bool empty() const noexcept
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
void resize(size_type __sz, const value_type &__val)
Resizes the forward_list to the specified number of elements.
void push_front(const _Tp &__val)
Add data to the front of the forward_list.
forward_list(forward_list &&)=default
The forward_list move constructor.
forward_list(_InputIterator __first, _InputIterator __last, const _Alloc &__al=_Alloc())
Builds a forward_list from a range.
void splice_after(const_iterator __pos, forward_list &, const_iterator __before, const_iterator __last) noexcept
Insert range from another forward_list.
const_iterator cbegin() const noexcept
void pop_front()
Removes first element.
void assign(std::initializer_list< _Tp > __il)
Assigns an initializer_list to a forward_list.
size_type max_size() const noexcept
Base class for forward_list.
The node-base type for allocators that use fancy pointers.
A helper node class for forward_list.
A forward_list iterator when the allocator uses fancy pointers.
friend constexpr bool operator==(const _Iterator &__x, const _Iterator &__y) noexcept
Forward list iterator equality comparison.
Uniform interface to all pointer-like types.
One of the comparison functors.
One of the comparison functors.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.
static constexpr pointer allocate(_Node_alloc_type &__a, size_type __n)
static constexpr void deallocate(_Node_alloc_type &__a, pointer __p, size_type __n)
static constexpr size_type max_size(const _Node_alloc_type &__a) noexcept