17#ifndef LIB_CASTABLE_H_
18#define LIB_CASTABLE_H_
22#include "lib/exceptions.h"
40 const T &
as()
const {
…}
53 auto *result =
to<T>();
54 BUG_CHECK(result,
"Cast failed: %1% is not a %2%",
this,
typeid(T).name());
61 auto *result =
to<T>();
62 BUG_CHECK(result,
"Cast failed: %1% is not a %2%",
this,
typeid(T).name());
T & as()
Tries to convert the class to type T. A BUG occurs if the cast fails.
Definition castable.h:46
const T & as() const
Tries to convert the class to type T. A BUG occurs if the cast fails.
Definition castable.h:40
T * checkedTo()
Performs a checked cast. A BUG occurs if the cast fails.
Definition castable.h:60
const T * checkedTo() const
Performs a checked cast. A BUG occurs if the cast fails.
Definition castable.h:52
T * to() noexcept
Definition rtti.h:226