Function Vector.elements

Return slice of all elements (same as opSlice()).

inout inout(Vector.ElementType)[] elements() pure nothrow @nogc @property @system;

The slice returned may be invalidated by further calls to other member functions that modify the object.

Examples

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

int[] slice = vec.elements;
assert(slice.length == vec.length);
assert(slice.ptr is vec.ptr);

vec.reserve(vec.capacity * 2);
assert(slice.length == vec.length);
// slice contains dangling pointer!