Re: generating switch case from compile time sequence of functions

2019-07-15 Thread Sjoerd Nijboer via Digitalmars-d-learn
On Sunday, 14 July 2019 at 19:59:36 UTC, Adam D. Ruppe wrote: but I think even attempting this is overcomplicating. static foreach (name; FunctionNames) { name ~ " : " ~ name ~ "(); break;"; } I eventually went with `switch (mixin(index)) { static fore

Re: generating switch case from compile time sequence of functions

2019-07-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 July 2019 at 19:26:41 UTC, Sjoerd Nijboer wrote: The code it must generate for `doSwitch!(foo, bar)()` is `{ switch (int) { foo: foo(); return; bar: bar(); return; } }` I'd probably just do void doSwitch

generating switch case from compile time sequence of functions

2019-07-14 Thread Sjoerd Nijboer via Digitalmars-d-learn
I am trying to create a template function with a switch case inside it. The function signature is: `static void doSwitch(T...)(int i)` The code it must generate for `doSwitch!(foo, bar)()` is `{ switch (int) { foo: foo(); return; bar: b