basic_string.tcc (reserve): Allow shrink-to-fit.

2003-12-11  Neil Ferguson  <nferguso@eso.org>
	    Paolo Carlini  <pcarlini@suse.de>

	* include/bits/basic_string.tcc (reserve): Allow shrink-to-fit.
	* testsuite/21_strings/basic_string/capacity/1.cc: Tweak.
	* testsuite/21_strings/basic_string/capacity/char/1.cc: Ditto.
	* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Ditto.

Co-Authored-By: Paolo Carlini <pcarlini@suse.de>

From-SVN: r74551
This commit is contained in:
Neil Ferguson 2003-12-11 22:29:12 +00:00 committed by Paolo Carlini
parent fe16ab7e3e
commit cbc6795585
5 changed files with 12 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2003-12-11 Neil Ferguson <nferguso@eso.org>
Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (reserve): Allow shrink-to-fit.
* testsuite/21_strings/basic_string/capacity/1.cc: Tweak.
* testsuite/21_strings/basic_string/capacity/char/1.cc: Ditto.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Ditto.
2003-12-10 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/6243

View File

@ -474,7 +474,7 @@ namespace std
void
basic_string<_CharT, _Traits, _Alloc>::reserve(size_type __res)
{
if (__res > this->capacity() || _M_rep()->_M_is_shared())
if (__res != this->capacity() || _M_rep()->_M_is_shared())
{
if (__res > this->max_size())
__throw_length_error("basic_string::reserve");

View File

@ -140,7 +140,7 @@ void test01()
VERIFY( sz04 >= 100 );
str02.reserve();
sz03 = str02.capacity();
VERIFY( sz03 > 0 );
VERIFY( sz03 >= 0 );
sz03 = str02.size() + 5;
str02.resize(sz03);

View File

@ -37,7 +37,7 @@ void test01()
VERIFY( sz02 >= 100 );
str01.reserve();
sz01 = str01.capacity();
VERIFY( sz01 > 0 );
VERIFY( sz01 >= 0 );
sz01 = str01.size() + 5;
str01.resize(sz01);

View File

@ -37,7 +37,7 @@ void test01()
VERIFY( sz02 >= 100 );
str01.reserve();
sz01 = str01.capacity();
VERIFY( sz01 > 0 );
VERIFY( sz01 >= 0 );
sz01 = str01.size() + 5;
str01.resize(sz01);