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)
54 auto __to = __pos._M_const_cast()._M_node;
56 __thing->_M_next = __to->_M_next;
57 __to->_M_next = __thing->_M_base_ptr();
61 template<
typename _Tp,
typename _Alloc>
63 _Fwd_list_base<_Tp, _Alloc>::
64 _M_erase_after(_Base_ptr __pos)
67 auto& __curr =
static_cast<_Node&
>(*__pos->_M_next);
68 __pos->_M_next = __curr._M_next;
69 _M_destroy_node(__curr._M_node_ptr());
70 return __pos->_M_next;
73 template<
typename _Tp,
typename _Alloc>
75 _Fwd_list_base<_Tp, _Alloc>::
76 _M_erase_after(_Base_ptr __pos, _Base_ptr __last)
79 _Base_ptr __curr = __pos->_M_next;
80 while (__curr != __last)
82 auto& __node =
static_cast<_Node&
>(*__curr);
83 __curr = __curr->_M_next;
84 _M_destroy_node(__node._M_node_ptr());
86 __pos->_M_next = __last;
91 template<
typename _Tp,
typename _Alloc>
92 template<
typename _InputIterator>
94 forward_list<_Tp, _Alloc>::
95 _M_range_initialize(_InputIterator __first, _InputIterator __last)
97 auto __to = this->_M_impl._M_head._M_base_ptr();
98 for (; __first != __last; ++__first)
100 __to->_M_next = this->_M_create_node(*__first)->_M_base_ptr();
101 __to = __to->_M_next;
106 template<
typename _Tp,
typename _Alloc>
108 forward_list<_Tp, _Alloc>::
109 _M_fill_initialize(size_type __n,
const value_type& __value)
111 auto __to = this->_M_impl._M_head._M_base_ptr();
114 __to->_M_next = this->_M_create_node(__value)->_M_base_ptr();
115 __to = __to->_M_next;
119 template<
typename _Tp,
typename _Alloc>
121 forward_list<_Tp, _Alloc>::
122 _M_default_initialize(size_type __n)
124 auto __to = this->_M_impl._M_head._M_base_ptr();
127 __to->_M_next = this->_M_create_node()->_M_base_ptr();
128 __to = __to->_M_next;
132 template<
typename _Tp,
typename _Alloc>
133 forward_list<_Tp, _Alloc>&
139 if (_Node_alloc_traits::_S_propagate_on_copy_assign())
143 if (!_Node_alloc_traits::_S_always_equal()
156 template<
typename _Tp,
typename _Alloc>
169 erase_after(__saved_pos, ++__pos);
170 __throw_exception_again;
174 template<
typename _Tp,
typename _Alloc>
179 iterator
__k = before_begin();
193 template<
typename _Tp,
typename _Alloc>
196 resize(size_type
__sz,
const value_type& __val)
198 iterator
__k = before_begin();
212 template<
typename _Tp,
typename _Alloc>
213 typename forward_list<_Tp, _Alloc>::iterator
216 const_iterator
__before, const_iterator __last)
219 auto __b =
__before._M_const_cast()._M_node;
222 while (__end && __end->_M_next != __last._M_node)
223 __end = __end->_M_next;
231 template<
typename _Tp,
typename _Alloc>
235 const_iterator __i)
noexcept
237 const_iterator __j = __i;
244 __tmp->_M_transfer_after(__i._M_const_cast()._M_node,
245 __j._M_const_cast()._M_node);
248 template<
typename _Tp,
typename _Alloc>
249 typename forward_list<_Tp, _Alloc>::iterator
259 return __pos._M_const_cast();
262 template<
typename _Tp,
typename _Alloc>
263 template<
typename _InputIterator,
typename>
264 typename forward_list<_Tp, _Alloc>::iterator
273 return __pos._M_const_cast();
276#if __cplusplus > 201703L
277# define _GLIBCXX20_ONLY(__expr) __expr
279# define _GLIBCXX20_ONLY(__expr)
282 template<
typename _Tp,
typename _Alloc>
285 remove(
const _Tp& __val) -> __remove_return_type
292 if (*
static_cast<_Node&
>(*__tmp)._M_valptr() == __val)
304 template<
typename _Tp,
typename _Alloc>
305 template<
typename _Pred>
315 if (
__pred(*
static_cast<_Node&
>(*__tmp)._M_valptr()))
324 return _GLIBCXX20_ONLY( __removed );
327 template<
typename _Tp,
typename _Alloc>
328 template<
typename _BinPred>
330 forward_list<_Tp, _Alloc>::
331 unique(_BinPred __binary_pred) -> __remove_return_type
333 iterator __first =
begin();
334 iterator __last =
end();
335 if (__first == __last)
336 return _GLIBCXX20_ONLY(0);
338 forward_list __to_destroy(get_allocator());
339 size_type __removed __attribute__((__unused__)) = 0;
340 iterator __next = __first;
341 while (++__next != __last)
343 if (__binary_pred(*__first, *__next))
345 __to_destroy.splice_after(__to_destroy.cbefore_begin(),
347 _GLIBCXX20_ONLY( __removed++ );
354 return _GLIBCXX20_ONLY( __removed );
357#undef _GLIBCXX20_ONLY
359 template<
typename _Tp,
typename _Alloc>
360 template<
typename _Comp>
370 using _Base_ptr =
typename _Node::_Base_ptr;
372 _Base_ptr
__node = this->_M_impl._M_head._M_base_ptr();
373 _Base_ptr __other = __list._M_impl._M_head._M_base_ptr();
374 while (
__node->_M_next && __other->_M_next)
376 auto&
__l =
static_cast<_Node&
>(*__other->_M_next);
377 auto& __r =
static_cast<_Node&
>(*
__node->_M_next);
378 if (__comp(*
__l._M_valptr(), *__r._M_valptr()))
379 __node->_M_transfer_after(__other, __other->_M_next);
383 if (__list._M_impl._M_head._M_next)
387 template<
typename _Tp,
typename _Alloc>
409 template<
typename _Tp,
class _Alloc>
410 template<
typename _Comp>
418 using _Base_ptr =
typename _Node::_Base_ptr;
421 _Base_ptr __list = this->_M_impl._M_head._M_next;
427 _Base_ptr __p = __list;
429 _Base_ptr
__tail =
nullptr;
441 for (
unsigned long __i = 0; __i <
__insize; ++__i)
471 else if (!__comp(*
static_cast<_Node&
>(*__q)._M_valptr(),
472 *
static_cast<_Node&
>(*__p)._M_valptr()))
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.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
ISO C++ entities toplevel namespace is std.
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
const_iterator cend() const noexcept
const_iterator cbegin() const noexcept