Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | string‎ | basic string
m (Text replace - "/sidebar" to "/navbar")
m (r2.7.3) (Robot: Adding de, es, fr, it, zh)
Line 38: Line 38:
 
{{dcl list end}}
 
{{dcl list end}}
  
 +
 +
 +
 +
 
[[ja:cpp/string/basic string/resize]]
 
[[ja:cpp/string/basic string/resize]]
 
[[pt:cpp/string/basic string/resize]]
 
[[pt:cpp/string/basic string/resize]]
 
[[ru:cpp/string/basic string/resize]]
 
[[ru:cpp/string/basic string/resize]]
 +

Revision as of 11:03, 2 November 2012

 
 
 
std::basic_string
 

Template:ddcl list begin <tr class="t-dcl ">

<td >
void resize( size_type count );
</td>

<td > (1) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
void resize( size_type count, CharT ch );
</td>

<td > (2) </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

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

Template:cpp/string/basic string/dcl list size