diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-03 00:47:17 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-03 00:47:17 +0000 |
commit | 08caf8b46d470b46853a3a55d544b5631b6ea6cf (patch) | |
tree | 7f5c4b43c373eb9a4a34b99d15cc89adbbc88b1b /libstdc++-v3 | |
parent | 9ccbe252276bf0966f27c2109ecb4ef2466cd0ca (diff) | |
download | gcc-08caf8b46d470b46853a3a55d544b5631b6ea6cf.tar.gz |
2012-07-02 Paolo Carlini <paolo.carlini@oracle.com>
Revert:
2011-10-04 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/49561
* include/bits/stl_list.h (_List_base<>::_List_impl::_M_size):
Add in C++0x mode.
(_List_base<>::_List_impl, _List_base<>::_M_get_node,
_List_base<>::_M_put_node, _List_base<>::_List_base(_List_base&&),
list<>::size, list<>::swap, list<>::splice): Use it.
(operator==(const list<>&, const list<>&)): Rewrite in C++0x mode.
* include/bits/list.tcc (list<>::erase): Likewise.
(list<>::merge): Adjust in C++0x mode.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@189185 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
7 files changed, 50 insertions, 87 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 45981813524..94a0ad48576 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,26 @@ +2012-07-02 Paolo Carlini <paolo.carlini@oracle.com> + + Revert: + 2011-10-04 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/49561 + * include/bits/stl_list.h (_List_base<>::_List_impl::_M_size): + Add in C++0x mode. + (_List_base<>::_List_impl, _List_base<>::_M_get_node, + _List_base<>::_M_put_node, _List_base<>::_List_base(_List_base&&), + list<>::size, list<>::swap, list<>::splice): Use it. + (operator==(const list<>&, const list<>&)): Rewrite in C++0x mode. + * include/bits/list.tcc (list<>::erase): Likewise. + (list<>::merge): Adjust in C++0x mode. + * testsuite/23_containers/list/requirements/dr438/assign_neg.cc: + Adjust dg-error line number. + * testsuite/23_containers/list/requirements/dr438/insert_neg.cc: + Likewise. + * testsuite/23_containers/list/requirements/dr438/ + constructor_1_neg.cc: Likewise. + * testsuite/23_containers/list/requirements/dr438/ + constructor_2_neg.cc: Likewise. + 2012-06-27 Benjamin Kosnik <bkoz@redhat.com> * include/bits/c++config: Remove __regex nested namespace. diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc index 55156bbf062..727e82d3d8d 100644 --- a/libstdc++-v3/include/bits/list.tcc +++ b/libstdc++-v3/include/bits/list.tcc @@ -1,7 +1,7 @@ // List implementation (out of line) -*- C++ -*- // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -// 2011 Free Software Foundation, Inc. +// 2011, 2012 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 @@ -139,14 +139,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER list<_Tp, _Alloc>:: resize(size_type __new_size) { - if (__new_size > size()) - _M_default_append(__new_size - size()); - else if (__new_size < size()) - { - iterator __i = begin(); - std::advance(__i, __new_size); - erase(__i, end()); - } + iterator __i = begin(); + size_type __len = 0; + for (; __i != end() && __len < __new_size; ++__i, ++__len) + ; + if (__len == __new_size) + erase(__i, end()); + else // __i == end() + _M_default_append(__new_size - __len); } template<typename _Tp, typename _Alloc> @@ -154,14 +154,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER list<_Tp, _Alloc>:: resize(size_type __new_size, const value_type& __x) { - if (__new_size > size()) - insert(end(), __new_size - size(), __x); - else if (__new_size < size()) - { - iterator __i = begin(); - std::advance(__i, __new_size); - erase(__i, end()); - } + iterator __i = begin(); + size_type __len = 0; + for (; __i != end() && __len < __new_size; ++__i, ++__len) + ; + if (__len == __new_size) + erase(__i, end()); + else // __i == end() + insert(end(), __new_size - __len, __x); } #else template<typename _Tp, typename _Alloc> @@ -312,11 +312,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ++__first1; if (__first2 != __last2) _M_transfer(__last1, __first2, __last2); - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - this->_M_impl._M_size += __x.size(); - __x._M_impl._M_size = 0; -#endif } } @@ -351,11 +346,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ++__first1; if (__first2 != __last2) _M_transfer(__last1, __first2, __last2); - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - this->_M_impl._M_size += __x.size(); - __x._M_impl._M_size = 0; -#endif } } diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index b568cd701b0..5fdaec91d17 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -313,10 +313,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { __detail::_List_node_base _M_node; -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - size_t _M_size = 0; -#endif - _List_impl() : _Node_alloc_type(), _M_node() { } @@ -336,23 +332,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _List_node<_Tp>* _M_get_node() - { - _List_node<_Tp>* __tmp = _M_impl._Node_alloc_type::allocate(1); -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - ++_M_impl._M_size; -#endif - return __tmp; - } + { return _M_impl._Node_alloc_type::allocate(1); } void _M_put_node(_List_node<_Tp>* __p) - { - _M_impl._Node_alloc_type::deallocate(__p, 1); -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - --_M_impl._M_size; -#endif - } - + { _M_impl._Node_alloc_type::deallocate(__p, 1); } + public: typedef _Alloc allocator_type; @@ -386,7 +371,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { _M_init(); __detail::_List_node_base::swap(_M_impl._M_node, __x._M_impl._M_node); - std::swap(_M_impl._M_size, __x._M_impl._M_size); } #endif @@ -888,13 +872,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /** Returns the number of elements in the %list. */ size_type size() const _GLIBCXX_NOEXCEPT - { -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - return this->_M_impl._M_size; -#else - return std::distance(begin(), end()); -#endif - } + { return std::distance(begin(), end()); } /** Returns the size() of the largest possible %list. */ size_type @@ -1234,9 +1212,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { __detail::_List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node); -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - std::swap(this->_M_impl._M_size, __x._M_impl._M_size); -#endif // _GLIBCXX_RESOLVE_LIB_DEFECTS // 431. Swapping containers with unequal allocators. @@ -1281,11 +1256,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_check_equal_allocators(__x); this->_M_transfer(__position, __x.begin(), __x.end()); - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - this->_M_impl._M_size += __x.size(); - __x._M_impl._M_size = 0; -#endif } } @@ -1317,14 +1287,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return; if (this != &__x) - { - _M_check_equal_allocators(__x); - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - ++this->_M_impl._M_size; - --__x._M_impl._M_size; -#endif - } + _M_check_equal_allocators(__x); this->_M_transfer(__position, __i, __j); } @@ -1359,15 +1322,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER if (__first != __last) { if (this != &__x) - { - _M_check_equal_allocators(__x); - -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - const size_type __size = std::distance(__first, __last); - this->_M_impl._M_size += __size; - __x._M_impl._M_size -= __size; -#endif - } + _M_check_equal_allocators(__x); this->_M_transfer(__position, __first, __last); } @@ -1643,10 +1598,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER inline bool operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - return (__x.size() == __y.size() - && std::equal(__x.begin(), __x.end(), __y.begin())); -#else typedef typename list<_Tp, _Alloc>::const_iterator const_iterator; const_iterator __end1 = __x.end(); const_iterator __end2 = __y.end(); @@ -1659,7 +1610,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ++__i2; } return __i1 == __end1 && __i2 == __end2; -#endif } /** diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc index 65a6d412014..17af9cfe4d5 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc @@ -18,7 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1571 } +// { dg-error "no matching" "" { target *-*-* } 1526 } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc index 34caa3b5d2f..cf303f9daeb 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc @@ -18,7 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1527 } +// { dg-error "no matching" "" { target *-*-* } 1482 } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc index d1709c32ace..3e74bcfeb02 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc @@ -18,7 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1527 } +// { dg-error "no matching" "" { target *-*-* } 1482 } #include <list> #include <utility> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc index 2651f3b62ca..ac33bff7902 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc @@ -18,7 +18,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1527 } +// { dg-error "no matching" "" { target *-*-* } 1482 } #include <list> |