How to get the type of a derived class in a method of its base class?

Max Samukha via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 18 23:52:13 PST 2017


class A {
     this(T = this)() {
         static assert(is(T == B));
     }
}

class B {
}

auto b = new B;

Here, T becomes A, which may be reasonable but is completely 
useless. Is there a way to obtain the type of the class (or class 
instance reference) the method is called on?


More information about the Digitalmars-d-learn mailing list