diff --git a/include/nameof.hpp b/include/nameof.hpp index 8c71c2e..5ea132d 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -206,7 +206,7 @@ template -inline detail::cstring NameofTypeRaw() noexcept { +inline constexpr detail::cstring NameofTypeRaw() noexcept { #if defined(__clang__) return {__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, @@ -215,7 +215,7 @@ inline detail::cstring NameofTypeRaw() noexcept { #elif defined(__GNUC__) return {__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, - sizeof("nameof::detail::cstring nameof::NameofTypeRaw() [with T = ") - 1, + sizeof("constexpr nameof::detail::cstring nameof::NameofTypeRaw() [with T = ") - 1, sizeof("]") - 1}; #elif defined(_MSC_VER) return {__FUNCSIG__, @@ -228,7 +228,7 @@ inline detail::cstring NameofTypeRaw() noexcept { } template ::type> -inline detail::cstring NameofType() noexcept { +inline constexpr detail::cstring NameofType() noexcept { const auto raw_type_name = NameofTypeRaw(); return detail::NameofBase(raw_type_name.begin(), raw_type_name.length(), false); } diff --git a/test/test.cpp b/test/test.cpp index ad4d62b..bff76d2 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -114,7 +114,8 @@ TEST_CASE("constexpr") { static_assert(cx6 == "__cplusplus", ""); } -#if 0 + //TODO: constexpr NameofType gcc. +#if (defined(__clang__) || (defined(_MSC_VER) && _MSC_VER >= 1910)) SECTION("NAMEOF_TYPE") { SomeClass a;