30#ifndef _FORWARD_LIST_TCC
31#define _FORWARD_LIST_TCC 1
33namespace std _GLIBCXX_VISIBILITY(default)
35_GLIBCXX_BEGIN_NAMESPACE_VERSION
36_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
38 template<
typename _Tp,
typename _Alloc>
39 _Fwd_list_base<_Tp, _Alloc>::
40 _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a)
43 if (__lst._M_get_Node_allocator() == _M_get_Node_allocator())
44 this->_M_impl._M_head =
std::move(__lst._M_impl._M_head);
47 template<
typename _Tp,
typename _Alloc>
48 template<
typename... _Args>
50 _Fwd_list_base<_Tp, _Alloc>::
51 _M_insert_after(const_iterator __pos, _Args&&... __args)
53 _Fwd_list_node_base* __to
54 =
const_cast<_Fwd_list_node_base*
>(__pos._M_node);
56 __thing->_M_next = __to->_M_next;
57 __to->_M_next = __thing;
61 template<
typename _Tp,
typename _Alloc>
63 _Fwd_list_base<_Tp, _Alloc>::
64 _M_erase_after(_Fwd_list_node_base* __pos)
66 _Node* __curr =
static_cast<_Node*
>(__pos->_M_next);
67 __pos->_M_next = __curr->_M_next;
68 _Node_alloc_traits::destroy(_M_get_Node_allocator(),
72 return __pos->_M_next;
75 template<
typename _Tp,
typename _Alloc>
77 _Fwd_list_base<_Tp, _Alloc>::
78 _M_erase_after(_Fwd_list_node_base* __pos,
79 _Fwd_list_node_base* __last)
81 _Node* __curr =
static_cast<_Node*
>(__pos->_M_next);
82 while (__curr != __last)
84 _Node* __temp = __curr;
85 __curr =
static_cast<_Node*
>(__curr->_M_next);
86 _Node_alloc_traits::destroy(_M_get_Node_allocator(),
91 __pos->_M_next = __last;
96 template<
typename _Tp,
typename _Alloc>
97 template<
typename _InputIterator>
99 forward_list<_Tp, _Alloc>::
100 _M_range_initialize(_InputIterator __first, _InputIterator __last)
102 _Node_base* __to = &this->_M_impl._M_head;
103 for (; __first != __last; ++__first)
105 __to->_M_next = this->_M_create_node(*__first);
106 __to = __to->_M_next;
111 template<
typename _Tp,
typename _Alloc>
113 forward_list<_Tp, _Alloc>::
114 _M_fill_initialize(size_type __n,
const value_type& __value)
116 _Node_base* __to = &this->_M_impl._M_head;
119 __to->_M_next = this->_M_create_node(__value);
120 __to = __to->_M_next;
124 template<
typename _Tp,
typename _Alloc>
126 forward_list<_Tp, _Alloc>::
127 _M_default_initialize(size_type __n)
129 _Node_base* __to = &this->_M_impl._M_head;
132 __to->_M_next = this->_M_create_node();
133 __to = __to->_M_next;
137 template<
typename _Tp,
typename _Alloc>
138 forward_list<_Tp, _Alloc>&
144 if (_Node_alloc_traits::_S_propagate_on_copy_assign())
148 if (!_Node_alloc_traits::_S_always_equal()
161 template<
typename _Tp,
typename _Alloc>
174 erase_after(__saved_pos, ++__pos);
175 __throw_exception_again;
179 template<
typename _Tp,
typename _Alloc>
193 erase_after(
__k, end());
198 template<
typename _Tp,
typename _Alloc>
201 resize(size_type
__sz,
const value_type& __val)
212 erase_after(
__k, end());
217 template<
typename _Tp,
typename _Alloc>
221 const_iterator
__before, const_iterator __last)
223 _Node_base*
__tmp =
const_cast<_Node_base*
>(
__pos._M_node);
224 _Node_base* __b =
const_cast<_Node_base*
>(
__before._M_node);
225 _Node_base* __end = __b;
227 while (__end && __end->_M_next != __last._M_node)
228 __end = __end->_M_next;
236 template<
typename _Tp,
typename _Alloc>
253 template<
typename _Tp,
typename _Alloc>
267 template<
typename _Tp,
typename _Alloc>
268 template<
typename _InputIterator,
typename>
281#if __cplusplus > 201703L
282# define _GLIBCXX20_ONLY(__expr) __expr
284# define _GLIBCXX20_ONLY(__expr)
287 template<
typename _Tp,
typename _Alloc>
290 remove(
const _Tp& __val) -> __remove_return_type
297 if (*
__tmp->_M_valptr() == __val)
309 template<
typename _Tp,
typename _Alloc>
310 template<
typename _Pred>
319 while (_Node*
__tmp =
static_cast<_Node*
>(
__prev_it._M_node->_M_next))
329 return _GLIBCXX20_ONLY( __removed );
332 template<
typename _Tp,
typename _Alloc>
333 template<
typename _BinPred>
335 forward_list<_Tp, _Alloc>::
336 unique(_BinPred __binary_pred) -> __remove_return_type
338 iterator __first = begin();
339 iterator __last = end();
340 if (__first == __last)
341 return _GLIBCXX20_ONLY(0);
343 forward_list __to_destroy(get_allocator());
344 size_type __removed __attribute__((__unused__)) = 0;
345 iterator __next = __first;
346 while (++__next != __last)
348 if (__binary_pred(*__first, *__next))
350 __to_destroy.splice_after(__to_destroy.cbefore_begin(),
352 _GLIBCXX20_ONLY( __removed++ );
359 return _GLIBCXX20_ONLY( __removed );
362#undef _GLIBCXX20_ONLY
364 template<
typename _Tp,
typename _Alloc>
365 template<
typename _Comp>
376 while (
__node->_M_next &&
__list._M_impl._M_head._M_next)
378 if (__comp(*
static_cast<_Node*
>
379 (
__list._M_impl._M_head._M_next)->_M_valptr(),
381 (
__node->_M_next)->_M_valptr()))
383 __list._M_impl._M_head._M_next);
387 if (
__list._M_impl._M_head._M_next)
391 template<
typename _Tp,
typename _Alloc>
413 template<
typename _Tp,
class _Alloc>
414 template<
typename _Comp>
442 for (
unsigned long __i = 0; __i <
__insize; ++__i)
445 __q =
static_cast<_Node*
>(__q->_M_next);
462 __q =
static_cast<_Node*
>(__q->_M_next);
469 __p =
static_cast<_Node*
>(__p->_M_next);
472 else if (!__comp(*__q->_M_valptr(), *__p->_M_valptr()))
476 __p =
static_cast<_Node*
>(__p->_M_next);
483 __q =
static_cast<_Node*
>(__q->_M_next);
498 __tail->_M_next =
nullptr;
504 this->_M_impl._M_head._M_next =
__list;
513_GLIBCXX_END_NAMESPACE_CONTAINER
514_GLIBCXX_END_NAMESPACE_VERSION
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.
ISO C++ entities toplevel namespace is std.
A helper basic node class for forward_list. This is just a linked list with nothing inside it....
A forward_list::const_iterator.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...