Vector.upsize

Upsize the vector to a length of n elements.

If n is smaller than the current vector length, then nothing happend.

If n is greater than the current vector length, the current content is extended by inserting at the end as many elements as needed to reach a size of n.

If args are specified, the new elements are emplaced with parameters args, otherwise, they are ElementType.init.

struct Vector
scope @safe
void
upsize
(
Args...
)
(
const size_t n
,
auto ref Args args
)

Examples

Vector!(int, 6) vec = Vector!(int, 6).build(1, 2, 3);

vec.upsize(5, 0);
assert(vec == [1, 2, 3, 0, 0]);

vec.upsize(2);
assert(vec == [1, 2, 3, 0, 0]);

Meta