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; }
35 template<
class T >
const T*
as()
const {
return const_cast<RuntimeCast*
>(
this)->
template as<T >(); }
36 template<
class T >
const T*
isa()
const {
return const_cast<RuntimeCast*
>(
this)->
template isa<T >(); }
37 template<
class T,
class U>
const B*
isa()
const {
return const_cast<RuntimeCast*
>(
this)->
template isa<T, U>(); }
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.