.classinfo by Class name

Adam adam at anizi.com
Thu Dec 1 13:56:37 PST 2011


Nevermind - sorry for the clutter.

For those who are apparently as dense as I am, this can be roughly
accomplished via Template specialization:

class Fruit {}

class Apple : Fruit {}

class Celery {}

void mustBeFruit(T : Fruit)() {
    writeln(T.classinfo.name);
}

void main() {
    mustBeFruit!(Apple)(); // Ok
    mustBeFruit!(Celery)(); // Does not compile
}


More information about the Digitalmars-d-learn mailing list