diff options
Diffstat (limited to 'libstdc++-v3/include/bits/forward_list.tcc')
-rw-r--r-- | libstdc++-v3/include/bits/forward_list.tcc | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/libstdc++-v3/include/bits/forward_list.tcc b/libstdc++-v3/include/bits/forward_list.tcc index 83f32c4e299..e70e74a222d 100644 --- a/libstdc++-v3/include/bits/forward_list.tcc +++ b/libstdc++-v3/include/bits/forward_list.tcc @@ -225,22 +225,37 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>:: - _M_splice_after(const_iterator __pos, forward_list&& __list) + _M_splice_after(const_iterator __pos, + const_iterator __before, const_iterator __last) { _Node_base* __tmp = const_cast<_Node_base*>(__pos._M_node); - iterator __before = __list.before_begin(); - return iterator(__tmp->_M_transfer_after(__before._M_node)); + _Node_base* __b = const_cast<_Node_base*>(__before._M_node); + _Node_base* __end = __b; + + while (__end && __end->_M_next != __last._M_node) + __end = __end->_M_next; + + if (__b != __end) + return iterator(__tmp->_M_transfer_after(__b, __end)); + else + return iterator(__tmp); } template<typename _Tp, typename _Alloc> void forward_list<_Tp, _Alloc>:: splice_after(const_iterator __pos, forward_list&&, - const_iterator __before, const_iterator __last) + const_iterator __i) { + const_iterator __j = __i; + ++__j; + + if (__pos == __i || __pos == __j) + return; + _Node_base* __tmp = const_cast<_Node_base*>(__pos._M_node); - __tmp->_M_transfer_after(const_cast<_Node_base*>(__before._M_node), - const_cast<_Node_base*>(__last._M_node)); + __tmp->_M_transfer_after(const_cast<_Node_base*>(__i._M_node), + const_cast<_Node_base*>(__j._M_node)); } template<typename _Tp, typename _Alloc> @@ -251,7 +266,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER if (__n) { forward_list __tmp(__n, __val, get_allocator()); - return _M_splice_after(__pos, std::move(__tmp)); + return _M_splice_after(__pos, __tmp.before_begin(), __tmp.end()); } else return iterator(const_cast<_Node_base*>(__pos._M_node)); @@ -266,26 +281,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { forward_list __tmp(__first, __last, get_allocator()); if (!__tmp.empty()) - return _M_splice_after(__pos, std::move(__tmp)); + return _M_splice_after(__pos, __tmp.before_begin(), __tmp.end()); else return iterator(const_cast<_Node_base*>(__pos._M_node)); } template<typename _Tp, typename _Alloc> - typename forward_list<_Tp, _Alloc>::iterator - forward_list<_Tp, _Alloc>:: - insert_after(const_iterator __pos, std::initializer_list<_Tp> __il) - { - if (__il.size()) - { - forward_list __tmp(__il, get_allocator()); - return _M_splice_after(__pos, std::move(__tmp)); - } - else - return iterator(const_cast<_Node_base*>(__pos._M_node)); - } - - template<typename _Tp, typename _Alloc> void forward_list<_Tp, _Alloc>:: remove(const _Tp& __val) |