On Friday, 31 May 2019 at 08:35:23 UTC, Simen Kjærås wrote:
With 1), 2) and 3) fixed, the code would look like this (only
changed code included):
unittest {
with (Dispatcher.X) {
A(1);
A("a");
B(2);
C_Q(3);
}
}
struct Dispatcher {
struct opDispatch(string prefix, alias context =
__CONTEXT__) {
static auto opDispatch(string name, Args...)(Args args)
{
return getMethod!(context, prefix~"_"~name)(args);
}
}
}
Actually, Dispatcher could look like this:
struct Dispatcher {
struct opDispatch(string prefix, alias context = __CONTEXT__)
{
alias opDispatch(string name) = getMethod!(context,
prefix~"_"~name);
}
}
--
Simen