opStar

Janice Caron caron800 at googlemail.com
Sun Nov 11 03:02:07 PST 2007


On 11/11/07, Bruce Adams <tortoise_74 at yeah.who.co.uk> wrote:
> Walter Bright Wrote:
> > For iterators. Should a class be used as an iterator? I can't see how
> > that would make sense anyway.
>
> Are we to infer from that that iterators (and possibly smart pointers) might be a new kind of first class entity or did you just mean structs.

I think you're reading too much into that. Walter only said that
classes as iterators doesn't make much sense. And he's right.
Consider.

    Iterator p = collection.begin();
    Iterator q = p;
    ++p;

You wouldn't expect q to be incremented in the above code! Therefore,
iterators must be passed by value. Therefore, they should be structs.

But that doesn't change any of the reasoning about dereferencing and
the dot operator.



More information about the Digitalmars-d mailing list