diff --git a/include/nameof.hpp b/include/nameof.hpp index f330dea..b7ec353 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -233,9 +233,8 @@ template constexpr int min = enum_range::min > (std::numeric_limits::min)() ? enum_range::min : (std::numeric_limits::min)(); constexpr auto range = std::make_integer_sequence{}; constexpr auto names = detail::enum_names_impl(range); - const int i = static_cast(value) - min; - if (i >= 0 && static_cast(i) < names.size()) { + if (int i = static_cast(value) - min; i >= 0 && static_cast(i) < names.size()) { return names[i]; } else { return {}; // Value out of range.