19 template<
class T> T*
as() { assert(
isa<T>());
return static_cast<T*
>(
this); }
26 return static_cast<B*
>(
this)->node() == T::Node ?
static_cast<T*
>(
this) :
nullptr;
28 return dynamic_cast<T*
>(
static_cast<B*
>(
this));
33 template<
class T,
class U> B*
isa() {
return (
isa<T>() ||
isa<U>()) ?
static_cast<B*
>(
this) :
nullptr; }
Inherit from this class using CRTP, for some nice dynamic_cast-style wrappers.
T * as()
static_cast with debug check.
const T * isa() const
const version.
B * isa()
Yields B* if it is either T or U and `nullptr* otherwise.
const B * isa() const
const version.
const T * as() const
const version.