Yet another const problem...

Chris Cain clcain at uncg.edu
Sun May 20 22:09:33 PDT 2012


On Monday, 21 May 2012 at 03:53:08 UTC, Mehrdad wrote:
> Hmmm... so if you have some (complicated) random-access range, 
> and then you want to overload opApply() (perhaps to let the 
> user use multiple loop variables), how are you supposed to do 
> this without duplicating your code?

A random access range has opIndex and a length. Just use a normal 
for loop in your opApply.

...

for(size_t i = 0; i < this.length; ++i)
     dg(i, this[i]);

...


More information about the Digitalmars-d mailing list