[Issue 13732] Regular templates can use "template this", and they allow any type to be passed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 9 10:48:06 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=13732

--- Comment #2 from Meta <monkeyworks12 at hotmail.com> ---
import std.stdio;

class Base {
    void test1(T = typeof(this))() {
        writeln("test1: ", T.stringof);
    }

    void test2(this T)() {
        writeln("test2: ", T.stringof);
    }
}

class Derived: Base {
}

void main()
{
    new Base().test1();    //test1: Base
    new Base().test2();    //test2: Base

    new Derived().test1(); //test1: Base
    new Derived().test2(); //test1: Derived
}

--


More information about the Digitalmars-d-bugs mailing list