std::basic_string<CharT,Traits,Allocator>::resize (3) - Linux Manuals
std::basic_string<CharT,Traits,Allocator>::resize: std::basic_string<CharT,Traits,Allocator>::resize
NAME
std::basic_string<CharT,Traits,Allocator>::resize - std::basic_string<CharT,Traits,Allocator>::resize
Synopsis
void resize( size_type count ); (1)
void resize( size_type count, CharT ch ); (2)
Resizes the string to contain count characters.
If the current size is less than count, additional characters are appended.
If the current size is greater than count, the string is reduced to its first count elements.
The first version initializes new characters to CharT(), the second version initializes new characters to ch.
Parameters
count - new size of the string
ch - character to initialize the new characters with
Return value
(none)
Exceptions
std::length_error if count > max_size(). Any exceptions thrown by corresponding Allocator.
If an exception is thrown for any reason, this function has no effect (strong exception guarantee).
(since C++11)
Example
// Run this code