Namespaces
Variants
Views
Actions

std::vector::reserve

From cppreference.com
< cpp | container | vector
Revision as of 17:19, 2 November 2012 by P12bot (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
void reserve( size_type size );

Sets the capacity of the container to at least size. New storage is allocated if necessary.

If size is greater than capacity(), all iterators and references, including the past-the-end iterator, are invalidated. Otherwise, no iterators or references are invalidated.

Contents

[edit] Parameters

size - new capacity of the container

[edit] Return value

(none)

[edit] Exceptions

std::length_error if size > max_size().

[edit] Complexity

Linear in the size of the container

[edit] See also

returns the number of elements that can be held in currently allocated storage
(public member function) [edit]