How to compare two types?
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Aug 31 15:52:02 PDT 2014
There's two ways:
static if(is(One == Two)) {
}
That compares the static types in a form of conditional
compilation. http://dlang.org/expression.html#IsExpression
If you want to compare the runtime type of a class object, you
can do:
if(typeid(obj_one) == typeid(obj_two))
that should tell you if they are the same dynamic class type.
More information about the Digitalmars-d-learn
mailing list