std::inplace_vector<T,N>::resize

Resizes the container to contain count elements, does nothing if count == size().

# Declarations

constexpr void resize( size_type count );

(since C++26)

constexpr void resize( size_type count, const value_type& value );

(since C++26)

# Parameters

# Example

#include <inplace_vector>
#include <print>
 
int main()
{
    std::inplace_vector<int, 6> v(6, 9);
    std::println("Initially, v = {}", v);
 
    v.resize(2);
    std::println("After resize(2), v = {}", v);
 
    v.resize(4);
    std::println("After resize(4), v = {}", v);
 
    v.resize(6, -1);
    std::println("After resize(6, -1), v = {}", v);
 
    try
    {
        std::print("Trying resize(13): ");
        v.resize(13); // throws, because count > N; v is left unchanged
    }
    catch(const std::bad_alloc& ex)
    {
        std::println("ex.what(): {}", ex.what());
    }
    std::println("After exception, v = {}", v);
}

# See also