writing iterators without code duplication. inout?
pompei2
pompei2 at gmail.com
Wed Dec 21 08:34:18 PST 2011
On Wednesday, 21 December 2011 at 16:05:24 UTC, Trass3r wrote:
> Can't really answer your original question, but
> 1. Why don't you use opApply?
> 2. Why do you use ref int even in the const version?
> 3. You could also use alias this to allow iteration, don't know
> if that's what you want in general though.
1&3: Because there are different things in my class to iterate
over. Think foreach(p ; obj.properties()) and foreach(c ;
obj.components()). (I know, I can make those @property so I don't
need the ().)
2. Because if not, it says: Error: cannot implicitly convert
expression (__foreachbody1315) of type int delegate(ref int) to
int delegate(int)
More information about the Digitalmars-d-learn
mailing list