Create a foreach-able struct? Multi-dimensional even?

Heywood Floyd soul8o8 at gmail.com
Thu Aug 25 03:02:44 PDT 2011


Heywood Floyd Wrote:

> 
> Hello!
> 
> 1) How do I create a struct that I can foreach over?
> 
> I get the impression opApply has something do to with this, but I can't find any documentation on it? (And I'm abroad without my TDPL.)
> 
> 
> 2) Also, is it possible to do something like this? 
> 
>   MyData!(100,100,100) data;
>   foreach(x, y, z, ref cell; data){
>      cell = x*y*z;
>   }
> 
> (The idea here is cells are stored in a plain 1-dimensional array behind the scenes, but iterated as a 3-dimensional array.)
> 
> 
> Kind regards
> /HF


Ah, I'm sorry, I found the documentation regarding opApply() now. Typical. (The site-search didn't seem to work there. Ok..)

Still, is the multi-dimensional part possible?

/HF


More information about the Digitalmars-d-learn mailing list