diff --git a/include/nameof.hpp b/include/nameof.hpp index 037cbf8..b5aed41 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -385,25 +385,32 @@ NAMEOF_CONSTEXPR nameof::cstring NameofEnumImpl2() { #endif } -template +template struct NameofEnumImpl { - NAMEOF_CONSTEXPR nameof::cstring operator()(T value) const { - return (static_cast(value) - I == 0) - ? NameofEnumImpl2() - : (static_cast(value) >= 0) - ? NameofEnumImpl{}(value) - : NameofEnumImpl{}(value); + NAMEOF_CONSTEXPR nameof::cstring operator()(int value) const { + return (value - I == 0) + ? NameofEnumImpl2() + : (value - I == 1) + ? NameofEnumImpl2() + : (value - I == 2) + ? NameofEnumImpl2() + : (value - I == 3) + ? NameofEnumImpl2() + : (value - I == 4) + ? NameofEnumImpl2() + : (value - I == 5) + ? NameofEnumImpl2() + : (value - I == 6) + ? NameofEnumImpl2() + : (value - I == 7) + ? NameofEnumImpl2() + : NameofEnumImpl{}(value); } }; template struct NameofEnumImpl { - NAMEOF_CONSTEXPR nameof::cstring operator()(T) const { return {}; } -}; - -template -struct NameofEnumImpl { - NAMEOF_CONSTEXPR nameof::cstring operator()(T) const { return {}; } + NAMEOF_CONSTEXPR nameof::cstring operator()(int) const { return {}; } }; template @@ -447,9 +454,9 @@ template ::value && std::is_enum::value>::type> NAMEOF_CONSTEXPR cstring NameofEnum(T value) { #if defined(__clang__) || defined(_MSC_VER) - return detail::NameofPretty(detail::NameofEnumImpl{}(value), false); + return detail::NameofPretty(detail::NameofEnumImpl{}(static_cast(value)), false); #elif defined(__GNUC__) - return detail::NameofEnumImpl{}(value); + return detail::NameofEnumImpl{}(static_cast(value)); #else return {}; #endif