From 5013f0e351efd30aad4099b3b36ef805d6cc05e4 Mon Sep 17 00:00:00 2001 From: Neargye Date: Tue, 4 Sep 2018 19:25:28 +0500 Subject: [PATCH] clean-up --- include/nameof.hpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index 9faee3e..c98cdad 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -92,22 +92,6 @@ constexpr int StrCompare(const char* lhs, const char* rhs, std::size_t size) { #endif } -constexpr std::size_t StrLen(const char* str, std::size_t size = 0) { -#if !defined(_MSC_VER) && __cplusplus >= 201703L - static_cast(size); - return std::char_traits::length(str); -#elif defined(NAMEOF_HAS_CONSTEXPR14) - for (; str != nullptr; ++size) { - if (str[size] == '\0') { - return size; - } - } - return size; -#else - return (str[size] == '\0') ? size : StrLen(str, size + 1); -#endif -} - } // namespace detail // std::string like compile-time const char* string. @@ -120,7 +104,8 @@ class cstring final { : str_{str + prefix}, size_{size - prefix - suffix} {} - constexpr cstring(const char* str) noexcept : cstring{str, detail::StrLen(str), 0, 0} {} + template + constexpr cstring(const char (&str)[N]) noexcept : cstring{str, N - 1, 0, 0} {} constexpr cstring() noexcept : cstring{nullptr, 0, 0, 0} {} @@ -475,10 +460,9 @@ NAMEOF_CONSTEXPR cstring NameofEnum(D value) { #endif } -template +template > NAMEOF_CONSTEXPR cstring NameofType() { - return true ? detail::NameofType>() - : detail::NameofType>(); + return true ? detail::NameofType() : detail::NameofType(); } template