array::resize

## `array::resize`

Change the number of elements stored.

### Synopsis

    void
    resize(
        std::size_t count); (1)

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

### Description

Resizes the container to contain `count` elements.

- If `size() > count`, the container is reduced to its first `count` elements.

- If `size() < count`, additional null values ((1)) or copies of `jv` ((2)) are appended.

If `capacity() < count`, a reallocation occurs first, and all iterators and references are invalidated. Any past-the-end iterators are always invalidated.

### Complexity

Linear in `size() + count`.

### Exception Safety

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

### Parameters

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

Edit this page