diff --git a/include/nameof.hpp b/include/nameof.hpp index f637342..34e80db 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -559,16 +559,18 @@ constexpr auto n() noexcept { template inline constexpr auto type_name_v = n(); -inline auto n(const char* tn) { #if __has_include() +inline std::string demangle(const char* tn) { auto dmg = abi::__cxa_demangle(tn, nullptr, nullptr, nullptr); auto r = std::string{dmg != nullptr ? dmg : tn}; std::free(dmg); return r; -#else - return std::string_view{tn}; -#endif } +#else +constexpr std::string_view demangle(const char* tn) noexcept { + return std::string_view{tn}; +} +#endif } // namespace nameof::detail @@ -691,7 +693,7 @@ template #define NAMEOF_FULL_TYPE_EXPR(...) ::nameof::nameof_full_type() // Obtains string name of type using RTTI. -#define NAMEOF_TYPE_RTTI(...) ::nameof::detail::n(typeid(__VA_ARGS__).name()) +#define NAMEOF_TYPE_RTTI(...) ::nameof::detail::demangle(typeid(__VA_ARGS__).name()) #if defined(_MSC_VER) # pragma warning(pop)