"the last change" for ranges
Jason House
jason.james.house at gmail.com
Wed May 20 17:14:50 PDT 2009
Andrei Alexandrescu Wrote:
> 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
You didn't declare FileByCharacter as either a struct or a class? Did I plant a seed? :)
More information about the Digitalmars-d
mailing list