Idea: limited template expansion
Sebastiaan Koppe via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jan 21 04:18:23 PST 2016
On Wednesday, 20 January 2016 at 21:44:06 UTC, David Nadlinger
wrote:
> 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>))`.
I have used EnumMembers a few times and it definitely saved me
the hassle of writing the switch myself.
However, in this case, isn't there a mapping between enums and
types that one still needs to specify? That is: ( UTF8=>char[],
UTF16=>wchar[], UTF32=>dchar[] ).
More information about the Digitalmars-d
mailing list