30#ifndef _FORWARD_LIST_H
31#define _FORWARD_LIST_H 1
33#pragma GCC system_header
44namespace std _GLIBCXX_VISIBILITY(default)
46_GLIBCXX_BEGIN_NAMESPACE_VERSION
47_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
58 : _M_next(__x._M_next)
59 { __x._M_next =
nullptr; }
67 _M_next = __x._M_next;
68 __x._M_next =
nullptr;
81 __begin->_M_next = __end->_M_next;
82 __end->_M_next = _M_next;
85 __begin->_M_next =
nullptr;
91 _M_reverse_after()
noexcept
101 _M_next->_M_next =
__keep;
112 template<
typename _Tp>
118 __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
122 {
return _M_storage._M_ptr(); }
125 _M_valptr()
const noexcept
126 {
return _M_storage._M_ptr(); }
134 template<
typename _Tp>
140 typedef _Tp value_type;
141 typedef _Tp* pointer;
142 typedef _Tp& reference;
143 typedef ptrdiff_t difference_type;
155 operator*()
const noexcept
156 {
return *
static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
160 operator->()
const noexcept
161 {
return static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
164 operator++()
noexcept
166 _M_node = _M_node->_M_next;
171 operator++(
int)
noexcept
174 _M_node = _M_node->_M_next;
184 {
return __x._M_node == __y._M_node; }
186#if __cpp_impl_three_way_comparison < 201907L
192 operator!=(
const _Self& __x,
const _Self& __y)
noexcept
193 {
return __x._M_node != __y._M_node; }
197 _M_next() const noexcept
200 return _Fwd_list_iterator(_M_node->_M_next);
202 return _Fwd_list_iterator(
nullptr);
205 _Fwd_list_node_base* _M_node;
213 template<
typename _Tp>
220 typedef _Tp value_type;
221 typedef const _Tp* pointer;
222 typedef const _Tp& reference;
223 typedef ptrdiff_t difference_type;
234 : _M_node(__iter._M_node) { }
238 operator*()
const noexcept
239 {
return *
static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
243 operator->()
const noexcept
244 {
return static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
247 operator++()
noexcept
249 _M_node = _M_node->_M_next;
254 operator++(
int)
noexcept
257 _M_node = _M_node->_M_next;
267 {
return __x._M_node == __y._M_node; }
269#if __cpp_impl_three_way_comparison < 201907L
275 operator!=(
const _Self& __x,
const _Self& __y)
noexcept
276 {
return __x._M_node != __y._M_node; }
280 _M_next() const noexcept
283 return _Fwd_list_const_iterator(_M_node->_M_next);
285 return _Fwd_list_const_iterator(
nullptr);
288 const _Fwd_list_node_base* _M_node;
294 template<
typename _Tp,
typename _Alloc>
301 struct _Fwd_list_impl
302 :
public _Node_alloc_type
308 : _Node_alloc_type(), _M_head()
311 _Fwd_list_impl(_Fwd_list_impl&&) =
default;
313 _Fwd_list_impl(_Fwd_list_impl&&
__fl, _Node_alloc_type&& __a)
317 _Fwd_list_impl(_Node_alloc_type&& __a)
318 : _Node_alloc_type(
std::move(__a)), _M_head()
322 _Fwd_list_impl _M_impl;
330 _M_get_Node_allocator()
noexcept
331 {
return this->_M_impl; }
333 const _Node_alloc_type&
334 _M_get_Node_allocator()
const noexcept
335 {
return this->_M_impl; }
354 { _M_erase_after(&_M_impl._M_head,
nullptr); }
361 return std::__to_address(
__ptr);
364 template<
typename...
_Args>
372 _Node_alloc_traits::construct(_M_get_Node_allocator(),
378 this->_M_put_node(
__node);
379 __throw_exception_again;
384 template<
typename...
_Args>
389 _M_put_node(
_Node* __p)
432 template<
typename _Tp,
typename _Alloc = allocator<_Tp>>
436 "std::forward_list must have a non-const, non-volatile value_type");
437#if __cplusplus > 201703L || defined __STRICT_ANSI__
439 "std::forward_list must have the same value_type as its allocator");
452 typedef _Tp value_type;
453 typedef typename _Alloc_traits::pointer pointer;
454 typedef typename _Alloc_traits::const_pointer const_pointer;
455 typedef value_type& reference;
456 typedef const value_type& const_reference;
460 typedef std::size_t size_type;
461 typedef std::ptrdiff_t difference_type;
462 typedef _Alloc allocator_type;
498 std::__make_move_if_noexcept_iterator(
__list.begin()),
499 std::__make_move_if_noexcept_iterator(
__list.end()));
516 noexcept(_Node_alloc_traits::_S_always_equal())
532 { _M_default_initialize(__n); }
544 const _Alloc&
__al = _Alloc())
546 { _M_fill_initialize(__n, __value); }
561 const _Alloc&
__al = _Alloc())
563 { _M_range_initialize(__first, __last); }
572 __list._M_get_Node_allocator()))
595 const _Alloc&
__al = _Alloc())
597 { _M_range_initialize(
__il.begin(),
__il.end()); }
631 noexcept(_Node_alloc_traits::_S_nothrow_move())
634 _Node_alloc_traits::_S_propagate_on_move_assign()
635 || _Node_alloc_traits::_S_always_equal();
673 _M_assign(__first, __last, __assignable());
705 {
return allocator_type(this->_M_get_Node_allocator()); }
716 {
return iterator(&this->_M_impl._M_head); }
735 {
return iterator(this->_M_impl._M_head._M_next); }
804 {
return this->_M_impl._M_head._M_next ==
nullptr; }
853 template<
typename...
_Args>
854#if __cplusplus > 201402L
863#if __cplusplus > 201402L
903 { this->_M_erase_after(&this->_M_impl._M_head); }
918 template<
typename...
_Args>
963 insert_after(const_iterator __pos, size_type __n,
const _Tp& __val);
980 template<
typename _InputIterator,
984 _InputIterator __first, _InputIterator __last);
1025 (
__pos._M_node))); }
1050 (__last._M_node))); }
1067 std::swap(this->_M_impl._M_head._M_next,
1068 __list._M_impl._M_head._M_next);
1069 _Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(),
1070 __list._M_get_Node_allocator());
1100 resize(size_type
__sz,
const value_type& __val);
1112 { this->_M_erase_after(&this->_M_impl._M_head,
nullptr); }
1150 const_iterator __i)
noexcept;
1154 const_iterator __i)
noexcept
1183#if __cplusplus > 201703L
1184# define __cpp_lib_list_remove_return_type 201806L
1185 using __remove_return_type = size_type;
1186# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG \
1187 __attribute__((__abi_tag__("__cxx20")))
1189 using __remove_return_type =
void;
1190# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG
1205 _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG
1206 __remove_return_type
1207 remove(
const _Tp& __val);
1220 template<
typename _Pred>
1221 __remove_return_type
1234 _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG
1235 __remove_return_type
1239#undef _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG
1253 template<
typename _BinPred>
1254 __remove_return_type
1285 template<
typename _Comp>
1289 template<
typename _Comp>
1310 template<
typename _Comp>
1321 { this->_M_impl._M_head._M_reverse_after(); }
1325 template<
typename _InputIterator>
1332 _M_fill_initialize(size_type __n,
const value_type& __value);
1336 _M_splice_after(const_iterator
__pos, const_iterator
__before,
1337 const_iterator __last);
1341 _M_default_initialize(size_type __n);
1345 _M_default_insert_after(const_iterator
__pos, size_type __n);
1352 this->_M_impl._M_head._M_next =
__list._M_impl._M_head._M_next;
1353 __list._M_impl._M_head._M_next =
nullptr;
1355 __list._M_get_Node_allocator());
1362 if (__list._M_get_Node_allocator() == this->_M_get_Node_allocator())
1367 this->
assign(std::make_move_iterator(__list.begin()),
1368 std::make_move_iterator(__list.end()));
1373 template<
typename _InputIterator>
1375 _M_assign(_InputIterator __first, _InputIterator __last,
true_type)
1378 auto __curr =
begin();
1380 while (__curr != __end && __first != __last)
1387 if (__first != __last)
1389 else if (__curr != __end)
1395 template<
typename _InputIterator>
1397 _M_assign(_InputIterator __first, _InputIterator __last,
false_type)
1405 _M_assign_n(size_type __n,
const _Tp& __val,
true_type)
1408 auto __curr =
begin();
1410 while (__curr != __end && __n > 0)
1419 else if (__curr != __end)
1425 _M_assign_n(size_type __n,
const _Tp& __val,
false_type)
1432#if __cpp_deduction_guides >= 201606
1433 template<
typename _InputIterator,
typename _ValT
1434 =
typename iterator_traits<_InputIterator>::value_type,
1435 typename _Allocator = allocator<_ValT>,
1436 typename = _RequireInputIter<_InputIterator>,
1437 typename = _RequireAllocator<_Allocator>>
1438 forward_list(_InputIterator, _InputIterator, _Allocator = _Allocator())
1439 -> forward_list<_ValT, _Allocator>;
1452 template<
typename _Tp,
typename _Alloc>
1455 operator==(
const forward_list<_Tp, _Alloc>& __lx,
1456 const forward_list<_Tp, _Alloc>& __ly);
1458#if __cpp_lib_three_way_comparison
1470 template<
typename _Tp,
typename _Alloc>
1472 inline __detail::__synth3way_t<_Tp>
1473 operator<=>(
const forward_list<_Tp, _Alloc>& __x,
1474 const forward_list<_Tp, _Alloc>& __y)
1477 __y.begin(), __y.end(),
1478 __detail::__synth3way);
1493 template<
typename _Tp,
typename _Alloc>
1498 {
return std::lexicographical_compare(
__lx.cbegin(),
__lx.cend(),
1502 template<
typename _Tp,
typename _Alloc>
1510 template<
typename _Tp,
typename _Alloc>
1518 template<
typename _Tp,
typename _Alloc>
1526 template<
typename _Tp,
typename _Alloc>
1535 template<
typename _Tp,
typename _Alloc>
1539 noexcept(
noexcept(
__lx.swap(
__ly)))
1542_GLIBCXX_END_NAMESPACE_CONTAINER
1543_GLIBCXX_END_NAMESPACE_VERSION
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, 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.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
ISO C++ entities toplevel namespace is std.
is_nothrow_default_constructible
A helper basic node class for forward_list. This is just a linked list with nothing inside it....
A helper node class for forward_list. This is just a linked list with uninitialized storage for a dat...
A forward_list::iterator.
friend bool operator==(const _Self &__x, const _Self &__y) noexcept
Forward list iterator equality comparison.
A forward_list::const_iterator.
friend bool operator==(const _Self &__x, const _Self &__y) noexcept
Forward list const_iterator equality comparison.
Base class for forward_list.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
__remove_return_type unique(_BinPred __binary_pred)
Remove consecutive elements satisfying a predicate.
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.
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.
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.
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 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
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.
static constexpr pointer allocate(_Alloc &__a, size_type __n)
Allocate memory.
static constexpr void deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.
static constexpr size_type max_size(const _Alloc &__a) noexcept
The maximum supported allocation size.