diff --git a/include/magic_enum/magic_enum.hpp b/include/magic_enum/magic_enum.hpp index 161f44b..5b95952 100644 --- a/include/magic_enum/magic_enum.hpp +++ b/include/magic_enum/magic_enum.hpp @@ -1414,17 +1414,26 @@ template , typename Bi return static_cast(enum_cast(value, std::move(p))); } -// Returns true if the enum value is in the range of values that can be reflected. +// Returns true if the enum integer value is in the range of values that can be reflected. template > -[[nodiscard]] constexpr auto enum_reflected(E value) noexcept -> detail::enable_if_t { +[[nodiscard]] constexpr auto enum_reflected(underlying_type_t value) noexcept -> detail::enable_if_t { using D = std::decay_t; if constexpr (detail::is_reflected_v) { constexpr auto min = detail::reflected_min(); constexpr auto max = detail::reflected_max(); return value >= min && value <= max; + } else { + return false; } - return false; +} + +// Returns true if the enum value is in the range of values that can be reflected. +template > +[[nodiscard]] constexpr auto enum_reflected(E value) noexcept -> detail::enable_if_t { + using D = std::decay_t; + + return enum_reflected(static_cast>(value)); } // Returns true if the enum value is in the range of values that can be reflected. @@ -1432,15 +1441,7 @@ template [[nodiscard]] constexpr auto enum_reflected(E value) noexcept -> detail::enable_if_t { using D = std::decay_t; - return enum_cast(value); -} - -// Returns true if the enum integer value is in the range of values that can be reflected. -template > -[[nodiscard]] constexpr auto enum_reflected(underlying_type_t value) noexcept -> detail::enable_if_t { - using D = std::decay_t; - - return enum_cast(value); + return enum_reflected(value); } template