xte::array<T>::resize()

Defined in header <xte/data/array.hpp>


Definitions

#0
[[nodiscard]] constexpr void resize(xte::uz size) & noexcept(false) requires(/* See below */);
Default-constructs elements at the end while .size() is less than size. Destroys elements at the end while .size() is greater than size. Requires that T is default-constructible.

#1
[[nodiscard]] constexpr void resize(xte::uz size, const T& fill) & noexcept(false) requires(/* See below */);
Same as #0 but copy-constructs elements at the end from fill. Requires that T is copy-constructible.



Example

xte::array array = { 1, 2, 3 };
array.resize(5);
std::println("{}", array);
array.resize(2);
std::println("{}", array);
Output:
[1, 2, 3, 0, 0]
[1, 2]
[View in Compiler Explorer]