mirror of git://gcc.gnu.org/git/gcc.git
stl_vector.h (vector::_Alloc_traits): Make private.
* include/bits/stl_vector.h (vector::_Alloc_traits): Make private. * include/debug/vector: Add allocator-extended constructors, ensure move assignment and swap have same allocator propagation semantics and exceptions specification as base class. * include/profile/vector: Likewise. (vector::push_back(_Tp&&)): Forward argument as rvalue. * testsuite/23_containers/vector/debug/alloc_prop.cc: New. * doc/xml/manual/status_cxx2011.xml: Clarify status of container requirements with respect to allocators. (status.iso.200x): Add anchor for old ID to preserve existing links. From-SVN: r181189
This commit is contained in:
parent
ffe1468659
commit
425006751b
|
@ -1,3 +1,16 @@
|
||||||
|
2011-11-09 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
|
* include/bits/stl_vector.h (vector::_Alloc_traits): Make private.
|
||||||
|
* include/debug/vector: Add allocator-extended constructors, ensure
|
||||||
|
move assignment and swap have same allocator propagation semantics
|
||||||
|
and exceptions specification as base class.
|
||||||
|
* include/profile/vector: Likewise.
|
||||||
|
(vector::push_back(_Tp&&)): Forward argument as rvalue.
|
||||||
|
* testsuite/23_containers/vector/debug/alloc_prop.cc: New.
|
||||||
|
* doc/xml/manual/status_cxx2011.xml: Clarify status of container
|
||||||
|
requirements with respect to allocators.
|
||||||
|
(status.iso.200x): Add anchor for old ID to preserve existing links.
|
||||||
|
|
||||||
2011-11-08 Jonathan Wakely <jwakely.gcc@gmail.com>
|
2011-11-08 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
* include/bits/shared_ptr_base.h (_Sp_counted_ptr): Make 'final'.
|
* include/bits/shared_ptr_base.h (_Sp_counted_ptr): Make 'final'.
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
</info>
|
</info>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
<anchor xml:id="status.iso.200x" /> <!-- preserve links to old section ID -->
|
||||||
This table is based on the table of contents of ISO/IEC
|
This table is based on the table of contents of ISO/IEC
|
||||||
JTC1 SC22 WG21 Doc No: N3290 Date: 2011-04-11
|
JTC1 SC22 WG21 Doc No: N3290 Date: 2011-04-11
|
||||||
Final Draft International Standard, Standard for Programming Language C++
|
Final Draft International Standard, Standard for Programming Language C++
|
||||||
|
@ -1373,10 +1374,12 @@ particular release.
|
||||||
<entry/>
|
<entry/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
|
<?dbhtml bgcolor="#B0B0B0" ?>
|
||||||
<entry>23.2.1</entry>
|
<entry>23.2.1</entry>
|
||||||
<entry>General container requirements</entry>
|
<entry>General container requirements</entry>
|
||||||
<entry>Y</entry>
|
<entry>Partial</entry>
|
||||||
<entry/>
|
<entry>Only <code>vector</code> meets the requirements
|
||||||
|
relating to allocator use and propagation.</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>23.2.2</entry>
|
<entry>23.2.2</entry>
|
||||||
|
|
|
@ -214,11 +214,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||||
|
|
||||||
typedef _Vector_base<_Tp, _Alloc> _Base;
|
typedef _Vector_base<_Tp, _Alloc> _Base;
|
||||||
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
|
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
|
||||||
|
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef _Tp value_type;
|
typedef _Tp value_type;
|
||||||
typedef typename _Base::pointer pointer;
|
typedef typename _Base::pointer pointer;
|
||||||
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits;
|
|
||||||
typedef typename _Alloc_traits::const_pointer const_pointer;
|
typedef typename _Alloc_traits::const_pointer const_pointer;
|
||||||
typedef typename _Alloc_traits::reference reference;
|
typedef typename _Alloc_traits::reference reference;
|
||||||
typedef typename _Alloc_traits::const_reference const_reference;
|
typedef typename _Alloc_traits::const_reference const_reference;
|
||||||
|
|
|
@ -52,6 +52,10 @@ namespace __debug
|
||||||
typedef typename _Base::const_iterator _Base_const_iterator;
|
typedef typename _Base::const_iterator _Base_const_iterator;
|
||||||
typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
|
typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
|
||||||
|
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits;
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
|
@ -116,6 +120,17 @@ namespace __debug
|
||||||
__x._M_guaranteed_capacity = 0;
|
__x._M_guaranteed_capacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector(const vector& __x, const allocator_type& __a)
|
||||||
|
: _Base(__x, __a), _M_guaranteed_capacity(__x.size()) { }
|
||||||
|
|
||||||
|
vector(vector&& __x, const allocator_type& __a)
|
||||||
|
: _Base(std::move(__x), __a),
|
||||||
|
_M_guaranteed_capacity(this->size())
|
||||||
|
{
|
||||||
|
__x._M_invalidate_all();
|
||||||
|
__x._M_guaranteed_capacity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
vector(initializer_list<value_type> __l,
|
vector(initializer_list<value_type> __l,
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__l, __a),
|
: _Base(__l, __a),
|
||||||
|
@ -135,12 +150,13 @@ namespace __debug
|
||||||
|
|
||||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
vector&
|
vector&
|
||||||
operator=(vector&& __x)
|
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
|
||||||
{
|
{
|
||||||
// NB: DR 1204.
|
_Base::operator=(std::move(__x));
|
||||||
// NB: DR 675.
|
this->_M_invalidate_all();
|
||||||
clear();
|
_M_update_guaranteed_capacity();
|
||||||
swap(__x);
|
__x._M_invalidate_all();
|
||||||
|
__x._M_guaranteed_capacity = 0;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,6 +529,9 @@ namespace __debug
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(vector& __x)
|
swap(vector& __x)
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
noexcept(_Alloc_traits::_S_nothrow_swap())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_Base::swap(__x);
|
_Base::swap(__x);
|
||||||
this->_M_swap(__x);
|
this->_M_swap(__x);
|
||||||
|
|
|
@ -50,6 +50,10 @@ namespace __profile
|
||||||
{
|
{
|
||||||
typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base;
|
typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base;
|
||||||
|
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits;
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::reference reference;
|
typedef typename _Base::reference reference;
|
||||||
typedef typename _Base::const_reference const_reference;
|
typedef typename _Base::const_reference const_reference;
|
||||||
|
@ -143,6 +147,20 @@ namespace __profile
|
||||||
__profcxx_vector_construct2(this);
|
__profcxx_vector_construct2(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector(const _Base& __x, const _Allocator& __a)
|
||||||
|
: _Base(__x)
|
||||||
|
{
|
||||||
|
__profcxx_vector_construct(this, this->capacity());
|
||||||
|
__profcxx_vector_construct2(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
vector(vector&& __x, const _Allocator& __a) noexcept
|
||||||
|
: _Base(std::move(__x), __a)
|
||||||
|
{
|
||||||
|
__profcxx_vector_construct(this, this->capacity());
|
||||||
|
__profcxx_vector_construct2(this);
|
||||||
|
}
|
||||||
|
|
||||||
vector(initializer_list<value_type> __l,
|
vector(initializer_list<value_type> __l,
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__l, __a) { }
|
: _Base(__l, __a) { }
|
||||||
|
@ -163,12 +181,11 @@ namespace __profile
|
||||||
|
|
||||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
vector&
|
vector&
|
||||||
operator=(vector&& __x)
|
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
|
||||||
{
|
{
|
||||||
// NB: DR 1204.
|
__profcxx_vector_destruct(this, this->capacity(), this->size());
|
||||||
// NB: DR 675.
|
__profcxx_vector_destruct2(this);
|
||||||
this->clear();
|
static_cast<_Base&>(*this) = std::move(__x);
|
||||||
this->swap(__x);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +346,7 @@ namespace __profile
|
||||||
push_back(_Tp&& __x)
|
push_back(_Tp&& __x)
|
||||||
{
|
{
|
||||||
size_type __old_size = this->capacity();
|
size_type __old_size = this->capacity();
|
||||||
_Base::push_back(__x);
|
_Base::push_back(std::move(__x));
|
||||||
_M_profile_resize(this, __old_size, this->capacity());
|
_M_profile_resize(this, __old_size, this->capacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,6 +390,9 @@ namespace __profile
|
||||||
|
|
||||||
void
|
void
|
||||||
swap(vector& __x)
|
swap(vector& __x)
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
noexcept(_Alloc_traits::_S_nothrow_swap())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_Base::swap(__x);
|
_Base::swap(__x);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
// Copyright (C) 2011 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
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this library; see the file COPYING3. If not see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++11" }
|
||||||
|
|
||||||
|
#include <debug/vector>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <testsuite_allocator.h>
|
||||||
|
|
||||||
|
template<typename T, typename A>
|
||||||
|
void
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
typedef std::vector<T, A> base;
|
||||||
|
typedef __gnu_debug::vector<T, A> debug;
|
||||||
|
|
||||||
|
using std::is_nothrow_default_constructible;
|
||||||
|
using std::is_nothrow_copy_constructible;
|
||||||
|
using std::is_nothrow_move_constructible;
|
||||||
|
using std::is_nothrow_copy_assignable;
|
||||||
|
using std::is_nothrow_move_assignable;
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
is_nothrow_default_constructible<base>::value
|
||||||
|
== is_nothrow_default_constructible<debug>::value,
|
||||||
|
"nothrow default constructible");
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
is_nothrow_copy_constructible<base>::value
|
||||||
|
== is_nothrow_copy_constructible<debug>::value,
|
||||||
|
"nothrow copy constructible");
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
is_nothrow_move_constructible<base>::value
|
||||||
|
== is_nothrow_move_constructible<debug>::value,
|
||||||
|
"nothrow move constructible");
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
is_nothrow_copy_assignable<base>::value
|
||||||
|
== is_nothrow_copy_assignable<debug>::value,
|
||||||
|
"nothrow move assignable");
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
is_nothrow_move_assignable<base>::value
|
||||||
|
== is_nothrow_move_assignable<debug>::value,
|
||||||
|
"nothrow move assignable");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct X
|
||||||
|
{
|
||||||
|
X() { }
|
||||||
|
~X() { }
|
||||||
|
X(const X&) { }
|
||||||
|
X(X&&) { }
|
||||||
|
X& operator=(const X&) { }
|
||||||
|
X& operator=(X&&) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using __gnu_test::propagating_allocator;
|
||||||
|
using __gnu_test::SimpleAllocator;
|
||||||
|
|
||||||
|
test<int, std::allocator<int>>();
|
||||||
|
test<int, SimpleAllocator<int>>();
|
||||||
|
test<int, propagating_allocator<int, true>>();
|
||||||
|
test<int, propagating_allocator<int, false>>();
|
||||||
|
test<X, std::allocator<X>>();
|
||||||
|
test<X, SimpleAllocator<X>>();
|
||||||
|
test<X, propagating_allocator<X, true>>();
|
||||||
|
test<X, propagating_allocator<X, false>>();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue