Function popBackExactly

Removes exactly count last elements from the bidirectional range range.

void popBackExactly(R) (
  ref R range,
  size_t count
)
if (isBidirectionalRange!R && (hasLength!R || isInfinite!R));

R must have length or be infinite.

Parameters

NameDescription
R Range type.
range Some bidirectional range.
count Number of elements to remove.

See Also

popFrontExactly, popBackN, isBidirectionalRange, hasLength, isInfinite.

Precondition

If R has length, it must be less than or equal to count.

Example

int[5] a = [1, 2, 3, 4, 5];
auto slice = a[];

popBackExactly(slice, 3);
assert(slice.length == 2);
assert(slice[0] == 1);
assert(slice[$ - 1] == 2);

popBackExactly(slice, 2);
assert(slice.length == 0);