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