Idiomatic way to call base method in generic code
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 25 00:57:49 PDT 2015
On Sun, 24 May 2015 23:32:50 +0000, ZombineDev wrote:
> I know I can call a base implementation of a method like in 3), but I
> need to do it generically like in 2). Does anybody now how I can achieve
> this?
i don't know why you want that, but something like this may do:
auto callBaseMethod(string MTN, C, Args...) (inout C self, Args args) {
alias FSC = BaseClassesTuple!(C)[0];
return mixin(`self.`~FSC.stringof~`.`~MTN~"(args)");
}
writeln(d.callBaseMethod!"toString");
> Additionally is there a way to make 1) work without using string mixins?
no. and again, why do you want that? why do you people are so afraid of
string mixins? ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150525/ba7c0ddb/attachment.sig>
More information about the Digitalmars-d-learn
mailing list