Is there other way to do that?
Jack
jckj33 at gmail.com
Mon Feb 15 07:26:56 UTC 2021
I need to check if an instance is of a specific type derived from
my base class but this class has template parameter and this type
isn't available at time I'm checking it. Something like:
class B { }
class A(T) : B { }
class X : B { }
class Z : B { }
auto c = can be any derived class from B
bool isX = cast(A!???) c !is null;
assert(isX);
an interface would work:
interface IA { }
class A(T) : B, IA { }
bool isX = cast(IA) c !is null;
assert(isX);
but I would have create one just for that. It feels a bit hacky?
also, does an empty interface like that increase the A class
memory size at all?
More information about the Digitalmars-d-learn
mailing list