Index: include/string =================================================================== --- include/string +++ include/string @@ -956,8 +956,10 @@ void resize(size_type __n, value_type __c); _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} - void reserve(size_type __res_arg = 0); + void reserve(size_type __res_arg); _LIBCPP_INLINE_VISIBILITY + void reserve() _NOEXCEPT {reserve(0);} + _LIBCPP_INLINE_VISIBILITY void shrink_to_fit() _NOEXCEPT {reserve();} _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT; Index: test/std/strings/basic.string/string.capacity/reserve.pass.cpp =================================================================== --- test/std/strings/basic.string/string.capacity/reserve.pass.cpp +++ test/std/strings/basic.string/string.capacity/reserve.pass.cpp @@ -9,7 +9,9 @@ // -// void reserve(size_type res_arg=0); +// Split into two calls for C++20 +// void reserve(); +// void reserve(size_type res_arg); #include #include @@ -44,6 +46,9 @@ assert(s == s0); assert(s.capacity() >= res_arg); assert(s.capacity() >= s.size()); +#if TEST_STD_VER > 17 + assert(s.capacity() >= old_cap); // resize never shrinks as of P0966 +#endif } #ifndef TEST_HAS_NO_EXCEPTIONS else @@ -90,6 +95,7 @@ test(s, 10); test(s, 50); test(s, 100); + test(s, 1000); test(s, S::npos); } } @@ -121,6 +127,7 @@ test(s, 10); test(s, 50); test(s, 100); + test(s, 1000); test(s, S::npos); } }