Return enum-templated struct based on runtime value
Tobias Pankrath
tobias at pankrath.net
Sat Apr 6 08:38:53 PDT 2013
>
> Is there however some way to generate that switch with cases
> for each enum member in a template, so that each case calls
> <some-passed-template-func>(Machine)() instantiated with the
> appropriate enum member? I know you could do it with string
> mixins, but that be a hassle to implement...
>
> Eventually, I want my code to look like
>
> void func(Machine machine)() { ... }
> switchOnEachEnumMember!func(machine);
http://dpaste.dzfl.pl/ce8366a7
The foreach is unrolled at compile time.
More information about the Digitalmars-d-learn
mailing list