diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index eebffbded2b..07ce90f5b85 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,7 +1,15 @@ +2009-03-25 Paolo Carlini + + * include/bits/forward_list.h (_Fwd_list_node_base<>:: + _M_transfer_after, _M_reverse_after): Move out of line... + * include/bits/forward_list.tcc: ... here. + (forward_list<>::reverse): Move inline... + * include/bits/forward_list.h: ... here; minor cosmetic changes. + 2009-03-22 Mark Mitchell - * testsuite/21_strings/basic_string/inserters_extractors/wchar_t/28277.cc: - Likewise. + * testsuite/21_strings/basic_string/inserters_extractors/wchar_t/ + 28277.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_character/wchar_t/28277-3.cc: Likewise. * testsuite/27_io/basic_ostream/inserters_character/wchar_t/28277-4.cc: diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h index 55029c9647a..0a4bf3a6a95 100644 --- a/libstdc++-v3/include/bits/forward_list.h +++ b/libstdc++-v3/include/bits/forward_list.h @@ -62,52 +62,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ::other::pointer _Pointer; typedef typename _Alloc::template rebind<_Fwd_list_node_base<_Alloc> > ::other::const_pointer _Const_pointer; - + _Pointer _M_next; - + _Fwd_list_node_base() : _M_next(0) { } - + static void swap(_Fwd_list_node_base& __x, _Fwd_list_node_base& __y) { std::swap(__x._M_next, __y._M_next); } - + void - _M_transfer_after(_Pointer __bbegin, _Pointer __bend) - { - _Pointer __keep = __bbegin->_M_next; - if (__bend) - { - __bbegin->_M_next = __bend->_M_next; - __bend->_M_next = this->_M_next; - } - else - __bbegin->_M_next = 0; - this->_M_next = __keep; - } - + _M_transfer_after(_Pointer __bbegin); + void - _M_transfer_after(_Pointer __bbegin) - { - _Pointer __bend = __bbegin; - while (__bend && __bend->_M_next) - __bend = __bend->_M_next; - _M_transfer_after(__bbegin, __bend); - } - + _M_transfer_after(_Pointer __bbegin, _Pointer __bend); + void - _M_reverse_after() - { - _Pointer __tail = this->_M_next; - if (!__tail) - return; - while (_Pointer __temp = __tail->_M_next) - { - _Pointer __keep = this->_M_next; - this->_M_next = __temp; - __tail->_M_next = __temp->_M_next; - this->_M_next->_M_next = __keep; - } - } + _M_reverse_after(); }; /** @@ -159,16 +130,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) reference operator*() const - { return __static_pointer_cast<_Node*>(this->_M_node)->_M_value; } + { return __static_pointer_cast<_Node*>(_M_node)->_M_value; } pointer operator->() const - { return &__static_pointer_cast<_Node*>(this->_M_node)->_M_value; } + { return &__static_pointer_cast<_Node*>(_M_node)->_M_value; } _Self& operator++() { - this->_M_node = this->_M_node->_M_next; + _M_node = _M_node->_M_next; return *this; } @@ -176,23 +147,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) operator++(int) { _Self __tmp(*this); - this->_M_node = this->_M_node->_M_next; + _M_node = _M_node->_M_next; return __tmp; } bool operator==(const _Self& __x) const - { return this->_M_node == __x._M_node; } + { return _M_node == __x._M_node; } bool operator!=(const _Self& __x) const - { return this->_M_node != __x._M_node; } + { return _M_node != __x._M_node; } _Self _M_next() const { if (_M_node) - return _Fwd_list_iterator(this->_M_node->_M_next); + return _Fwd_list_iterator(_M_node->_M_next); else return _Fwd_list_iterator(0); } @@ -230,16 +201,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) reference operator*() const - { return __static_pointer_cast<_Node*>(this->_M_node)->_M_value; } + { return __static_pointer_cast<_Node*>(_M_node)->_M_value; } pointer operator->() const - { return &__static_pointer_cast<_Node*>(this->_M_node)->_M_value; } + { return &__static_pointer_cast<_Node*>(_M_node)->_M_value; } _Self& operator++() { - this->_M_node = this->_M_node->_M_next; + _M_node = _M_node->_M_next; return *this; } @@ -247,23 +218,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) operator++(int) { _Self __tmp(*this); - this->_M_node = this->_M_node->_M_next; + _M_node = _M_node->_M_next; return __tmp; } bool operator==(const _Self& __x) const - { return this->_M_node == __x._M_node; } + { return _M_node == __x._M_node; } bool operator!=(const _Self& __x) const - { return this->_M_node != __x._M_node; } + { return _M_node != __x._M_node; } _Self _M_next() const { if (this->_M_node) - return _Fwd_list_const_iterator(this->_M_node->_M_next); + return _Fwd_list_const_iterator(_M_node->_M_next); else return _Fwd_list_const_iterator(0); } @@ -777,7 +748,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) reference front() { - _Node* __front = __static_pointer_cast<_Node*>(this->_M_impl._M_head._M_next); + _Node* __front = + __static_pointer_cast<_Node*>(this->_M_impl._M_head._M_next); return __front->_M_value; } @@ -1229,7 +1201,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) * Reverse the order of elements in the list in linear time. */ void - reverse(); + reverse() + { this->_M_impl._M_head._M_reverse_after(); } private: template @@ -1328,7 +1301,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template 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 diff --git a/libstdc++-v3/include/bits/forward_list.tcc b/libstdc++-v3/include/bits/forward_list.tcc index bfc814df4a3..35fb9b30afc 100644 --- a/libstdc++-v3/include/bits/forward_list.tcc +++ b/libstdc++-v3/include/bits/forward_list.tcc @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2008 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -36,6 +36,50 @@ _GLIBCXX_BEGIN_NAMESPACE(std) + template + void + _Fwd_list_node_base<_Alloc>:: + _M_transfer_after(_Pointer __bbegin) + { + _Pointer __bend = __bbegin; + while (__bend && __bend->_M_next) + __bend = __bend->_M_next; + _M_transfer_after(__bbegin, __bend); + } + + template + void + _Fwd_list_node_base<_Alloc>:: + _M_transfer_after(_Pointer __bbegin, _Pointer __bend) + { + _Pointer __keep = __bbegin->_M_next; + if (__bend) + { + __bbegin->_M_next = __bend->_M_next; + __bend->_M_next = _M_next; + } + else + __bbegin->_M_next = 0; + _M_next = __keep; + } + + template + void + _Fwd_list_node_base<_Alloc>:: + _M_reverse_after() + { + _Pointer __tail = _M_next; + if (!__tail) + return; + while (_Pointer __temp = __tail->_M_next) + { + _Pointer __keep = _M_next; + _M_next = __temp; + __tail->_M_next = __temp->_M_next; + _M_next->_M_next = __keep; + } + } + /** * @brief Sort the singly linked list starting after this node. * This node is assumed to be an empty head node (of type @@ -411,12 +455,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) } } - template - void - forward_list<_Tp, _Alloc>:: - reverse() - { this->_M_impl._M_head._M_reverse_after(); } - template bool operator==(const forward_list<_Tp, _Alloc>& __lx,