13template<
typename TO,
typename FROM>
16 assert(
dynamic_cast<TO
>(from) ==
static_cast<TO
>(from));
17 return static_cast<TO
>(from);
19template<
typename TO,
typename FROM>
22 using TO_PTR = std::remove_reference_t<TO>*;
23 TO_PTR* suppress_warning =
nullptr; (void)suppress_warning;
24 assert(
dynamic_cast<TO_PTR
>(&from) ==
static_cast<TO_PTR
>(&from));
25 return static_cast<TO
>(from);
constexpr TO checked_cast(FROM *from)
Based on checked_cast implementation from the book: C++ Coding Standard item 93: Avoid using static_c...