debug: pretend to return the same type in unhandled
This commit is contained in:
parent
e7dda93a36
commit
d57a4dddc2
@ -524,9 +524,13 @@ unreachable [[noreturn]] (void)
|
||||
/// statements. will almost invariably abort the application.
|
||||
namespace cruft::debug::detail {
|
||||
template <typename T>
|
||||
void
|
||||
T
|
||||
unhandled [[noreturn]] (T &&t) noexcept
|
||||
{
|
||||
// If we've been given an enum we should handle it like its underlying
|
||||
// type so that when we end up logging it we don't accidentally
|
||||
// trigger an infinite loop of calls to `unhandled` within the
|
||||
// ostream operator. It doesn't have to be pretty, just functional.
|
||||
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));
|
||||
@ -540,7 +544,7 @@ namespace cruft::debug::detail {
|
||||
|
||||
|
||||
template <typename T>
|
||||
constexpr void
|
||||
constexpr T
|
||||
unhandled [[noreturn]] (T &&t) noexcept
|
||||
{
|
||||
cruft::debug::detail::unhandled (std::forward<T> (t));
|
||||
|
Loading…
Reference in New Issue
Block a user