From acf3f7faada7a1c0a886ca70350f13d14b867cfb Mon Sep 17 00:00:00 2001 From: Neargye Date: Tue, 7 Aug 2018 21:14:24 +0500 Subject: [PATCH] fix nameofType --- include/nameof.hpp | 18 ++++++++++++------ test/test.cpp | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index dd80fbf..8c71c2e 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -208,14 +208,20 @@ inline NAMEOF_CONSTEXPR14 detail::cstring Nameof(T&&, const char*, std::size_t, template inline detail::cstring NameofTypeRaw() noexcept { #if defined(__clang__) - return {__PRETTY_FUNCTION__ + (sizeof("detail::cstring nameof::NameofTypeRaw() [T = ") - 1), - (sizeof(__PRETTY_FUNCTION__) - 1) - (sizeof("detail::cstring nameof::NameofTypeRaw() [T = ") - 1) - (sizeof("]") - 1)}; + return {__PRETTY_FUNCTION__, + sizeof(__PRETTY_FUNCTION__) - 1, + sizeof("detail::cstring nameof::NameofTypeRaw() [T = ") - 1, + sizeof("]") - 1}; #elif defined(__GNUC__) - return {__PRETTY_FUNCTION__ + (sizeof("constexpr nameof::detail::cstring nameof::NameofTypeRaw() [with T = ") - 1), - (sizeof(__PRETTY_FUNCTION__) - 1) - (sizeof("constexpr nameof::detail::cstring nameof::NameofTypeRaw() [with T = ") - 1) - (sizeof("]") - 1)}; + return {__PRETTY_FUNCTION__, + sizeof(__PRETTY_FUNCTION__) - 1, + sizeof("nameof::detail::cstring nameof::NameofTypeRaw() [with T = ") - 1, + sizeof("]") - 1}; #elif defined(_MSC_VER) - return {__FUNCSIG__ + (sizeof("class nameof::detail::cstring __cdecl nameof::NameofTypeRaw<") - 1), - (sizeof(__FUNCSIG__) - 1) - (sizeof("class nameof::detail::cstring __cdecl nameof::NameofTypeRaw<") - 1) - (sizeof(">(void) noexcept") - 1)}; + return {__FUNCSIG__, + sizeof(__FUNCSIG__) - 1, + sizeof("class nameof::detail::cstring __cdecl nameof::NameofTypeRaw<") - 1, + sizeof(">(void) noexcept") - 1}; #else return {}; #endif diff --git a/test/test.cpp b/test/test.cpp index 713a4a8..ad4d62b 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -113,6 +113,7 @@ TEST_CASE("constexpr") { constexpr auto cx6 = NAMEOF_RAW(__cplusplus); static_assert(cx6 == "__cplusplus", ""); } + #if 0 SECTION("NAMEOF_TYPE") { SomeClass a;