how to compare the type of a subclass

Eric via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Nov 21 14:15:36 PST 2014


Suppose I have:

module test;
class X { }
class Y : X { }

Y y = new Y;

X x = y;

assert(is(typeof(x) == test.Y); // this assertion will fail
assert(typeid(x).toString() == "test.Y"); // this assertion will 
pass

Is there a way I can check the type of x without doing
a string comparison?

-Eric


More information about the Digitalmars-d-learn mailing list