debug: cast unhandled enum to int before printing

This commit is contained in:
Danny Robson 2019-01-15 12:57:59 +11:00
parent 04a44c627f
commit f51beedcdd

View File

@ -527,11 +527,16 @@ namespace cruft::debug::detail {
void void
unhandled [[noreturn]] (T &&t) noexcept unhandled [[noreturn]] (T &&t) noexcept
{ {
using base_type = std::remove_reference_t<std::decay_t<T>>;
if constexpr (std::is_enum_v<base_type>) {
unhandled (static_cast<std::underlying_type_t<base_type>> (t));
} else {
std::ostringstream os; std::ostringstream os;
os << "unhandled value: " << t << '\n'; os << "unhandled value: " << t << '\n';
::panic (os.str ()); ::panic (os.str ());
} }
} }
}
template <typename T> template <typename T>