: _Fwd_list_node_base<_Alloc>(),
_M_value(std::forward<_Args>(__args)...) { }
- template<typename _Comp>
- void
- _M_sort_after(_Comp __comp);
-
_Tp _M_value;
};
_M_put_node(typename _Node::_Pointer __p)
{ _M_get_Node_allocator().deallocate(__p, 1); }
- typename _Node_base::_Pointer
+ void
_M_erase_after(typename _Node_base::_Pointer __pos);
- typename _Node_base::_Pointer
+ void
_M_erase_after(typename _Node_base::_Pointer __pos,
typename _Node_base::_Pointer __last);
};
* @brief The forward_list dtor.
*/
~forward_list()
- { _M_erase_after(&this->_M_impl._M_head, 0); }
+ { }
/**
* @brief The %forward_list assignment operator.
insert_after(const_iterator __pos, size_type __n, const _Tp& __val)
{
forward_list __tmp(__n, __val, this->get_allocator());
- this->splice_after(__pos, std::move(__tmp));
+ splice_after(__pos, std::move(__tmp));
}
/**
_InputIterator __first, _InputIterator __last)
{
forward_list __tmp(__first, __last, this->get_allocator());
- this->splice_after(__pos, std::move(__tmp));
+ splice_after(__pos, std::move(__tmp));
}
/**
insert_after(const_iterator __pos, std::initializer_list<_Tp> __il)
{
forward_list __tmp(__il, this->get_allocator());
- this->splice_after(__pos, std::move(__tmp));
+ splice_after(__pos, std::move(__tmp));
}
/**
* @brief Removes the element pointed to by the iterator following
* @c pos.
- * @param pos Iterator pointing to element to be erased.
- * @return An iterator pointing to the next element (or end()).
+ * @param pos Iterator pointing before element to be erased.
*
* This function will erase the element at the given position and
* thus shorten the %forward_list by one.
* is itself a pointer, the pointed-to memory is not touched in
* any way. Managing the pointer is the user's responsibility.
*/
- iterator
+ void
erase_after(const_iterator __pos)
{
_Node_base* __tmp = __const_pointer_cast<_Node_base*>(__pos._M_node);
- if (__tmp)
- return iterator(this->_M_erase_after(__tmp));
- else
- return end();
+ this->_M_erase_after(__tmp);
}
/**
* erased.
* @param last Iterator pointing to one past the last element to be
* erased.
- * @return An iterator pointing to the element pointed to by @a last
- * prior to erasing (or end()).
*
* This function will erase the elements in the range @a
* (pos,last) and shorten the %forward_list accordingly.
* pointed-to memory is not touched in any way. Managing the pointer
* is the user's responsibility.
*/
- iterator
- erase_after(const_iterator __pos, iterator __last)
+ void
+ erase_after(const_iterator __pos, const_iterator __last)
{
- _Node_base* __tmp = __const_pointer_cast<_Node_base*>(__pos._M_node);
- return iterator(this->_M_erase_after(__tmp, &*__last._M_node));
+ _Node_base* __tmpp = __const_pointer_cast<_Node_base*>(__pos._M_node);
+ _Node_base* __tmpl = __const_pointer_cast<_Node_base*>(__last._M_node);
+ this->_M_erase_after(__tmpp, __tmpl);
}
/**
* function.
*/
void
- swap(forward_list&& __list)
+ swap(forward_list& __list)
{ _Node_base::swap(this->_M_impl._M_head, __list._M_impl._M_head); }
/**
* @brief Insert element from another %forward_list.
* @param pos Iterator referencing the element to insert after.
* @param list Source list.
- * @param it Iterator referencing the element before the element
+ * @param i Iterator referencing the element before the element
* to move.
*
* Removes the element in list @a list referenced by @a i and
*/
void
splice_after(const_iterator __pos, forward_list&& __list,
- const_iterator __it)
- { this->splice_after(__pos, __list, __it, __it._M_next()); }
+ const_iterator __i)
+ {
+ const_iterator __j = __i;
+ ++__j;
+ if (__pos == __i || __pos == __j)
+ return;
+
+ splice_after(__pos, std::move(__list), __i, __j);
+ }
/**
* @brief Insert range from another %forward_list.
*/
void
merge(forward_list&& __list)
- { this->merge(__list, std::less<_Tp>()); }
+ { this->merge(std::move(__list), std::less<_Tp>()); }
/**
* @brief Merge sorted lists according to comparison function.
*/
void
sort()
- {
- _Node* __tmp = __static_pointer_cast<_Node*>(&this->_M_impl._M_head);
- __tmp->_M_sort_after(std::less<_Tp>());
- }
+ { this->sort(std::less<_Tp>()); }
/**
* @brief Sort the forward_list using a comparison function.
*/
template<typename _Comp>
void
- sort(_Comp __comp)
- {
- _Node* __tmp = __static_pointer_cast<_Node*>(&this->_M_impl._M_head);
- __tmp->_M_sort_after(__comp);
- }
+ sort(_Comp __comp);
/**
* @brief Reverse the elements in list.
template<typename _Tp, typename _Alloc>
inline void
swap(forward_list<_Tp, _Alloc>& __lx,
- forward_list<_Tp, _Alloc>& __ly)
- { __lx.swap(__ly); }
-
- /// See std::forward_list::swap().
- template<typename _Tp, typename _Alloc>
- inline void
- swap(forward_list<_Tp, _Alloc>&& __lx,
- forward_list<_Tp, _Alloc>& __ly)
- { __lx.swap(__ly); }
-
- /// See std::forward_list::swap().
- template<typename _Tp, typename _Alloc>
- inline void
- swap(forward_list<_Tp, _Alloc>& __lx,
- forward_list<_Tp, _Alloc>&& __ly)
+ forward_list<_Tp, _Alloc>& __ly)
{ __lx.swap(__ly); }
_GLIBCXX_END_NAMESPACE // namespace std