From 790fb2877536caa30f82657bb550d95e33c4bac7 Mon Sep 17 00:00:00 2001 From: Neargye Date: Sun, 2 Sep 2018 00:14:14 +0500 Subject: [PATCH] improve nameof enum --- include/nameof.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index 65fd63f..88dd663 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -455,9 +455,15 @@ template ::value>::type> NAMEOF_CONSTEXPR cstring NameofEnum(T value) { #if defined(__clang__) || defined(_MSC_VER) - return detail::NameofPretty(detail::NameofEnumImpl{}(static_cast(value)), false); + return detail::NameofPretty( + std::is_unsigned::type>::value + ? detail::NameofEnumImpl{}(static_cast(value)) + : detail::NameofEnumImpl{}(static_cast(value)), + false); #elif defined(__GNUC__) - return detail::NameofEnumImpl{}(static_cast(value)); + return std::is_unsigned::type>::value + ? detail::NameofEnumImpl{}(static_cast(value)) + : detail::NameofEnumImpl{}(static_cast(value)); #else return {}; #endif