libstdc++: Implement P0966 std::string::reserve should not shrink
authorAndrew Luo <andrewluotechnologies@outlook.com>
Thu, 6 Aug 2020 18:35:43 +0000 (19:35 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 6 Aug 2020 18:49:07 +0000 (19:49 +0100)
commit140cf935cd118f7208b7c3826a8b9d50936242f0
tree65f67d2de44231a18d83ebdb1fffa3eff6602d86
parent4e39f563c0cd25401f689c2093cb8c13692156ef
libstdc++: Implement P0966 std::string::reserve should not shrink

Remove ability for reserve(n) to reduce a string's capacity. Add a new
reserve() overload that makes a shrink-to-fit request, and make
shrink_to_fit() use that.

libstdc++-v3/ChangeLog:

2020-07-30  Andrew Luo  <andrewluotechnologies@outlook.com>
    Jonathan Wakely  <jwakely@redhat.com>

* config/abi/pre/gnu.ver (GLIBCXX_3.4): Use less greedy
patterns for basic_string members.
(GLIBCXX_3.4.29): Export new basic_string::reserve symbols.
* doc/xml/manual/status_cxx2020.xml: Update P0966 status.
* include/bits/basic_string.h (shrink_to_fit()): Call reserve().
(reserve(size_type)): Remove default argument.
(reserve()): Declare new overload.
[!_GLIBCXX_USE_CXX11_ABI] (shrink_to_fit, reserve): Likewise.
* include/bits/basic_string.tcc (reserve(size_type)): Remove
support for shrinking capacity.
(reserve()): Perform shrink-to-fit operation.
[!_GLIBCXX_USE_CXX11_ABI] (reserve): Likewise.
* testsuite/21_strings/basic_string/capacity/1.cc: Adjust to
reflect new behavior.
* testsuite/21_strings/basic_string/capacity/char/1.cc:
Likewise.
* testsuite/21_strings/basic_string/capacity/char/18654.cc:
Likewise.
* testsuite/21_strings/basic_string/capacity/char/2.cc:
Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc:
Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/2.cc:
Likewise.
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/doc/xml/manual/status_cxx2020.xml
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/basic_string.tcc
libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc
libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc
libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/18654.cc
libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/2.cc
libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc
libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc
libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/2.cc