Another cool mini-project: advance a range within n steps from its end
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Fri Dec 4 08:37:36 PST 2015
Like "tail" in Unix. Given a range R r and a number size_t n, return a
TakeExactly!R that's r at no more than n steps from its end:
TakeExactly!R advanceWithin(R)(R r, size_t n)
if (isForwardRange!R);
Invariant:
assert(r.advanceWithin(n).length <= n);
Implementation would send a scout range ahead, etc.
I didn't file an issue for it, but it's a great function to have.
Takers?
Andrei
More information about the Digitalmars-d
mailing list