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

Heywood Floyd soul8o8 at gmail.com
Thu Aug 25 02:55:47 PDT 2011


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


More information about the Digitalmars-d-learn mailing list