Vector.opIndex - multiple declarations
Function Vector.opIndex
Return slice of all elements (same as Vector
).
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[];
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!
Function Vector.opIndex
Returns reference to element at specified location pos
.
Examples
auto vec = Vector!(int, 10) .build(1, 2, 3);
assert(vec[1] == 2);