A template for method forwarding?
Christian Kamm
kamm-incasoftware at removethis.de
Sat Dec 13 02:05:15 PST 2008
> So looks like bad stringof is the culprit, once again.
Why use stringof when you have an alias? This works for me in D1 - if you
discount default arguments and parameter storage classes (will templates
ever be able to touch these?).
template Forward(string clName, Methods...) {
static if(Methods.length == 1) {
mixin ForwardImpl!(clName, Methods[0]);
} else {
mixin ForwardImpl!(clName, Methods[0]);
mixin Forward!(clName, Methods[1..$]);
}
}
template ForwardImpl(string clName, string method) {
private mixin("alias ParameterTypeTuple!(" ~ clName ~ "."
~ method ~ ") params;");
private mixin("alias ReturnType!(" ~ clName ~ "."
~ method ~ ") retType;");
mixin("retType " ~ method ~
"(params args){ return " ~ clName ~ "."
~ method ~ "(args); }");
}
More information about the Digitalmars-d
mailing list