From cff9399e284a92b264777321807729933930dde6 Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 10 Oct 2019 16:15:42 +0500 Subject: [PATCH] update static_assert --- include/nameof.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index ffd0cf6..7bf4423 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -86,7 +86,7 @@ static_assert(NAMEOF_ENUM_RANGE_MAX > NAMEOF_ENUM_RANGE_MIN, "NAMEOF_ENUM_RANGE_ template struct [[nodiscard]] cstring { - static_assert(N > 0, "Expression does not have a name."); + static_assert(N > 0, "nameof::cstring requires size greater than 0."); constexpr cstring(std::string_view str) noexcept : cstring{str, std::make_index_sequence{}} {} @@ -537,6 +537,8 @@ constexpr auto n() noexcept { # elif defined(_MSC_VER) constexpr std::string_view name{__FUNCSIG__ + 63, sizeof(__FUNCSIG__) - 81 - (__FUNCSIG__[sizeof(__FUNCSIG__) - 19] == ' ' ? 1 : 0)}; # endif + static_assert(!name.empty(), "Type does not have a name."); + return cstring{name}; #else static_assert(nameof_type_supported::value, "nameof::nameof_type: Unsupported compiler (https://github.com/Neargye/nameof#compiler-compatibility).");