"the last change" for ranges

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed May 20 16:17:15 PDT 2009


MLT wrote:
> I think that if
>> R last = r;
> then after
>> r.popFront;
> the order of elements in "last" should not change, no matter what
> type of range you are dealing with. (That means that input operations
> would be buffered to the leftmost range that still extsts.)
> 
> If I understood the logic of ranges, popFront() just changes the
> range, and not the elements it points to.

That's the case for all ranges except input ranges. Consider:

FileByCharacter
{
     private FILE* _f;
     private dchar _last;
     bool empty() { return _last == 0xffff; }
     void popFront() { _last = fgetc(_f); }
     dchar front() { return _last; }
}

Consider what happens when you copy this range around.


Andrei



More information about the Digitalmars-d mailing list