From 68308613820a5501a3b6babb2d60ce8e4a3b755b Mon Sep 17 00:00:00 2001 From: terik23 Date: Mon, 22 Jul 2019 00:13:06 +0500 Subject: [PATCH] nameof_type return name same as typeid --- include/nameof.hpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index 4dc75c6..2117c9e 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -251,9 +251,15 @@ template return detail::nameof_enum_impl(); } -// Obtains string name of type. +// Obtains string name of type, reference and cv-qualifiers are ignored. template [[nodiscard]] constexpr std::string_view nameof_type() noexcept { + return detail::nameof_type_impl>>>(); +} + +// Obtains string name of full type, with reference and cv-qualifiers. +template +[[nodiscard]] constexpr std::string_view nameof_full_type() noexcept { return detail::nameof_type_impl>(); } @@ -275,10 +281,16 @@ template // This version is much lighter on the compile times and is not restricted to the enum_range limitation. #define NAMEOF_CONST_ENUM(...) ::nameof::nameof_enum<__VA_ARGS__>() -// Obtains string name of type. +// Obtains string name of type, reference and cv-qualifiers are ignored. #define NAMEOF_TYPE(...) ::nameof::nameof_type<__VA_ARGS__>() -// Obtains string name of variable type. -#define NAMEOF_VAR_TYPE(...) ::nameof::nameof_type() +// Obtains string name of full type, with reference and cv-qualifiers. +#define NAMEOF_FULL_TYPE(...) ::nameof::nameof_full_type<__VA_ARGS__>() + +// Obtains string name type of expression, reference and cv-qualifiers are ignored. +#define NAMEOF_TYPE_EXPR(...) ::nameof::nameof_type() + +// Obtains string name full type of expression, with reference and cv-qualifiers. +#define NAMEOF_FULL_TYPE_EXPR(...) ::nameof::nameof_full_type() #endif // NEARGYE_NAMEOF_HPP