From fa0f7f3c794a503c39c5fc264d7e043dbfb45965 Mon Sep 17 00:00:00 2001 From: neargye Date: Fri, 3 May 2019 15:22:18 +0500 Subject: [PATCH] add NAMEOF_CONST_ENUM --- include/nameof.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/nameof.hpp b/include/nameof.hpp index 4751039..101bfce 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -234,6 +234,16 @@ template } } +// Obtains simple (unqualified) string enum name of static storage enum variable. +// This version is much lighter on the compile times and is not restricted to the enum_range limitation. +template +[[nodiscard]] constexpr std::enable_if_t>, std::string_view> nameof_enum() noexcept { + using D = std::decay_t; + static_assert(std::is_enum_v, "nameof::nameof_enum requires enum type."); + + return nameof_enum_impl(); +} + // Obtains string name of type. template [[nodiscard]] constexpr std::string_view nameof_type() noexcept { @@ -254,6 +264,10 @@ template // Obtains simple (unqualified) string enum name of enum variable. #define NAMEOF_ENUM(...) ::nameof::nameof_enum(__VA_ARGS__) +// Obtains simple (unqualified) string enum name of static storage enum variable. +// 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. #define NAMEOF_TYPE(...) ::nameof::nameof_type<__VA_ARGS__>()