parallelism

thedeemon dlang at thedeemon.com
Sun Jan 28 04:44:23 UTC 2018


On Saturday, 27 January 2018 at 20:49:43 UTC, Arun Chandrasekaran 
wrote:

> Error: must use labeled break within static foreach

Just follow the compiler suggestion:

void main(string[] args) {
     auto op = Operation.a;
     foreach (_; 0 .. args.length) {
         ops: final switch (op) {
             static foreach(e; EnumMembers!Operation) {
             case e:
                 mixin(e.to!string ~ "();");
                 break ops;
             }
         }
     }
}

Here 'ops' is a label that we use to tell break what exactly it 
breaks.
But really I'm not sure why you want static foreach here, a 
simple foreach is fine, it gets unrolled statically here just 
like static one.


More information about the Digitalmars-d-learn mailing list