From 821418dd1cad823fd5a9a1ee4640e3344a3fc271 Mon Sep 17 00:00:00 2001 From: Neargye Date: Tue, 7 Aug 2018 23:08:46 +0500 Subject: [PATCH] TODO: constexpr NameofType g++. --- include/nameof.hpp | 6 +++--- test/test.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) 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;