Is it possible to use a template to choose between foreach and foreach_reverse?

pineapple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 4 07:32:23 PDT 2016


It would be fantastic if I could write this -

     static if(forward){
         foreach(item; items) dostuff();
     }else{
         foreach_reverse(item; items) dostuff();
     }

as something like this -

     foreach!forward(item; items) dostuff();

Is there any way to accomplish this?



More information about the Digitalmars-d-learn mailing list