std::basic_string<CharT,Traits,Allocator>::reserve
From cppreference.com
< cpp | string | basic string
(1) | ||
void reserve( size_type new_cap = 0 ); |
(until C++20) | |
constexpr void reserve( size_type new_cap ); |
(since C++20) | |
void reserve(); |
(2) | (since C++20) (deprecated in C++20) (removed in C++26) |
1) Informs a
std::basic_string
object of a planned change in size, so that it can manage the storage allocation appropriately.
- If new_cap is greater than the current capacity(), new storage is allocated, and capacity() is made equal or greater than new_cap.
|
(until C++20) |
|
(since C++20) |
If a capacity change takes place, all iterators and references, including the past-the-end iterator, are invalidated.
2) A non-binding shrink-to-fit request. After this call, capacity() has an unspecified value greater than or equal to size().
Contents |
[edit] Parameters
new_cap | - | new capacity of the string |