[PATCH] D56997: Fix implementation of P0966 - string::reserve Should Not Shrink
Jonathan Wakely via Phabricator
reviews at reviews.llvm.org
Wed Jan 23 07:02:58 PST 2019
jwakely added inline comments.
================
Comment at: include/string:3144
+ size_type __cap = capacity();
+ if (__res_arg <= __cap)
+ return;
----------------
EricWF wrote:
> After some more thinking, I think it's best we leave the old behavior as-is. All of the existing standard libraries seem to honor the shrink request prior to C++20, and that provides mostly consistent behavior to users. For consistency alone I think it's probably better not to backport this extension.
For libstdc++ I think we have no real choice but to change it for all dialects. Our `std::string::reserve(size_type)` is exported from the shared library, so users will always get whatever behaviour the library exports, irrespective of their `-std` options. So we'll be changing `reserve(size_type)` to never shrink, unconditionally. So the consistency argument is lost.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56997/new/
https://reviews.llvm.org/D56997
More information about the libcxx-commits
mailing list