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,9 +527,14 @@ namespace cruft::debug::detail {
void
unhandled [[noreturn]] (T &&t) noexcept
{
std::ostringstream os;
os << "unhandled value: " << t << '\n';
::panic (os.str ());
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;
os << "unhandled value: " << t << '\n';
::panic (os.str ());
}
}
}