TODO: constexpr NameofType g++.

This commit is contained in:
Neargye 2018-08-07 23:08:46 +05:00
parent 247ae55af3
commit 821418dd1c
2 changed files with 5 additions and 4 deletions

View file

@ -206,7 +206,7 @@ template <typename T,
inline NAMEOF_CONSTEXPR14 detail::cstring Nameof(T&&, const char*, std::size_t, bool) = delete; inline NAMEOF_CONSTEXPR14 detail::cstring Nameof(T&&, const char*, std::size_t, bool) = delete;
template <typename T> template <typename T>
inline detail::cstring NameofTypeRaw() noexcept { inline constexpr detail::cstring NameofTypeRaw() noexcept {
#if defined(__clang__) #if defined(__clang__)
return {__PRETTY_FUNCTION__, return {__PRETTY_FUNCTION__,
sizeof(__PRETTY_FUNCTION__) - 1, sizeof(__PRETTY_FUNCTION__) - 1,
@ -215,7 +215,7 @@ inline detail::cstring NameofTypeRaw() noexcept {
#elif defined(__GNUC__) #elif defined(__GNUC__)
return {__PRETTY_FUNCTION__, return {__PRETTY_FUNCTION__,
sizeof(__PRETTY_FUNCTION__) - 1, 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}; sizeof("]") - 1};
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
return {__FUNCSIG__, return {__FUNCSIG__,
@ -228,7 +228,7 @@ inline detail::cstring NameofTypeRaw() noexcept {
} }
template <typename T, typename D = typename detail::Decay<T>::type> template <typename T, typename D = typename detail::Decay<T>::type>
inline detail::cstring NameofType() noexcept { inline constexpr detail::cstring NameofType() noexcept {
const auto raw_type_name = NameofTypeRaw<D>(); const auto raw_type_name = NameofTypeRaw<D>();
return detail::NameofBase(raw_type_name.begin(), raw_type_name.length(), false); return detail::NameofBase(raw_type_name.begin(), raw_type_name.length(), false);
} }

View file

@ -114,7 +114,8 @@ TEST_CASE("constexpr") {
static_assert(cx6 == "__cplusplus", ""); static_assert(cx6 == "__cplusplus", "");
} }
#if 0 //TODO: constexpr NameofType gcc.
#if (defined(__clang__) || (defined(_MSC_VER) && _MSC_VER >= 1910))
SECTION("NAMEOF_TYPE") { SECTION("NAMEOF_TYPE") {
SomeClass<int> a; SomeClass<int> a;