mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-15 01:40:36 +08:00
re PR libstdc++/32618 (std::vector calls uneccessary constructors instead of inplace construction of first object)
2010-06-18 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/32618 * include/bits/stl_list.h (vector<>::_M_default_initialize, _M_default_append): Declare. (list<>::list(size_type), resize(size_type)): Add in C++0x mode, use the latter. * include/bits/list.tcc (list<>::resize, _M_default_append): Define. * include/bits/stl_vector.h (vector<>::_M_default_initialize, _M_default_append): Declare. (vector<>::vector(size_type), resize(size_type)): Add in C++0x mode, use the latter. * include/bits/vector.tcc (vector<>::_M_default_append): Define. * include/bits/stl_deque.h (deque<>::_M_default_initialize, _M_default_append): Declare. (deque<>::deque(size_type), resize(size_type)): Add in C++0x mode, use the latter. * include/bits/deque.tcc (deque<>::_M_default_append): Define. * include/debug/vector: Update. * include/debug/deque: Likewise. * include/debug/list: Likewise. * include/profile/vector: Likewise. * include/profile/deque: Likewise. * include/profile/list: Likewise. * include/bits/forward_list.h (_M_default_initialize, _M_default_insert_after): Declare. (forward_list<>::forward_list(size_type), resize(size_type)): Fix, use the latter. * include/bits/forward_list.tcc (forward_list<>::_M_default_append, _M_default_insert_after): Define. * testsuite/util/testsuite_api.h (NonCopyConstructible): Add. * testsuite/23_containers/forward_list/modifiers/6.cc: Move to... * testsuite/23_containers/forward_list/capacity/resize_size.cc: ... here. * testsuite/23_containers/forward_list/cons/10.cc: Move to... * testsuite/23_containers/forward_list/cons/cons_size.cc: ... here. * testsuite/23_containers/vector/resize/1.cc: Move to... * testsuite/23_containers/vector/capacity/resize/1.cc: ... here. * testsuite/23_containers/vector/resize/moveable.cc: Move to... * testsuite/23_containers/vector/resize/capacity/moveable.cc: ... here. * testsuite/23_containers/vector/cons/cons_size.cc: New. * testsuite/23_containers/vector/capacity/resize/resize_size.cc: Likewise. * testsuite/23_containers/deque/cons/cons_size.cc: Likewise. * testsuite/23_containers/deque/capacity/resize_size.cc: Likewise. * testsuite/23_containers/list/cons/cons_size.cc: Likewise. * testsuite/23_containers/list/capacity/resize_size.cc: Likewise. * testsuite/23_containers/vector/capacity/resize/moveable.cc: Adjust. * testsuite/23_containers/deque/capacity/moveable.cc: Likewise. * testsuite/23_containers/forward_list/requirements/dr438/ assign_neg.cc: Adjust dg-error line numbers. * testsuite/23_containers/forward_list/requirements/dr438/ insert_neg.cc: Likewise. * testsuite/23_containers/forward_list/requirements/dr438/ constructor_1_neg.cc: Likewise. * testsuite/23_containers/forward_list/requirements/dr438/ constructor_2_neg.cc: Likewise. * testsuite/23_containers/vector/requirements/dr438/ assign_neg.cc: Likewise. * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Likewise. * testsuite/23_containers/vector/requirements/dr438/ constructor_1_neg.cc: Likewise. * testsuite/23_containers/vector/requirements/dr438/ constructor_2_neg.cc: Likewise. * testsuite/23_containers/deque/requirements/dr438/ assign_neg.cc: Likewise. * testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Likewise. * testsuite/23_containers/deque/requirements/dr438/ constructor_1_neg.cc: Likewise. * testsuite/23_containers/deque/requirements/dr438/ constructor_2_neg.cc: Likewise. * testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Likewise. * 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. From-SVN: r161009
This commit is contained in:
parent
fae76410f4
commit
dc2cf706b8
@ -1,3 +1,85 @@
|
||||
2010-06-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR libstdc++/32618
|
||||
* include/bits/stl_list.h (vector<>::_M_default_initialize,
|
||||
_M_default_append): Declare.
|
||||
(list<>::list(size_type), resize(size_type)): Add in C++0x mode,
|
||||
use the latter.
|
||||
* include/bits/list.tcc (list<>::resize, _M_default_append): Define.
|
||||
* include/bits/stl_vector.h (vector<>::_M_default_initialize,
|
||||
_M_default_append): Declare.
|
||||
(vector<>::vector(size_type), resize(size_type)): Add in C++0x mode,
|
||||
use the latter.
|
||||
* include/bits/vector.tcc (vector<>::_M_default_append): Define.
|
||||
* include/bits/stl_deque.h (deque<>::_M_default_initialize,
|
||||
_M_default_append): Declare.
|
||||
(deque<>::deque(size_type), resize(size_type)): Add in C++0x mode,
|
||||
use the latter.
|
||||
* include/bits/deque.tcc (deque<>::_M_default_append): Define.
|
||||
* include/debug/vector: Update.
|
||||
* include/debug/deque: Likewise.
|
||||
* include/debug/list: Likewise.
|
||||
* include/profile/vector: Likewise.
|
||||
* include/profile/deque: Likewise.
|
||||
* include/profile/list: Likewise.
|
||||
* include/bits/forward_list.h (_M_default_initialize,
|
||||
_M_default_insert_after): Declare.
|
||||
(forward_list<>::forward_list(size_type), resize(size_type)): Fix,
|
||||
use the latter.
|
||||
* include/bits/forward_list.tcc (forward_list<>::_M_default_append,
|
||||
_M_default_insert_after): Define.
|
||||
* testsuite/util/testsuite_api.h (NonCopyConstructible): Add.
|
||||
* testsuite/23_containers/forward_list/modifiers/6.cc: Move to...
|
||||
* testsuite/23_containers/forward_list/capacity/resize_size.cc:
|
||||
... here.
|
||||
* testsuite/23_containers/forward_list/cons/10.cc: Move to...
|
||||
* testsuite/23_containers/forward_list/cons/cons_size.cc: ... here.
|
||||
* testsuite/23_containers/vector/resize/1.cc: Move to...
|
||||
* testsuite/23_containers/vector/capacity/resize/1.cc: ... here.
|
||||
* testsuite/23_containers/vector/resize/moveable.cc: Move to...
|
||||
* testsuite/23_containers/vector/resize/capacity/moveable.cc: ... here.
|
||||
* testsuite/23_containers/vector/cons/cons_size.cc: New.
|
||||
* testsuite/23_containers/vector/capacity/resize/resize_size.cc:
|
||||
Likewise.
|
||||
* testsuite/23_containers/deque/cons/cons_size.cc: Likewise.
|
||||
* testsuite/23_containers/deque/capacity/resize_size.cc: Likewise.
|
||||
* testsuite/23_containers/list/cons/cons_size.cc: Likewise.
|
||||
* testsuite/23_containers/list/capacity/resize_size.cc: Likewise.
|
||||
* testsuite/23_containers/vector/capacity/resize/moveable.cc: Adjust.
|
||||
* testsuite/23_containers/deque/capacity/moveable.cc: Likewise.
|
||||
* testsuite/23_containers/forward_list/requirements/dr438/
|
||||
assign_neg.cc: Adjust dg-error line numbers.
|
||||
* testsuite/23_containers/forward_list/requirements/dr438/
|
||||
insert_neg.cc: Likewise.
|
||||
* testsuite/23_containers/forward_list/requirements/dr438/
|
||||
constructor_1_neg.cc: Likewise.
|
||||
* testsuite/23_containers/forward_list/requirements/dr438/
|
||||
constructor_2_neg.cc: Likewise.
|
||||
* testsuite/23_containers/vector/requirements/dr438/
|
||||
assign_neg.cc: Likewise.
|
||||
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
|
||||
Likewise.
|
||||
* testsuite/23_containers/vector/requirements/dr438/
|
||||
constructor_1_neg.cc: Likewise.
|
||||
* testsuite/23_containers/vector/requirements/dr438/
|
||||
constructor_2_neg.cc: Likewise.
|
||||
* testsuite/23_containers/deque/requirements/dr438/
|
||||
assign_neg.cc: Likewise.
|
||||
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
|
||||
Likewise.
|
||||
* testsuite/23_containers/deque/requirements/dr438/
|
||||
constructor_1_neg.cc: Likewise.
|
||||
* testsuite/23_containers/deque/requirements/dr438/
|
||||
constructor_2_neg.cc: Likewise.
|
||||
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
|
||||
Likewise.
|
||||
* 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.
|
||||
|
||||
2010-06-17 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/bits/stl_uninitialized.h (__uninitialized_default,
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Deque implementation (out of line) -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
||||
// 2009, 2010
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
@ -59,6 +60,33 @@
|
||||
|
||||
_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
template <typename _Tp, typename _Alloc>
|
||||
void
|
||||
deque<_Tp, _Alloc>::
|
||||
_M_default_initialize()
|
||||
{
|
||||
_Map_pointer __cur;
|
||||
__try
|
||||
{
|
||||
for (__cur = this->_M_impl._M_start._M_node;
|
||||
__cur < this->_M_impl._M_finish._M_node;
|
||||
++__cur)
|
||||
std::__uninitialized_default_a(*__cur, *__cur + _S_buffer_size(),
|
||||
_M_get_Tp_allocator());
|
||||
std::__uninitialized_default_a(this->_M_impl._M_finish._M_first,
|
||||
this->_M_impl._M_finish._M_cur,
|
||||
_M_get_Tp_allocator());
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur),
|
||||
_M_get_Tp_allocator());
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename _Tp, typename _Alloc>
|
||||
deque<_Tp, _Alloc>&
|
||||
deque<_Tp, _Alloc>::
|
||||
@ -271,6 +299,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
_M_insert_aux(__pos, __n, __x);
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
template <typename _Tp, typename _Alloc>
|
||||
void
|
||||
deque<_Tp, _Alloc>::
|
||||
_M_default_append(size_type __n)
|
||||
{
|
||||
if (__n)
|
||||
{
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
__try
|
||||
{
|
||||
std::__uninitialized_default_a(this->_M_impl._M_finish,
|
||||
__new_finish,
|
||||
_M_get_Tp_allocator());
|
||||
this->_M_impl._M_finish = __new_finish;
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
_M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
|
||||
__new_finish._M_node + 1);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename _Tp, typename _Alloc>
|
||||
void
|
||||
deque<_Tp, _Alloc>::
|
||||
|
@ -463,7 +463,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
* constructed elements.
|
||||
*/
|
||||
explicit
|
||||
forward_list(size_type __n);
|
||||
forward_list(size_type __n)
|
||||
: _Base()
|
||||
{ _M_default_initialize(__n); }
|
||||
|
||||
/**
|
||||
* @brief Creates a %forward_list with copies of an exemplar element.
|
||||
@ -1209,6 +1211,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
// Called by splice_after and insert_after.
|
||||
iterator
|
||||
_M_splice_after(const_iterator __pos, forward_list&& __list);
|
||||
|
||||
// Called by forward_list(n).
|
||||
void
|
||||
_M_default_initialize(size_type __n);
|
||||
|
||||
// Called by resize(sz).
|
||||
void
|
||||
_M_default_insert_after(const_iterator __pos, size_type __n);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
_M_fill_initialize(size_type __n, const value_type& __value)
|
||||
{
|
||||
_Node_base* __to = &this->_M_impl._M_head;
|
||||
for (; __n > 0; --__n)
|
||||
for (; __n; --__n)
|
||||
{
|
||||
__to->_M_next = this->_M_create_node(__value);
|
||||
__to = __to->_M_next;
|
||||
@ -122,12 +122,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
void
|
||||
forward_list<_Tp, _Alloc>::
|
||||
forward_list(size_type __n)
|
||||
: _Base()
|
||||
_M_default_initialize(size_type __n)
|
||||
{
|
||||
_Node_base* __to = &this->_M_impl._M_head;
|
||||
for (; __n > 0; --__n)
|
||||
for (; __n; --__n)
|
||||
{
|
||||
__to->_M_next = this->_M_create_node();
|
||||
__to = __to->_M_next;
|
||||
@ -161,6 +161,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
void
|
||||
forward_list<_Tp, _Alloc>::
|
||||
_M_default_insert_after(const_iterator __pos, size_type __n)
|
||||
{
|
||||
const_iterator __saved_pos = __pos;
|
||||
__try
|
||||
{
|
||||
for (; __n; --__n)
|
||||
__pos = emplace_after(__pos);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
erase_after(__saved_pos, ++__pos);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
void
|
||||
forward_list<_Tp, _Alloc>::
|
||||
@ -177,10 +195,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
if (__len == __sz)
|
||||
erase_after(__k, end());
|
||||
else
|
||||
{
|
||||
forward_list __tmp(__sz - __len);
|
||||
splice_after(__k, std::move(__tmp));
|
||||
}
|
||||
_M_default_insert_after(__k, __sz - __len);
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
|
@ -112,6 +112,56 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
return __ret;
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
template<typename _Tp, typename _Alloc>
|
||||
void
|
||||
list<_Tp, _Alloc>::
|
||||
_M_default_append(size_type __n)
|
||||
{
|
||||
size_type __i = 0;
|
||||
__try
|
||||
{
|
||||
for (; __i < __n; ++__i)
|
||||
emplace_back();
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
for (; __i; --__i)
|
||||
pop_back();
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
void
|
||||
list<_Tp, _Alloc>::
|
||||
resize(size_type __new_size)
|
||||
{
|
||||
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>
|
||||
void
|
||||
list<_Tp, _Alloc>::
|
||||
resize(size_type __new_size, const value_type& __x)
|
||||
{
|
||||
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>
|
||||
void
|
||||
list<_Tp, _Alloc>::
|
||||
@ -126,6 +176,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
else // __i == end()
|
||||
insert(end(), __new_size - __len, __x);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
list<_Tp, _Alloc>&
|
||||
|
@ -449,6 +449,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
: _M_impl()
|
||||
{ _M_initialize_map(0); }
|
||||
|
||||
_Deque_base(size_t __num_elements)
|
||||
: _M_impl()
|
||||
{ _M_initialize_map(__num_elements); }
|
||||
|
||||
_Deque_base(const allocator_type& __a, size_t __num_elements)
|
||||
: _M_impl(__a)
|
||||
{ _M_initialize_map(__num_elements); }
|
||||
@ -773,6 +777,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
deque(const allocator_type& __a)
|
||||
: _Base(__a, 0) { }
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Creates a %deque with default constructed elements.
|
||||
* @param n The number of elements to initially create.
|
||||
*
|
||||
* This constructor fills the %deque with @a n default
|
||||
* constructed elements.
|
||||
*/
|
||||
explicit
|
||||
deque(size_type __n)
|
||||
: _Base(__n)
|
||||
{ _M_default_initialize(); }
|
||||
|
||||
/**
|
||||
* @brief Creates a %deque with copies of an exemplar element.
|
||||
* @param n The number of elements to initially create.
|
||||
* @param value An element to copy.
|
||||
* @param a An allocator.
|
||||
*
|
||||
* This constructor fills the %deque with @a n copies of @a value.
|
||||
*/
|
||||
deque(size_type __n, const value_type& __value,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__a, __n)
|
||||
{ _M_fill_initialize(__value); }
|
||||
#else
|
||||
/**
|
||||
* @brief Creates a %deque with copies of an exemplar element.
|
||||
* @param n The number of elements to initially create.
|
||||
@ -786,6 +816,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__a, __n)
|
||||
{ _M_fill_initialize(__value); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief %Deque copy constructor.
|
||||
@ -824,11 +855,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
*/
|
||||
deque(initializer_list<value_type> __l,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__a)
|
||||
{
|
||||
_M_range_initialize(__l.begin(), __l.end(),
|
||||
random_access_iterator_tag());
|
||||
}
|
||||
: _Base(__a)
|
||||
{
|
||||
_M_range_initialize(__l.begin(), __l.end(),
|
||||
random_access_iterator_tag());
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -1086,6 +1117,49 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
max_size() const
|
||||
{ return _M_get_Tp_allocator().max_size(); }
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Resizes the %deque to the specified number of elements.
|
||||
* @param new_size Number of elements the %deque should contain.
|
||||
*
|
||||
* This function will %resize the %deque to the specified
|
||||
* number of elements. If the number is smaller than the
|
||||
* %deque's current size the %deque is truncated, otherwise
|
||||
* default constructed elements are appended.
|
||||
*/
|
||||
void
|
||||
resize(size_type __new_size)
|
||||
{
|
||||
const size_type __len = size();
|
||||
if (__new_size > __len)
|
||||
_M_default_append(__new_size - __len);
|
||||
else if (__new_size < __len)
|
||||
_M_erase_at_end(this->_M_impl._M_start
|
||||
+ difference_type(__new_size));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resizes the %deque to the specified number of elements.
|
||||
* @param new_size Number of elements the %deque should contain.
|
||||
* @param x Data with which new elements should be populated.
|
||||
*
|
||||
* This function will %resize the %deque to the specified
|
||||
* number of elements. If the number is smaller than the
|
||||
* %deque's current size the %deque is truncated, otherwise the
|
||||
* %deque is extended and new elements are populated with given
|
||||
* data.
|
||||
*/
|
||||
void
|
||||
resize(size_type __new_size, const value_type& __x)
|
||||
{
|
||||
const size_type __len = size();
|
||||
if (__new_size > __len)
|
||||
insert(this->_M_impl._M_finish, __new_size - __len, __x);
|
||||
else if (__new_size < __len)
|
||||
_M_erase_at_end(this->_M_impl._M_start
|
||||
+ difference_type(__new_size));
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* @brief Resizes the %deque to the specified number of elements.
|
||||
* @param new_size Number of elements the %deque should contain.
|
||||
@ -1101,11 +1175,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
resize(size_type __new_size, value_type __x = value_type())
|
||||
{
|
||||
const size_type __len = size();
|
||||
if (__new_size < __len)
|
||||
_M_erase_at_end(this->_M_impl._M_start + difference_type(__new_size));
|
||||
else
|
||||
if (__new_size > __len)
|
||||
insert(this->_M_impl._M_finish, __new_size - __len, __x);
|
||||
else if (__new_size < __len)
|
||||
_M_erase_at_end(this->_M_impl._M_start
|
||||
+ difference_type(__new_size));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/** A non-binding request to reduce memory use. */
|
||||
@ -1564,6 +1640,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
void
|
||||
_M_fill_initialize(const value_type& __value);
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
// called by deque(n).
|
||||
void
|
||||
_M_default_initialize();
|
||||
#endif
|
||||
|
||||
// Internal assign functions follow. The *_aux functions do the actual
|
||||
// assignment work for the range versions.
|
||||
|
||||
@ -1752,6 +1834,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
this->_M_impl._M_finish = __pos;
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
// Called by resize(sz).
|
||||
void
|
||||
_M_default_append(size_type __n);
|
||||
#endif
|
||||
|
||||
//@{
|
||||
/// Memory-handling helpers for the previous internal insert functions.
|
||||
iterator
|
||||
|
@ -508,6 +508,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
list(const allocator_type& __a)
|
||||
: _Base(__a) { }
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Creates a %list with default constructed elements.
|
||||
* @param n The number of elements to initially create.
|
||||
*
|
||||
* This constructor fills the %list with @a n default
|
||||
* constructed elements.
|
||||
*/
|
||||
explicit
|
||||
list(size_type __n)
|
||||
: _Base()
|
||||
{ _M_default_initialize(__n); }
|
||||
|
||||
/**
|
||||
* @brief Creates a %list with copies of an exemplar element.
|
||||
* @param n The number of elements to initially create.
|
||||
* @param value An element to copy.
|
||||
* @param a An allocator object.
|
||||
*
|
||||
* This constructor fills the %list with @a n copies of @a value.
|
||||
*/
|
||||
list(size_type __n, const value_type& __value,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__a)
|
||||
{ _M_fill_initialize(__n, __value); }
|
||||
#else
|
||||
/**
|
||||
* @brief Creates a %list with copies of an exemplar element.
|
||||
* @param n The number of elements to initially create.
|
||||
@ -521,6 +547,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__a)
|
||||
{ _M_fill_initialize(__n, __value); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief %List copy constructor.
|
||||
@ -811,6 +838,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
max_size() const
|
||||
{ return _M_get_Node_allocator().max_size(); }
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Resizes the %list to the specified number of elements.
|
||||
* @param new_size Number of elements the %list should contain.
|
||||
*
|
||||
* This function will %resize the %list to the specified number
|
||||
* of elements. If the number is smaller than the %list's
|
||||
* current size the %list is truncated, otherwise default
|
||||
* constructed elements are appended.
|
||||
*/
|
||||
void
|
||||
resize(size_type __new_size);
|
||||
|
||||
/**
|
||||
* @brief Resizes the %list to the specified number of elements.
|
||||
* @param new_size Number of elements the %list should contain.
|
||||
* @param x Data with which new elements should be populated.
|
||||
*
|
||||
* This function will %resize the %list to the specified number
|
||||
* of elements. If the number is smaller than the %list's
|
||||
* current size the %list is truncated, otherwise the %list is
|
||||
* extended and new elements are populated with given data.
|
||||
*/
|
||||
void
|
||||
resize(size_type __new_size, const value_type& __x);
|
||||
#else
|
||||
/**
|
||||
* @brief Resizes the %list to the specified number of elements.
|
||||
* @param new_size Number of elements the %list should contain.
|
||||
@ -823,6 +876,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
*/
|
||||
void
|
||||
resize(size_type __new_size, value_type __x = value_type());
|
||||
#endif
|
||||
|
||||
// element access
|
||||
/**
|
||||
@ -1394,10 +1448,23 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
void
|
||||
_M_fill_initialize(size_type __n, const value_type& __x)
|
||||
{
|
||||
for (; __n > 0; --__n)
|
||||
for (; __n; --__n)
|
||||
push_back(__x);
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
// Called by list(n).
|
||||
void
|
||||
_M_default_initialize(size_type __n)
|
||||
{
|
||||
for (; __n; --__n)
|
||||
emplace_back();
|
||||
}
|
||||
|
||||
// Called by resize(sz).
|
||||
void
|
||||
_M_default_append(size_type __n);
|
||||
#endif
|
||||
|
||||
// Internal assign functions follow.
|
||||
|
||||
|
@ -107,6 +107,14 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
_Vector_base(const allocator_type& __a)
|
||||
: _M_impl(__a) { }
|
||||
|
||||
_Vector_base(size_t __n)
|
||||
: _M_impl()
|
||||
{
|
||||
this->_M_impl._M_start = this->_M_allocate(__n);
|
||||
this->_M_impl._M_finish = this->_M_impl._M_start;
|
||||
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
|
||||
}
|
||||
|
||||
_Vector_base(size_t __n, const allocator_type& __a)
|
||||
: _M_impl(__a)
|
||||
{
|
||||
@ -215,6 +223,32 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
vector(const allocator_type& __a)
|
||||
: _Base(__a) { }
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Creates a %vector with default constructed elements.
|
||||
* @param n The number of elements to initially create.
|
||||
*
|
||||
* This constructor fills the %vector with @a n default
|
||||
* constructed elements.
|
||||
*/
|
||||
explicit
|
||||
vector(size_type __n)
|
||||
: _Base(__n)
|
||||
{ _M_default_initialize(__n); }
|
||||
|
||||
/**
|
||||
* @brief Creates a %vector with copies of an exemplar element.
|
||||
* @param n The number of elements to initially create.
|
||||
* @param value An element to copy.
|
||||
* @param a An allocator.
|
||||
*
|
||||
* This constructor fills the %vector with @a n copies of @a value.
|
||||
*/
|
||||
vector(size_type __n, const value_type& __value,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__n, __a)
|
||||
{ _M_fill_initialize(__n, __value); }
|
||||
#else
|
||||
/**
|
||||
* @brief Creates a %vector with copies of an exemplar element.
|
||||
* @param n The number of elements to initially create.
|
||||
@ -228,6 +262,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _Base(__n, __a)
|
||||
{ _M_fill_initialize(__n, __value); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief %Vector copy constructor.
|
||||
@ -538,6 +573,45 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
max_size() const
|
||||
{ return _M_get_Tp_allocator().max_size(); }
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/**
|
||||
* @brief Resizes the %vector to the specified number of elements.
|
||||
* @param new_size Number of elements the %vector should contain.
|
||||
*
|
||||
* This function will %resize the %vector to the specified
|
||||
* number of elements. If the number is smaller than the
|
||||
* %vector's current size the %vector is truncated, otherwise
|
||||
* default constructed elements are appended.
|
||||
*/
|
||||
void
|
||||
resize(size_type __new_size)
|
||||
{
|
||||
if (__new_size > size())
|
||||
_M_default_append(__new_size - size());
|
||||
else if (__new_size < size())
|
||||
_M_erase_at_end(this->_M_impl._M_start + __new_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resizes the %vector to the specified number of elements.
|
||||
* @param new_size Number of elements the %vector should contain.
|
||||
* @param x Data with which new elements should be populated.
|
||||
*
|
||||
* This function will %resize the %vector to the specified
|
||||
* number of elements. If the number is smaller than the
|
||||
* %vector's current size the %vector is truncated, otherwise
|
||||
* the %vector is extended and new elements are populated with
|
||||
* given data.
|
||||
*/
|
||||
void
|
||||
resize(size_type __new_size, const value_type& __x)
|
||||
{
|
||||
if (__new_size > size())
|
||||
insert(end(), __new_size - size(), __x);
|
||||
else if (__new_size < size())
|
||||
_M_erase_at_end(this->_M_impl._M_start + __new_size);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* @brief Resizes the %vector to the specified number of elements.
|
||||
* @param new_size Number of elements the %vector should contain.
|
||||
@ -552,11 +626,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
void
|
||||
resize(size_type __new_size, value_type __x = value_type())
|
||||
{
|
||||
if (__new_size < size())
|
||||
_M_erase_at_end(this->_M_impl._M_start + __new_size);
|
||||
else
|
||||
if (__new_size > size())
|
||||
insert(end(), __new_size - size(), __x);
|
||||
else if (__new_size < size())
|
||||
_M_erase_at_end(this->_M_impl._M_start + __new_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
/** A non-binding request to reduce capacity() to size(). */
|
||||
@ -1049,6 +1124,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
// Called by the vector(n) constructor.
|
||||
void
|
||||
_M_default_initialize(size_type __n)
|
||||
{
|
||||
std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
|
||||
_M_get_Tp_allocator());
|
||||
this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Internal assign functions follow. The *_aux functions do the actual
|
||||
// assignment work for the range versions.
|
||||
@ -1131,6 +1216,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
void
|
||||
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
// Called by resize(n).
|
||||
void
|
||||
_M_default_append(size_type __n);
|
||||
#endif
|
||||
|
||||
// Called by insert(p,x)
|
||||
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
||||
void
|
||||
|
@ -458,6 +458,59 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
template<typename _Tp, typename _Alloc>
|
||||
void
|
||||
vector<_Tp, _Alloc>::
|
||||
_M_default_append(size_type __n)
|
||||
{
|
||||
if (__n != 0)
|
||||
{
|
||||
if (size_type(this->_M_impl._M_end_of_storage
|
||||
- this->_M_impl._M_finish) >= __n)
|
||||
{
|
||||
std::__uninitialized_default_n_a(this->_M_impl._M_finish,
|
||||
__n, _M_get_Tp_allocator());
|
||||
this->_M_impl._M_finish += __n;
|
||||
}
|
||||
else
|
||||
{
|
||||
const size_type __len =
|
||||
_M_check_len(__n, "vector::_M_default_append");
|
||||
const size_type __old_size = this->size();
|
||||
pointer __new_start(this->_M_allocate(__len));
|
||||
pointer __new_finish(__new_start);
|
||||
__try
|
||||
{
|
||||
__new_finish =
|
||||
std::__uninitialized_move_a(this->_M_impl._M_start,
|
||||
this->_M_impl._M_finish,
|
||||
__new_start,
|
||||
_M_get_Tp_allocator());
|
||||
std::__uninitialized_default_n_a(__new_finish, __n,
|
||||
_M_get_Tp_allocator());
|
||||
__new_finish += __n;
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
std::_Destroy(__new_start, __new_finish,
|
||||
_M_get_Tp_allocator());
|
||||
_M_deallocate(__new_start, __len);
|
||||
__throw_exception_again;
|
||||
}
|
||||
std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
|
||||
_M_get_Tp_allocator());
|
||||
_M_deallocate(this->_M_impl._M_start,
|
||||
this->_M_impl._M_end_of_storage
|
||||
- this->_M_impl._M_start);
|
||||
this->_M_impl._M_start = __new_start;
|
||||
this->_M_impl._M_finish = __new_finish;
|
||||
this->_M_impl._M_end_of_storage = __new_start + __len;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Tp, typename _Alloc>
|
||||
template<typename _InputIterator>
|
||||
void
|
||||
|
@ -67,12 +67,24 @@ namespace __debug
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
// 23.2.1.1 construct/copy/destroy:
|
||||
explicit deque(const _Allocator& __a = _Allocator())
|
||||
explicit
|
||||
deque(const _Allocator& __a = _Allocator())
|
||||
: _Base(__a) { }
|
||||
|
||||
explicit deque(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
explicit
|
||||
deque(size_type __n)
|
||||
: _Base(__n) { }
|
||||
|
||||
deque(size_type __n, const _Tp& __value,
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a) { }
|
||||
#else
|
||||
explicit
|
||||
deque(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a) { }
|
||||
#endif
|
||||
|
||||
template<class _InputIterator>
|
||||
deque(_InputIterator __first, _InputIterator __last,
|
||||
@ -208,6 +220,39 @@ namespace __debug
|
||||
using _Base::size;
|
||||
using _Base::max_size;
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
void
|
||||
resize(size_type __sz)
|
||||
{
|
||||
typedef typename _Base::const_iterator _Base_const_iterator;
|
||||
typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
|
||||
|
||||
bool __invalidate_all = __sz > this->size();
|
||||
if (__sz < this->size())
|
||||
this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
|
||||
|
||||
_Base::resize(__sz);
|
||||
|
||||
if (__invalidate_all)
|
||||
this->_M_invalidate_all();
|
||||
}
|
||||
|
||||
void
|
||||
resize(size_type __sz, const _Tp& __c)
|
||||
{
|
||||
typedef typename _Base::const_iterator _Base_const_iterator;
|
||||
typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
|
||||
|
||||
bool __invalidate_all = __sz > this->size();
|
||||
if (__sz < this->size())
|
||||
this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
|
||||
|
||||
_Base::resize(__sz, __c);
|
||||
|
||||
if (__invalidate_all)
|
||||
this->_M_invalidate_all();
|
||||
}
|
||||
#else
|
||||
void
|
||||
resize(size_type __sz, _Tp __c = _Tp())
|
||||
{
|
||||
@ -223,6 +268,7 @@ namespace __debug
|
||||
if (__invalidate_all)
|
||||
this->_M_invalidate_all();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
using _Base::shrink_to_fit;
|
||||
|
@ -67,12 +67,24 @@ namespace __debug
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
// 23.2.2.1 construct/copy/destroy:
|
||||
explicit list(const _Allocator& __a = _Allocator())
|
||||
explicit
|
||||
list(const _Allocator& __a = _Allocator())
|
||||
: _Base(__a) { }
|
||||
|
||||
explicit list(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
explicit
|
||||
list(size_type __n)
|
||||
: _Base(__n) { }
|
||||
|
||||
list(size_type __n, const _Tp& __value,
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a) { }
|
||||
#else
|
||||
explicit
|
||||
list(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a) { }
|
||||
#endif
|
||||
|
||||
template<class _InputIterator>
|
||||
list(_InputIterator __first, _InputIterator __last,
|
||||
@ -208,6 +220,63 @@ namespace __debug
|
||||
using _Base::size;
|
||||
using _Base::max_size;
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
void
|
||||
resize(size_type __sz)
|
||||
{
|
||||
this->_M_detach_singular();
|
||||
|
||||
// if __sz < size(), invalidate all iterators in [begin+__sz, end())
|
||||
iterator __victim = begin();
|
||||
iterator __end = end();
|
||||
for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
|
||||
++__victim;
|
||||
|
||||
while (__victim != __end)
|
||||
{
|
||||
iterator __real_victim = __victim++;
|
||||
__real_victim._M_invalidate();
|
||||
}
|
||||
|
||||
__try
|
||||
{
|
||||
_Base::resize(__sz);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
this->_M_revalidate_singular();
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
resize(size_type __sz, const _Tp& __c)
|
||||
{
|
||||
this->_M_detach_singular();
|
||||
|
||||
// if __sz < size(), invalidate all iterators in [begin+__sz, end())
|
||||
iterator __victim = begin();
|
||||
iterator __end = end();
|
||||
for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
|
||||
++__victim;
|
||||
|
||||
while (__victim != __end)
|
||||
{
|
||||
iterator __real_victim = __victim++;
|
||||
__real_victim._M_invalidate();
|
||||
}
|
||||
|
||||
__try
|
||||
{
|
||||
_Base::resize(__sz, __c);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
this->_M_revalidate_singular();
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
resize(size_type __sz, _Tp __c = _Tp())
|
||||
{
|
||||
@ -235,6 +304,7 @@ namespace __debug
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// element access:
|
||||
reference
|
||||
|
@ -72,12 +72,24 @@ namespace __debug
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
// 23.2.4.1 construct/copy/destroy:
|
||||
explicit vector(const _Allocator& __a = _Allocator())
|
||||
explicit
|
||||
vector(const _Allocator& __a = _Allocator())
|
||||
: _Base(__a), _M_guaranteed_capacity(0) { }
|
||||
|
||||
explicit vector(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
explicit
|
||||
vector(size_type __n)
|
||||
: _Base(__n), _M_guaranteed_capacity(__n) { }
|
||||
|
||||
vector(size_type __n, const _Tp& __value,
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a), _M_guaranteed_capacity(__n) { }
|
||||
#else
|
||||
explicit
|
||||
vector(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a), _M_guaranteed_capacity(__n) { }
|
||||
#endif
|
||||
|
||||
template<class _InputIterator>
|
||||
vector(_InputIterator __first, _InputIterator __last,
|
||||
@ -226,6 +238,31 @@ namespace __debug
|
||||
using _Base::size;
|
||||
using _Base::max_size;
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
void
|
||||
resize(size_type __sz)
|
||||
{
|
||||
bool __realloc = _M_requires_reallocation(__sz);
|
||||
if (__sz < this->size())
|
||||
this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
|
||||
_Base::resize(__sz);
|
||||
if (__realloc)
|
||||
this->_M_invalidate_all();
|
||||
_M_update_guaranteed_capacity();
|
||||
}
|
||||
|
||||
void
|
||||
resize(size_type __sz, const _Tp& __c)
|
||||
{
|
||||
bool __realloc = _M_requires_reallocation(__sz);
|
||||
if (__sz < this->size())
|
||||
this->_M_invalidate_if(_After_nth(__sz, _M_base().begin()));
|
||||
_Base::resize(__sz, __c);
|
||||
if (__realloc)
|
||||
this->_M_invalidate_all();
|
||||
_M_update_guaranteed_capacity();
|
||||
}
|
||||
#else
|
||||
void
|
||||
resize(size_type __sz, _Tp __c = _Tp())
|
||||
{
|
||||
@ -237,6 +274,7 @@ namespace __debug
|
||||
this->_M_invalidate_all();
|
||||
_M_update_guaranteed_capacity();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
using _Base::shrink_to_fit;
|
||||
|
@ -60,12 +60,24 @@ namespace __profile
|
||||
typedef typename _Base::const_pointer const_pointer;
|
||||
|
||||
// 23.2.1.1 construct/copy/destroy:
|
||||
explicit deque(const _Allocator& __a = _Allocator())
|
||||
explicit
|
||||
deque(const _Allocator& __a = _Allocator())
|
||||
: _Base(__a) { }
|
||||
|
||||
explicit deque(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
explicit
|
||||
deque(size_type __n)
|
||||
: _Base(__n) { }
|
||||
|
||||
deque(size_type __n, const _Tp& __value,
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a) { }
|
||||
#else
|
||||
explicit
|
||||
deque(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a) { }
|
||||
#endif
|
||||
|
||||
template<class _InputIterator>
|
||||
deque(_InputIterator __first, _InputIterator __last,
|
||||
@ -195,11 +207,25 @@ namespace __profile
|
||||
using _Base::size;
|
||||
using _Base::max_size;
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
void
|
||||
resize(size_type __sz)
|
||||
{
|
||||
_Base::resize(__sz);
|
||||
}
|
||||
|
||||
void
|
||||
resize(size_type __sz, const _Tp& __c)
|
||||
{
|
||||
_Base::resize(__sz, __c);
|
||||
}
|
||||
#else
|
||||
void
|
||||
resize(size_type __sz, _Tp __c = _Tp())
|
||||
{
|
||||
_Base::resize(__sz, __c);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
using _Base::shrink_to_fit;
|
||||
|
@ -64,20 +64,40 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
// 23.2.2.1 construct/copy/destroy:
|
||||
explicit list(const _Allocator& __a = _Allocator())
|
||||
explicit
|
||||
list(const _Allocator& __a = _Allocator())
|
||||
: _Base(__a)
|
||||
{
|
||||
__profcxx_list_construct(this); // list2slist
|
||||
__profcxx_list_construct2(this); // list2vector
|
||||
}
|
||||
|
||||
explicit list(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
explicit
|
||||
list(size_type __n)
|
||||
: _Base(__n)
|
||||
{
|
||||
__profcxx_list_construct(this);
|
||||
__profcxx_list_construct2(this);
|
||||
}
|
||||
|
||||
list(size_type __n, const _Tp& __value,
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a)
|
||||
{
|
||||
__profcxx_list_construct(this);
|
||||
__profcxx_list_construct2(this);
|
||||
}
|
||||
#else
|
||||
explicit
|
||||
list(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a)
|
||||
{
|
||||
__profcxx_list_construct(this);
|
||||
__profcxx_list_construct2(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class _InputIterator>
|
||||
list(_InputIterator __first, _InputIterator __last,
|
||||
@ -229,9 +249,19 @@ template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
||||
using _Base::size;
|
||||
using _Base::max_size;
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
void
|
||||
resize(size_type __sz)
|
||||
{ _Base::resize(__sz); }
|
||||
|
||||
void
|
||||
resize(size_type __sz, const _Tp& __c)
|
||||
{ _Base::resize(__sz, __c); }
|
||||
#else
|
||||
void
|
||||
resize(size_type __sz, _Tp __c = _Tp())
|
||||
{ _Base::resize(__sz, __c); }
|
||||
#endif
|
||||
|
||||
// element access:
|
||||
reference
|
||||
|
@ -76,20 +76,40 @@ namespace __profile
|
||||
_M_base() const { return *this; }
|
||||
|
||||
// 23.2.4.1 construct/copy/destroy:
|
||||
explicit vector(const _Allocator& __a = _Allocator())
|
||||
explicit
|
||||
vector(const _Allocator& __a = _Allocator())
|
||||
: _Base(__a)
|
||||
{
|
||||
__profcxx_vector_construct(this, this->capacity());
|
||||
__profcxx_vector_construct2(this);
|
||||
}
|
||||
|
||||
explicit vector(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
explicit
|
||||
vector(size_type __n)
|
||||
: _Base(__n)
|
||||
{
|
||||
__profcxx_vector_construct(this, this->capacity());
|
||||
__profcxx_vector_construct2(this);
|
||||
}
|
||||
|
||||
vector(size_type __n, const _Tp& __value,
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a)
|
||||
{
|
||||
__profcxx_vector_construct(this, this->capacity());
|
||||
__profcxx_vector_construct2(this);
|
||||
}
|
||||
#else
|
||||
explicit
|
||||
vector(size_type __n, const _Tp& __value = _Tp(),
|
||||
const _Allocator& __a = _Allocator())
|
||||
: _Base(__n, __value, __a)
|
||||
{
|
||||
__profcxx_vector_construct(this, this->capacity());
|
||||
__profcxx_vector_construct2(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class _InputIterator>
|
||||
vector(_InputIterator __first, _InputIterator __last,
|
||||
@ -218,6 +238,23 @@ namespace __profile
|
||||
using _Base::size;
|
||||
using _Base::max_size;
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
void
|
||||
resize(size_type __sz)
|
||||
{
|
||||
__profcxx_vector_invalid_operator(this);
|
||||
_M_profile_resize(this, this->capacity(), __sz);
|
||||
_Base::resize(__sz);
|
||||
}
|
||||
|
||||
void
|
||||
resize(size_type __sz, const _Tp& __c)
|
||||
{
|
||||
__profcxx_vector_invalid_operator(this);
|
||||
_M_profile_resize(this, this->capacity(), __sz);
|
||||
_Base::resize(__sz, __c);
|
||||
}
|
||||
#else
|
||||
void
|
||||
resize(size_type __sz, _Tp __c = _Tp())
|
||||
{
|
||||
@ -225,6 +262,7 @@ namespace __profile
|
||||
_M_profile_resize(this, this->capacity(), __sz);
|
||||
_Base::resize(__sz, __c);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
using _Base::shrink_to_fit;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2005, 2006, 2007, 2009, 2010 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
|
||||
@ -17,16 +17,12 @@
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include <deque>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_rvalref.h>
|
||||
|
||||
using namespace __gnu_test;
|
||||
|
||||
// According to n1771, there should be two resizes, with and without
|
||||
// parameter. We only have one at present, whose second parameter defaults
|
||||
// to a default-constructed object.
|
||||
void
|
||||
test01()
|
||||
{
|
||||
@ -38,30 +34,17 @@ test01()
|
||||
a.resize(98);
|
||||
a.resize(99);
|
||||
a.resize(100);
|
||||
#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
|
||||
VERIFY( copycounter::copycount == 100 );
|
||||
#else
|
||||
VERIFY( copycounter::copycount == 100 + 4 );
|
||||
#endif
|
||||
VERIFY( copycounter::copycount == 0 );
|
||||
|
||||
a.resize(99);
|
||||
a.resize(0);
|
||||
#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
|
||||
VERIFY( copycounter::copycount == 100 );
|
||||
#else
|
||||
VERIFY( copycounter::copycount == 100 + 6 );
|
||||
#endif
|
||||
VERIFY( copycounter::copycount == 0 );
|
||||
|
||||
a.resize(100);
|
||||
#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
|
||||
VERIFY( copycounter::copycount == 200 );
|
||||
#else
|
||||
VERIFY( copycounter::copycount == 200 + 7 );
|
||||
#endif
|
||||
VERIFY( copycounter::copycount == 0 );
|
||||
|
||||
a.clear();
|
||||
#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
|
||||
VERIFY( copycounter::copycount == 200 );
|
||||
#else
|
||||
VERIFY( copycounter::copycount == 200 + 7 );
|
||||
#endif
|
||||
VERIFY( copycounter::copycount == 0 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// Copyright (C) 2010 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/>.
|
||||
|
||||
#include <deque>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::deque<__gnu_test::NonCopyConstructible> d;
|
||||
VERIFY( std::distance(d.begin(), d.end()) == 0 );
|
||||
|
||||
d.resize(1000);
|
||||
VERIFY( std::distance(d.begin(), d.end()) == 1000 );
|
||||
for(auto it = d.begin(); it != d.end(); ++it)
|
||||
VERIFY( *it == -1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
40
libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc
Normal file
40
libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc
Normal file
@ -0,0 +1,40 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// Copyright (C) 2010 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/>.
|
||||
|
||||
#include <deque>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::deque<__gnu_test::NonCopyConstructible> d(1000);
|
||||
VERIFY( std::distance(d.begin(), d.end()) == 1000 );
|
||||
for(auto it = d.begin(); it != d.end(); ++it)
|
||||
VERIFY( *it == -1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1577 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1659 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <deque>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1516 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1592 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <deque>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// 2007-04-27 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2007, 2008, 2009 Free Software Foundation
|
||||
// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation
|
||||
//
|
||||
// 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
|
||||
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1516 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1592 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <deque>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1661 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1743 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <deque>
|
||||
|
@ -21,24 +21,17 @@
|
||||
|
||||
#include <forward_list>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
struct NoCopyConstructor
|
||||
{
|
||||
NoCopyConstructor() : num(-1) { }
|
||||
NoCopyConstructor(const NoCopyConstructor&) = delete;
|
||||
|
||||
operator int() { return num; }
|
||||
|
||||
private:
|
||||
int num;
|
||||
};
|
||||
#include <testsuite_api.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::forward_list<NoCopyConstructor> fl(5);
|
||||
VERIFY( std::distance(fl.begin(), fl.end()) == 5 );
|
||||
std::forward_list<__gnu_test::NonCopyConstructible> fl;
|
||||
VERIFY( std::distance(fl.begin(), fl.end()) == 0 );
|
||||
|
||||
fl.resize(1000);
|
||||
VERIFY( std::distance(fl.begin(), fl.end()) == 1000 );
|
||||
for(auto it = fl.begin(); it != fl.end(); ++it)
|
||||
VERIFY( *it == -1 );
|
||||
}
|
@ -21,27 +21,14 @@
|
||||
|
||||
#include <forward_list>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
struct NoCopyConstructor
|
||||
{
|
||||
NoCopyConstructor() : num(-1) { }
|
||||
NoCopyConstructor(const NoCopyConstructor&) = delete;
|
||||
|
||||
operator int() { return num; }
|
||||
|
||||
private:
|
||||
int num;
|
||||
};
|
||||
#include <testsuite_api.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::forward_list<NoCopyConstructor> fl;
|
||||
VERIFY( std::distance(fl.begin(), fl.end()) == 0 );
|
||||
|
||||
fl.resize(10);
|
||||
VERIFY( std::distance(fl.begin(), fl.end()) == 10 );
|
||||
std::forward_list<__gnu_test::NonCopyConstructible> fl(1000);
|
||||
VERIFY( std::distance(fl.begin(), fl.end()) == 1000 );
|
||||
for(auto it = fl.begin(); it != fl.end(); ++it)
|
||||
VERIFY( *it == -1 );
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1196 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1198 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
// Copyright (C) 2009, 2010 Free Software Foundation
|
||||
|
@ -1,6 +1,6 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1196 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1198 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
// Copyright (C) 2009, 2010 Free Software Foundation
|
||||
|
@ -1,6 +1,6 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1196 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1198 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
// Copyright (C) 2009, 2010 Free Software Foundation
|
||||
|
@ -1,6 +1,6 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1196 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1198 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
// Copyright (C) 2009, 2010 Free Software Foundation
|
||||
|
@ -0,0 +1,43 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// Copyright (C) 2010 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/>.
|
||||
|
||||
#include <list>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::list<__gnu_test::NonCopyConstructible> l;
|
||||
VERIFY( std::distance(l.begin(), l.end()) == 0 );
|
||||
|
||||
l.resize(1000);
|
||||
VERIFY( std::distance(l.begin(), l.end()) == 1000 );
|
||||
for(auto it = l.begin(); it != l.end(); ++it)
|
||||
VERIFY( *it == -1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
40
libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc
Normal file
40
libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc
Normal file
@ -0,0 +1,40 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// Copyright (C) 2010 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/>.
|
||||
|
||||
#include <list>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::list<__gnu_test::NonCopyConstructible> l(1000);
|
||||
VERIFY( std::distance(l.begin(), l.end()) == 1000 );
|
||||
for(auto it = l.begin(); it != l.end(); ++it)
|
||||
VERIFY( *it == -1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1411 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1478 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <list>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1380 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1434 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <list>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1380 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1434 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <list>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1380 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1434 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <list>
|
||||
|
@ -1,6 +1,7 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
|
||||
// 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
|
||||
@ -17,19 +18,12 @@
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_rvalref.h>
|
||||
|
||||
using namespace __gnu_test;
|
||||
|
||||
// According to n1771, there should be two resizes, with and without
|
||||
// parameter. We only have one at present, whose second parameter defaults
|
||||
// to a default-constructed object.
|
||||
// Also, the values are one higher than might be expected because internally
|
||||
// resize calls fill, which copies its input value in case it is already in
|
||||
// the vector when the vector isn't moved.
|
||||
void
|
||||
test01()
|
||||
{
|
||||
@ -41,30 +35,17 @@ test01()
|
||||
a.resize(98);
|
||||
a.resize(99);
|
||||
a.resize(100);
|
||||
#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
|
||||
VERIFY( copycounter::copycount == 100 + 1 );
|
||||
#else
|
||||
VERIFY( copycounter::copycount == 100 + 1 + 4 );
|
||||
#endif
|
||||
VERIFY( copycounter::copycount == 0 );
|
||||
|
||||
a.resize(99);
|
||||
a.resize(0);
|
||||
#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
|
||||
VERIFY( copycounter::copycount == 100 + 1 );
|
||||
#else
|
||||
VERIFY( copycounter::copycount == 100 + 1 + 6 );
|
||||
#endif
|
||||
VERIFY( copycounter::copycount == 0 );
|
||||
|
||||
a.resize(100);
|
||||
#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
|
||||
VERIFY( copycounter::copycount == 200 + 2 );
|
||||
#else
|
||||
VERIFY( copycounter::copycount == 200 + 2 + 7 );
|
||||
#endif
|
||||
VERIFY( copycounter::copycount == 0 );
|
||||
|
||||
a.clear();
|
||||
#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
|
||||
VERIFY( copycounter::copycount == 200 + 2 );
|
||||
#else
|
||||
VERIFY( copycounter::copycount == 200 + 2 + 7 );
|
||||
#endif
|
||||
VERIFY( copycounter::copycount == 0 );
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// Copyright (C) 2010 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/>.
|
||||
|
||||
#include <vector>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::vector<__gnu_test::NonCopyConstructible> v;
|
||||
VERIFY( std::distance(v.begin(), v.end()) == 0 );
|
||||
|
||||
v.resize(1000);
|
||||
VERIFY( std::distance(v.begin(), v.end()) == 1000 );
|
||||
for(auto it = v.begin(); it != v.end(); ++it)
|
||||
VERIFY( *it == -1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
// { dg-options "-std=gnu++0x" }
|
||||
|
||||
// 2010-06-18 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// Copyright (C) 2010 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/>.
|
||||
|
||||
#include <vector>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_api.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::vector<__gnu_test::NonCopyConstructible> v(1000);
|
||||
VERIFY( std::distance(v.begin(), v.end()) == 1000 );
|
||||
for(auto it = v.begin(); it != v.end(); ++it)
|
||||
VERIFY( *it == -1 );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1063 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1148 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <vector>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1003 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1078 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <vector>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1003 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1078 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <vector>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1104 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1189 }
|
||||
// { dg-excess-errors "" }
|
||||
|
||||
#include <vector>
|
||||
|
@ -19,7 +19,6 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
#include <cstddef>
|
||||
#include <exception>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
@ -107,7 +106,7 @@ namespace __gnu_test
|
||||
// For 23 unordered_* requirements.
|
||||
struct NonDefaultConstructible_hash
|
||||
{
|
||||
size_t
|
||||
std::size_t
|
||||
operator()(NonDefaultConstructible) const
|
||||
{ return 1; }
|
||||
};
|
||||
@ -170,10 +169,29 @@ namespace __gnu_test
|
||||
|
||||
struct OverloadedAddress_hash
|
||||
{
|
||||
size_t
|
||||
std::size_t
|
||||
operator()(const OverloadedAddress&) const
|
||||
{ return 1; }
|
||||
};
|
||||
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
struct NonCopyConstructible
|
||||
{
|
||||
NonCopyConstructible() : num(-1) { }
|
||||
|
||||
NonCopyConstructible(NonCopyConstructible&& other)
|
||||
: num(other.num)
|
||||
{ other.num = 0; }
|
||||
|
||||
NonCopyConstructible(const NonCopyConstructible&) = delete;
|
||||
|
||||
operator int() { return num; }
|
||||
|
||||
private:
|
||||
int num;
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user