Iterators for D

Walter Bright newshound at digitalmars.com
Mon Nov 6 15:21:45 PST 2006


Mike Capp wrote:
>> Overload opIndex for rvalue access
>> [...]
>> Overloading opIndex also will work for random access
> 
> Wouldn't this make iterators incompatible with e.g. linked lists? Seems to defeat
> much of the purpose.

To work, all it has to do is support [0], and throw an exception if the 
index is anything but 0.

> (It might be possible to implement random access for a list, but it's not
> something you'd want to encourage.)

I agree.



More information about the Digitalmars-d mailing list