Hey,

wondering whether it's possible to access the derived type from a function template in the base class or interface.

this T does not seem to be working, I guess because it's a static function and this does not exists?!


interface I
{
    static void test(this T)()
    {
        writeln(T.type.stringof);
    }
}

abstract class A
{
    static void test(this T)()
    {
        writeln(T.type.stringof);
    }
}

class B : A
{
    alias type = uint;
}
class C : I {
    alias type = int;
}

void main() {
        B.test();
        C.test();
}

Throws:
Error: template app.A.test cannot deduce function from argument types !()(), candidates are:
        app.A.test(this T)()
Error: template app.I.test cannot deduce function from argument types !()(), candidates are:
        app.I.test(this T)()


Any way I could accomplish this?

Reply via email to