writing iterators without code duplication. inout?

Steven Schveighoffer schveiguy at yahoo.com
Sat Jan 7 08:45:12 PST 2012

On Wed, 21 Dec 2011 11:34:18 -0500, pompei2 <pompei2 at gmail.com> wrote:

> 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)

Two of my most wished for bugs:


Looks like 2443 has been fixed in head!


More information about the Digitalmars-d-learn mailing list