The rfind challenge
FG
home at fgda.pl
Tue Jan 15 14:16:15 PST 2013
On 2013-01-15 21:59, Andrei Alexandrescu wrote:
> The generic implementation of before is trivial:
>
> auto before(R)(R theBuck, R stopsHere) {
> static struct Result {
> bool empty() { return r1 is r2; }
> auto ref front() { return r1.front; }
> void popFront() { r1.popFront; }
> private R r1, r2;
> }
> return Result(theBuck, stopsHere);
> }
I'm scared and would feel safer with:
bool empty() { return r1 is r2 || r1.empty(); }
>
> For random-access ranges:
>
> auto before(R)(R theBuck, R stopsHere) {
> return theBuck[0 .. theBuck.length - stopsHere.length];
> }
This implies that theBuck._end == stopsHere._end, but why?
More information about the Digitalmars-d
mailing list