reserve [C++ Reference]
Keywords: string,reserve
Date: 2010-03-11T02:35:47-0800

[[reserve]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## reserve

Syntax:

        #include <string>
        void reserve( size_type size = 0 );

The reserve() function sets the capacity of the string to at least size. If the argument `size` is less than the current number of characters (i.e. `size < this→size()`), it is a nonbinding shrink-to-fit request. reserve() runs in linear time.

Related Topics: capacity, resize

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •