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__)