On Wednesday, 20 January 2016 at 21:27:15 UTC, Steven Schveighoffer wrote:
It would be cool if the compiler could "expand" a finitely instantiable template (one with a finite number of ways it can be instantiated) based on a runtime value, and do the switch for me.

Can't you just write a wrapper function that takes the template function as a compile-time argument and generates the switch for you by iterating over the std.traits.EnumMembers of said compile-time parameter?

Something like `enumTemplateDispatch!foo(detectBOM(buffer), <runtime args>))`.

Depending on what template signatures you want to support, you might need to make enumTemplateDispatch explicitly take the enum type to use or the position of the respective parameter in the template argument list of the target.

 — David

Reply via email to