|
FE 0.10.2
Header-only C++ frontend library
|
Inherit from this class using CRTP, for some nice dynamic_cast-style wrappers. More...
#include <fe/cast.h>
Public Member Functions | |
| template<class T> | |
| T * | as () |
| static_cast with debug check. | |
| template<class T> | |
| T * | isa () |
| dynamic_cast. | |
| template<class T> | |
| const T * | as () const |
| const version. | |
| template<class T> | |
| const T * | isa () const |
| const version. | |
| template<class T, class... Args> | |
| T * | expect (std::format_string< Args... > fmt, Args &&... args) |
| Like as() but - instead of merely asserting via isa() in Debug builds - throws a std::logic_error with a formatted message when the cast fails. | |
| template<class T, class... Args> | |
| const T * | expect (std::format_string< Args... > fmt, Args &&... args) const |
| const version. | |
Inherit from this class using CRTP, for some nice dynamic_cast-style wrappers.
|
inline |
Like as() but - instead of merely asserting via isa() in Debug builds - throws a std::logic_error with a formatted message when the cast fails.
fmt / args describe what was expected: a plain string works, as does a format string plus arguments. If B is std::formattable, the offending object is appended to the message.
Definition at line 46 of file cast.h.
References isa(), and fe::throwf().
Referenced by expect().
|
inline |