Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/string/basic string/resize"

From cppreference.com
< cpp‎ | string‎ | basic string
m (Shorten template names. Use {{lc}} where appropriate.)
m (Update links.)
Line 35: Line 35:
  
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc inc | cpp/string/basic_string/dcl list size}}
+
{{dsc inc | cpp/string/basic_string/size}}
 
{{dsc end}}
 
{{dsc end}}
  

Revision as of 23:24, 31 May 2013

 
 
 
std::basic_string
 
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.

Contents

Parameters

count - new size of the string
ch - character to initialize the new characters with

Return value

(none)

Complexity

linear in the size of the string

See also

returns the number of characters
(public member function) [edit]