From b68625ca7a2ce49030bdfb1c774905c91f24a3b8 Mon Sep 17 00:00:00 2001 From: terik23 Date: Sun, 14 Apr 2019 18:16:24 +0500 Subject: [PATCH] add check type --- include/nameof.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index 231590d..3a5fa08 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -143,6 +143,14 @@ template > } } +template +struct check final { + using type = void; +}; + +template +using check_t = typename check::type; + template [[nodiscard]] constexpr std::string_view nameof_impl(std::string_view name, bool with_template_suffix) noexcept { if (name.length() >= 1 && (name.front() == '"' || name.front() == '\'')) { @@ -245,13 +253,13 @@ template } // namespace nameof // NAMEOF obtains simple (unqualified) string name of variable, function, enum, macro. -#define NAMEOF(...) ::nameof::detail::nameof_impl(#__VA_ARGS__, false) +#define NAMEOF(...) ::nameof::detail::nameof_impl<::nameof::detail::check_t>(#__VA_ARGS__, false) // Obtains simple (unqualified) full (with template suffix) string name of variable, function, enum, macro. -#define NAMEOF_FULL(...) ::nameof::detail::nameof_impl(#__VA_ARGS__, true) +#define NAMEOF_FULL(...) ::nameof::detail::nameof_impl<::nameof::detail::check_t>(#__VA_ARGS__, true) // Obtains raw string name of variable, function, enum, macro. -#define NAMEOF_RAW(...) ::nameof::detail::nameof_raw_impl(#__VA_ARGS__) +#define NAMEOF_RAW(...) ::nameof::detail::nameof_raw_impl<::nameof::detail::check_t>(#__VA_ARGS__) // Obtains simple (unqualified) string enum name of enum variable. #define NAMEOF_ENUM(...) ::nameof::nameof_enum(__VA_ARGS__)