30#ifndef _FORWARD_LIST_TCC
31#define _FORWARD_LIST_TCC 1
33namespace std _GLIBCXX_VISIBILITY(default)
35_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
37 template<
typename _Tp,
typename _Alloc>
38 _Fwd_list_base<_Tp, _Alloc>::
39 _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a)
40 : _M_impl(
std::move(__a))
42 if (__lst._M_get_Node_allocator() == _M_get_Node_allocator())
44 this->_M_impl._M_head._M_next = __lst._M_impl._M_head._M_next;
45 __lst._M_impl._M_head._M_next = 0;
48 this->_M_impl._M_head._M_next = 0;
51 template<
typename _Tp,
typename _Alloc>
52 template<
typename... _Args>
54 _Fwd_list_base<_Tp, _Alloc>::
55 _M_insert_after(const_iterator __pos, _Args&&... __args)
57 _Fwd_list_node_base* __to
58 =
const_cast<_Fwd_list_node_base*
>(__pos._M_node);
60 __thing->_M_next = __to->_M_next;
61 __to->_M_next = __thing;
65 template<
typename _Tp,
typename _Alloc>
67 _Fwd_list_base<_Tp, _Alloc>::
68 _M_erase_after(_Fwd_list_node_base* __pos)
70 _Node* __curr =
static_cast<_Node*
>(__pos->_M_next);
71 __pos->_M_next = __curr->_M_next;
72 _Tp_alloc_type __a(_M_get_Node_allocator());
73 allocator_traits<_Tp_alloc_type>::destroy(__a, __curr->_M_valptr());
76 return __pos->_M_next;
79 template<
typename _Tp,
typename _Alloc>
81 _Fwd_list_base<_Tp, _Alloc>::
82 _M_erase_after(_Fwd_list_node_base* __pos,
83 _Fwd_list_node_base* __last)
85 _Node* __curr =
static_cast<_Node*
>(__pos->_M_next);
86 while (__curr != __last)
88 _Node* __temp = __curr;
89 __curr =
static_cast<_Node*
>(__curr->_M_next);
90 _Tp_alloc_type __a(_M_get_Node_allocator());
91 allocator_traits<_Tp_alloc_type>::destroy(__a, __temp->_M_valptr());
95 __pos->_M_next = __last;
100 template<
typename _Tp,
typename _Alloc>
101 template<
typename _InputIterator>
103 forward_list<_Tp, _Alloc>::
104 _M_range_initialize(_InputIterator __first, _InputIterator __last)
106 _Node_base* __to = &this->_M_impl._M_head;
107 for (; __first != __last; ++__first)
109 __to->_M_next = this->_M_create_node(*__first);
110 __to = __to->_M_next;
115 template<
typename _Tp,
typename _Alloc>
117 forward_list<_Tp, _Alloc>::
118 _M_fill_initialize(size_type __n,
const value_type& __value)
120 _Node_base* __to = &this->_M_impl._M_head;
123 __to->_M_next = this->_M_create_node(__value);
124 __to = __to->_M_next;
128 template<
typename _Tp,
typename _Alloc>
130 forward_list<_Tp, _Alloc>::
131 _M_default_initialize(size_type __n)
133 _Node_base* __to = &this->_M_impl._M_head;
136 __to->_M_next = this->_M_create_node();
137 __to = __to->_M_next;
141 template<
typename _Tp,
typename _Alloc>
142 forward_list<_Tp, _Alloc>&
148 if (_Node_alloc_traits::_S_propagate_on_copy_assign())
152 if (!_Node_alloc_traits::_S_always_equal()
165 template<
typename _Tp,
typename _Alloc>
178 erase_after(__saved_pos, ++__pos);
179 __throw_exception_again;
183 template<
typename _Tp,
typename _Alloc>
202 template<
typename _Tp,
typename _Alloc>
205 resize(size_type
__sz,
const value_type& __val)
221 template<
typename _Tp,
typename _Alloc>
225 const_iterator
__before, const_iterator __last)
227 _Node_base*
__tmp =
const_cast<_Node_base*
>(
__pos._M_node);
228 _Node_base* __b =
const_cast<_Node_base*
>(
__before._M_node);
229 _Node_base* __end = __b;
231 while (__end && __end->_M_next != __last._M_node)
232 __end = __end->_M_next;
240 template<
typename _Tp,
typename _Alloc>
257 template<
typename _Tp,
typename _Alloc>
271 template<
typename _Tp,
typename _Alloc>
272 template<
typename _InputIterator,
typename>
285 template<
typename _Tp,
typename _Alloc>
295 if (*
__tmp->_M_valptr() == __val)
299 this->_M_erase_after(
__curr);
312 template<
typename _Tp,
typename _Alloc>
313 template<
typename _Pred>
322 this->_M_erase_after(
__curr);
328 template<
typename _Tp,
typename _Alloc>
329 template<
typename _BinPred>
336 if (__first == __last)
339 while (++__next != __last)
342 erase_after(__first);
349 template<
typename _Tp,
typename _Alloc>
350 template<
typename _Comp>
356 while (
__node->_M_next &&
__list._M_impl._M_head._M_next)
358 if (__comp(*
static_cast<_Node*
>
359 (
__list._M_impl._M_head._M_next)->_M_valptr(),
361 (
__node->_M_next)->_M_valptr()))
363 __list._M_impl._M_head._M_next);
366 if (
__list._M_impl._M_head._M_next)
369 __list._M_impl._M_head._M_next = 0;
373 template<
typename _Tp,
typename _Alloc>
395 template<
typename _Tp,
class _Alloc>
396 template<
typename _Comp>
424 for (
unsigned long __i = 0; __i <
__insize; ++__i)
427 __q =
static_cast<_Node*
>(__q->_M_next);
444 __q =
static_cast<_Node*
>(__q->_M_next);
451 __p =
static_cast<_Node*
>(__p->_M_next);
454 else if (__comp(*__p->_M_valptr(), *__q->_M_valptr()))
458 __p =
static_cast<_Node*
>(__p->_M_next);
465 __q =
static_cast<_Node*
>(__q->_M_next);
486 this->_M_impl._M_head._M_next =
__list;
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
ISO C++ entities toplevel namespace is std.
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list.
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...