On Monday, 8 June 2015 at 00:42:12 UTC, Mike Parker wrote:
When implementing a custom range, is it correct to say that consecutive calls to r.front with no intervening calls to popFront should return the same value?

Yes. For examle:

import std.stdio, std.range;

template foo(T) {
    auto foo(R)(R range) {
        while (!range.empty) {
            writeln(range.front);
            // .front --> the first element of the range
            range.popFront;
// .popFront --> to extract the first element of the range
        }
    }
}

void main() {
    foo!(int[])([1, 2, 3]);
}

Reply via email to