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?

Reply via email to