popFrontExactly

fnvoid popFrontExactly(Range)(ref Range r, size_t n) if (isInputRange!Range)

Eagerly advances r itself (not a copy) exactly n times (by calling r.popFront). popFrontExactly takes r by ref, so it mutates the original range. Completes in 1 steps for ranges that support slicing, and have either length or are infinite. Completes in n time for all other ranges.

Note

Unlike popFrontN, popFrontExactly will assume that the

range holds at least n elements. This makes popFrontExactly faster than popFrontN, but it also means that if range does not contain at least n elements, it will attempt to call popFront on an empty range, which is undefined behavior. So, only use popFrontExactly when it is guaranteed that range holds at least n elements.

popBackExactly will behave the same but instead removes elements from the back of the (bidirectional) range instead of the front.

See Also