Vector.reserve

Requests that the vector capacity be adapted to a planned change in size to a length of up to n elements.

If n is greater than the current vector capacity, the function causes the container to increase its capacity to n elements (or greater).

In all other cases, it do nothing.

This function has no effect on the vector length and cannot alter its content.

struct Vector
scope nothrow
void
reserve
()
(
const size_t n
)

Examples

Vector!(int, 6) vec = Vector!(int, 6).build(1, 2, 3);
assert(vec.capacity == typeof(vec).minimalCapacity);

const size_t cap = (vec.capacity * 2);
vec.reserve(cap);
assert(vec.capacity > typeof(vec).minimalCapacity);
assert(vec.capacity >= cap);

Meta