Create mixins from a list of strings
Philippe Sigaud
philippe.sigaud at gmail.com
Sat Jan 11 01:17:23 PST 2014
Maybe you could use just one name and put the dispatching code inside it?
T actor(T)(T t)
{
switch (t.name)
{
case "Gramm.Expr":
return foo(t);
case "Gramm.FunctionCall":
return foo(t);
case "Gramm.Declaration":
return foo(t);
default:
throw new Exception("...");
}
}
or do it with a template, holding function names as aliases:
alias actor = dispatcher!(foo, bar, baz);
More information about the Digitalmars-d-learn
mailing list