re PR libstdc++/42573 ([C++0x] shrink_to_fit() missing)

2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/42573
	* include/bits/allocator.h (struct __shrink_to_fit): Add.
	* include/bits/stl_deque.h (deque<>::shrink_to_fit): Add.
	* include/bits/stl_vector.h (vector<>::shrink_to_fit): Likewise.
	* include/bits/stl_bvector.h (vector<bool>::shrink_to_fit): Likewise.
	* include/bits/basic_string.h (basic_string<>::shrink_to_fit):
	Likewise.
	* include/ext/vstring.h (__versa_string<>::shrink_to_fit): Likewise.
	* include/debug/deque: Add corresponding using declaration.
	* include/debug/vector: Likewise.
	* include/debug/string: Likewise.
	* include/profile/deque: Likewise.
	* include/profile/vector: Likewise.
	* config/abi/pre/gnu.ver: Export new symbols.
	* testsuite/23_containers/deque/capacity/shrink_to_fit.cc: New.
	* testsuite/23_containers/vector/capacity/shrink_to_fit.cc: Likewise.
	* testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc:
	Likewise.
	* testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc:
	Likewise.
	* testsuite/ext/vstring/capacity/shrink_to_fit.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* 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/vector/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* 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.

From-SVN: r155733
This commit is contained in:
Paolo Carlini 2010-01-08 13:01:24 +00:00 committed by Paolo Carlini
parent 1eee5628bd
commit 79667f82ad
26 changed files with 372 additions and 28 deletions

View File

@ -1,3 +1,43 @@
2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42573
* include/bits/allocator.h (struct __shrink_to_fit): Add.
* include/bits/stl_deque.h (deque<>::shrink_to_fit): Add.
* include/bits/stl_vector.h (vector<>::shrink_to_fit): Likewise.
* include/bits/stl_bvector.h (vector<bool>::shrink_to_fit): Likewise.
* include/bits/basic_string.h (basic_string<>::shrink_to_fit):
Likewise.
* include/ext/vstring.h (__versa_string<>::shrink_to_fit): Likewise.
* include/debug/deque: Add corresponding using declaration.
* include/debug/vector: Likewise.
* include/debug/string: Likewise.
* include/profile/deque: Likewise.
* include/profile/vector: Likewise.
* config/abi/pre/gnu.ver: Export new symbols.
* testsuite/23_containers/deque/capacity/shrink_to_fit.cc: New.
* testsuite/23_containers/vector/capacity/shrink_to_fit.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc:
Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc:
Likewise.
* testsuite/ext/vstring/capacity/shrink_to_fit.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* 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/vector/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* 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.
2010-01-07 Benjamin Kosnik <bkoz@redhat.com>
* doc/xml/manual/evolution.xml: Fix typos, update.

View File

@ -1094,6 +1094,10 @@ GLIBCXX_3.4.14 {
_ZNSs18_S_construct_aux_2*;
_ZNSbIwSt11char_traitsIwESaIwEE18_S_construct_aux_2*;
# string|wstring shrink_to_fit member function
_ZNSs13shrink_to_fitEv;
_ZNSbIwSt11char_traitsIwESaIwEE13shrink_to_fitEv;
_ZSt25__throw_bad_function_callv;
# std::time_get::_M_extract_wday_or_month

View File

@ -1,6 +1,6 @@
// Allocators -*- 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
@ -176,6 +176,31 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return __one != __two; }
};
#ifdef __GXX_EXPERIMENTAL_CXX0X__
// A very basic implementation for now. In general we have to wait for
// the availability of the infrastructure described in N2983: we should
// try when either T has a move constructor which cannot throw or T is
// CopyContructible.
// NB: This code doesn't properly belong here, we should find a more
// suited place common to std::vector and std::deque.
template<typename _Tp,
bool = __has_trivial_copy(typename _Tp::value_type)>
struct __shrink_to_fit
{ static void _S_do_it(_Tp&) { } };
template<typename _Tp>
struct __shrink_to_fit<_Tp, true>
{
static void
_S_do_it(_Tp& __v)
{
try
{ _Tp(__v).swap(__v); }
catch(...) { }
}
};
#endif
_GLIBCXX_END_NAMESPACE
#endif

View File

@ -670,7 +670,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
length() const
{ return _M_rep()->_M_length; }
/// Returns the size() of the largest possible %string.
/// Returns the size() of the largest possible %string.
size_type
max_size() const
{ return _Rep::_S_max_size; }
@ -702,6 +702,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
resize(size_type __n)
{ this->resize(__n, _CharT()); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/// A non-binding request to reduce capacity() to size().
void
shrink_to_fit()
{
try
{ reserve(0); }
catch(...)
{ }
}
#endif
/**
* Returns the total number of characters that the %string can hold
* before needing to allocate more memory.

View File

@ -1,6 +1,6 @@
// vector<bool> specialization -*- 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
@ -600,7 +600,7 @@ template<typename _Alloc>
assign(initializer_list<bool> __l)
{ this->assign(__l.begin(), __l.end()); }
#endif
iterator
begin()
{ return this->_M_impl._M_start; }
@ -824,6 +824,12 @@ template<typename _Alloc>
insert(end(), __new_size - size(), __x);
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void
shrink_to_fit()
{ std::__shrink_to_fit<vector>::_S_do_it(*this); }
#endif
void
flip()
{

View File

@ -1,6 +1,6 @@
// Deque implementation -*- 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
@ -1105,6 +1105,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
insert(this->_M_impl._M_finish, __new_size - __len, __x);
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/** A non-binding request to reduce memory use. */
void
shrink_to_fit()
{ std::__shrink_to_fit<deque>::_S_do_it(*this); }
#endif
/**
* Returns true if the %deque is empty. (Thus begin() would
* equal end().)

View File

@ -1,6 +1,6 @@
// Vector implementation -*- 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
@ -557,6 +557,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
insert(end(), __new_size - size(), __x);
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/** A non-binding request to reduce capacity() to size(). */
void
shrink_to_fit()
{ std::__shrink_to_fit<vector>::_S_do_it(*this); }
#endif
/**
* Returns the total number of elements that the %vector can
* hold before needing to allocate more memory.

View File

@ -1,6 +1,6 @@
// Debugging deque implementation -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
// Copyright (C) 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
@ -223,6 +223,10 @@ namespace __debug
this->_M_invalidate_all();
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
using _Base::shrink_to_fit;
#endif
using _Base::empty;
// element access:

View File

@ -1,6 +1,6 @@
// Debugging string implementation -*- C++ -*-
// Copyright (C) 2003, 2005, 2006, 2009
// Copyright (C) 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
@ -203,6 +203,10 @@ namespace __gnu_debug
resize(size_type __n)
{ this->resize(__n, _CharT()); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
using _Base::shrink_to_fit;
#endif
using _Base::capacity;
using _Base::reserve;

View File

@ -1,6 +1,6 @@
// Debugging vector implementation -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
// Copyright (C) 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
@ -236,6 +236,10 @@ namespace __debug
this->_M_invalidate_all();
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
using _Base::shrink_to_fit;
#endif
size_type
capacity() const
{

View File

@ -1,6 +1,7 @@
// Versatile string -*- C++ -*-
// 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
@ -49,7 +50,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
class __versa_string
: private _Base<_CharT, _Traits, _Alloc>
{
typedef _Base<_CharT, _Traits, _Alloc> __vstring_base;
typedef _Base<_CharT, _Traits, _Alloc> __vstring_base;
typedef typename __vstring_base::_CharT_alloc_type _CharT_alloc_type;
// Types:
@ -455,6 +456,18 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
resize(size_type __n)
{ this->resize(__n, _CharT()); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/// A non-binding request to reduce capacity() to size().
void
shrink_to_fit()
{
try
{ this->reserve(0); }
catch(...)
{ }
}
#endif
/**
* Returns the total number of characters that the %string can
* hold before needing to allocate more memory.

View File

@ -1,6 +1,6 @@
// Profiling deque implementation -*- C++ -*-
// Copyright (C) 2009 Free Software Foundation, Inc.
// Copyright (C) 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
@ -200,6 +200,10 @@ namespace __profile
_Base::resize(__sz, __c);
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
using _Base::shrink_to_fit;
#endif
using _Base::empty;
// element access:

View File

@ -1,6 +1,6 @@
// Profiling vector implementation -*- C++ -*-
// Copyright (C) 2009 Free Software Foundation, Inc.
// Copyright (C) 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
@ -169,6 +169,10 @@ namespace __profile
_Base::resize(__sz, __c);
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
using _Base::shrink_to_fit;
#endif
using _Base::empty;
// element access:

View File

@ -0,0 +1,42 @@
// { dg-options "-std=gnu++0x" }
// 2010-01-08 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 Pred 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 <string>
#include <testsuite_hooks.h>
// libstdc++/42573
void test01()
{
bool test __attribute__((unused)) = true;
std::string s(100, 'a');
s.push_back('b');
s.push_back('b');
VERIFY( s.size() < s.capacity() );
s.shrink_to_fit();
VERIFY( s.size() == s.capacity() );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,42 @@
// { dg-options "-std=gnu++0x" }
// 2010-01-08 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 Pred 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 <string>
#include <testsuite_hooks.h>
// libstdc++/42573
void test01()
{
bool test __attribute__((unused)) = true;
std::wstring s(100, L'a');
s.push_back(L'b');
s.push_back(L'b');
VERIFY( s.size() < s.capacity() );
s.shrink_to_fit();
VERIFY( s.size() == s.capacity() );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,42 @@
// { dg-options "-std=gnu++0x" }
// 2010-01-08 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 Pred 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>
// libstdc++/42573
void test01()
{
bool test __attribute__((unused)) = true;
std::vector<int> d(100);
d.push_back(1);
d.push_back(1);
// VERIFY( d.size() < d.capacity() );
d.shrink_to_fit();
// VERIFY( d.size() == d.capacity() );
}
int main()
{
test01();
return 0;
}

View File

@ -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 *-*-* } 1568 }
// { dg-error "no matching" "" { target *-*-* } 1575 }
// { dg-excess-errors "" }
#include <deque>

View File

@ -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 *-*-* } 1507 }
// { dg-error "no matching" "" { target *-*-* } 1514 }
// { dg-excess-errors "" }
#include <deque>

View File

@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1507 }
// { dg-error "no matching" "" { target *-*-* } 1514 }
// { dg-excess-errors "" }
#include <deque>

View File

@ -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 *-*-* } 1652 }
// { dg-error "no matching" "" { target *-*-* } 1659 }
// { dg-excess-errors "" }
#include <deque>

View File

@ -0,0 +1,42 @@
// { dg-options "-std=gnu++0x" }
// 2010-01-08 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 Pred 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>
// libstdc++/42573
void test01()
{
bool test __attribute__((unused)) = true;
std::vector<int> v(100);
v.push_back(1);
v.push_back(1);
VERIFY( v.size() < v.capacity() );
v.shrink_to_fit();
VERIFY( v.size() == v.capacity() );
}
int main()
{
test01();
return 0;
}

View File

@ -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 *-*-* } 1047 }
// { dg-error "no matching" "" { target *-*-* } 1054 }
// { dg-excess-errors "" }
#include <vector>

View File

@ -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 *-*-* } 987 }
// { dg-error "no matching" "" { target *-*-* } 994 }
// { dg-excess-errors "" }
#include <vector>

View File

@ -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 *-*-* } 987 }
// { dg-error "no matching" "" { target *-*-* } 994 }
// { dg-excess-errors "" }
#include <vector>

View File

@ -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 *-*-* } 1088 }
// { dg-error "no matching" "" { target *-*-* } 1095 }
// { dg-excess-errors "" }
#include <vector>

View File

@ -0,0 +1,42 @@
// { dg-options "-std=gnu++0x" }
// 2010-01-08 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 Pred 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 <ext/vstring.h>
#include <testsuite_hooks.h>
// libstdc++/42573
void test01()
{
bool test __attribute__((unused)) = true;
__gnu_cxx::__vstring vs(100, 'a');
vs.push_back('b');
vs.push_back('b');
VERIFY( vs.size() < vs.capacity() );
vs.shrink_to_fit();
VERIFY( vs.size() == vs.capacity() );
}
int main()
{
test01();
return 0;
}