iterators again

David B. Held dheld at codelogicconsulting.com
Sun May 27 17:24:49 PDT 2007


Bill Baxter wrote:
> What's the deal with making iterators be classes in D, rather than 
> simple value types like they are in C++?  I see that tango uses classes, 
> and DTL used them too.  Chris commented over on the Tango forum that 
> "there are problems with using structs".  So what are they?
> 
> The way people describe iterators in C++ is as a generalization of a 
> pointer.  Including the fact that they are value types and can be 
> copied.  DTL and tango iterators can't even be copied at all.  Just 
> seems like a struct makes more sense for an iterator in D.

Iterators should almost certainly be value types (structs).  The 
problems are that structs currently don't have c'tors/d'tors nor do they 
have a fully useful copy c'tor.  However, both are planned for inclusion.

Dave



More information about the Digitalmars-d mailing list