From c015859ddb2a42a497d057e5c078b602f342e8ae Mon Sep 17 00:00:00 2001 From: neargye Date: Thu, 21 Mar 2019 11:56:59 +0500 Subject: [PATCH] clean-up --- include/nameof.hpp | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index d8802ce..de9942b 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -36,7 +36,7 @@ #include #if !defined(NAMEOF_ENUM_MAX_SEARCH_DEPTH) -# define NAMEOF_ENUM_MAX_SEARCH_DEPTH 64 +# define NAMEOF_ENUM_MAX_SEARCH_DEPTH 256 #endif namespace nameof { @@ -154,29 +154,34 @@ constexpr std::string_view nameof_enum_impl() { template struct nameof_enum_t { constexpr std::string_view operator()(int value) const { - return (value - I == 0) - ? nameof_enum_impl() - : (value - I == 1) - ? nameof_enum_impl() - : (value - I == 2) - ? nameof_enum_impl() - : (value - I == 3) - ? nameof_enum_impl() - : (value - I == 4) - ? nameof_enum_impl() - : (value - I == 5) - ? nameof_enum_impl() - : (value - I == 6) - ? nameof_enum_impl() - : (value - I == 7) - ? nameof_enum_impl() - : nameof_enum_t{}(value); + switch (value - I) { + case 0: + return nameof_enum_impl(); + case 1: + return nameof_enum_impl(); + case 2: + return nameof_enum_impl(); + case 3: + return nameof_enum_impl(); + case 4: + return nameof_enum_impl(); + case 5: + return nameof_enum_impl(); + case 6: + return nameof_enum_impl(); + case 7: + return nameof_enum_impl(); + default: + return nameof_enum_t{}(value); + } } }; template struct nameof_enum_t { - constexpr std::string_view operator()(int) const { return {"nameof_enum::out_of_range"}; } + constexpr std::string_view operator()(int) const { + return { "nameof_enum::out_of_range" }; + } }; constexpr std::string_view nameof_type_impl_(std::string_view name) {