From f51beedcddaebe39334e732f9fe586f8dd191981 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 15 Jan 2019 12:57:59 +1100 Subject: [PATCH] debug: cast unhandled enum to int before printing --- debug.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/debug.hpp b/debug.hpp index c2ed0105..c1dd7df4 100644 --- a/debug.hpp +++ b/debug.hpp @@ -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>; + if constexpr (std::is_enum_v) { + unhandled (static_cast> (t)); + } else { + std::ostringstream os; + os << "unhandled value: " << t << '\n'; + ::panic (os.str ()); + } } }