| Home | Libraries | People | FAQ | More

###### array::resize (2 of 2 overloads)

Change the number of elements stored.

###### Synopsis

    void
    resize(
        std::size_t count,
        value const& v);

###### Description

Resizes the container to contain `count` elements. If `capacity() < size() + count`, a reallocation occurs first, and all iterators and references are invalidated. Any past-the-end iterators are always invalidated.

- If `size() > count`, the container is reduced to its first `count` elements.
- If `size() < count`, additional copies of `v` are appended.

###### Complexity

Linear in `abs(size() - count)`, plus the cost of reallocation if `capacity()` is less than `count`.

###### Exception Safety

Strong guarantee. Calls to `memory_resource::allocate` may throw.

###### Parameters

Name | Description
--- | ---
`count` | The new size of the container.
`v` | The `value` to copy into the new elements.