From f643be2f212164acd56ea16ad39d8eecf0ab09b2 Mon Sep 17 00:00:00 2001 From: terik23 Date: Thu, 11 Apr 2019 22:24:53 +0500 Subject: [PATCH] improve name_impl --- include/magic_enum.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index c368d49..330593a 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -114,10 +114,10 @@ template #if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9) || defined(_MSC_VER) constexpr auto prefix = name.find_last_of(" :,-)", name.length() - suffix) + 1; - if ((name[prefix] >= 'a' && name[prefix] <= 'z') || (name[prefix] >= 'A' && name[prefix] <= 'Z')) { - return name.substr(prefix, name.size() - prefix - suffix); - } else { + if constexpr (name[prefix] >= '0' && name[prefix] <= '9') { return {}; // Value does not have name. + } else { + return name.substr(prefix, name.length() - prefix - suffix); } #endif }