1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-08 23:24:20 +00:00

fix enum_reflected

This commit is contained in:
neargye 2024-06-29 17:01:20 +03:00
parent bc2e94853b
commit f08355cd0d

View file

@ -1414,17 +1414,26 @@ template <typename E, detail::enum_subtype S = detail::subtype_v<E>, typename Bi
return static_cast<bool>(enum_cast<D, S>(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 <typename E, detail::enum_subtype S = detail::subtype_v<E>>
[[nodiscard]] constexpr auto enum_reflected(E value) noexcept -> detail::enable_if_t<E, bool> {
[[nodiscard]] constexpr auto enum_reflected(underlying_type_t<E> value) noexcept -> detail::enable_if_t<E, bool> {
using D = std::decay_t<E>;
if constexpr (detail::is_reflected_v<D, S>) {
constexpr auto min = detail::reflected_min<E, S>();
constexpr auto max = detail::reflected_max<E, S>();
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 <typename E, detail::enum_subtype S = detail::subtype_v<E>>
[[nodiscard]] constexpr auto enum_reflected(E value) noexcept -> detail::enable_if_t<E, bool> {
using D = std::decay_t<E>;
return enum_reflected<D, S>(static_cast<underlying_type_t<D>>(value));
}
// Returns true if the enum value is in the range of values that can be reflected.
@ -1432,15 +1441,7 @@ template <detail::enum_subtype S, typename E>
[[nodiscard]] constexpr auto enum_reflected(E value) noexcept -> detail::enable_if_t<E, bool> {
using D = std::decay_t<E>;
return enum_cast<D, S>(value);
}
// Returns true if the enum integer value is in the range of values that can be reflected.
template <typename E, detail::enum_subtype S = detail::subtype_v<E>>
[[nodiscard]] constexpr auto enum_reflected(underlying_type_t<E> value) noexcept -> detail::enable_if_t<E, bool> {
using D = std::decay_t<E>;
return enum_cast<D, S>(value);
return enum_reflected<D, S>(value);
}
template <bool AsFlags = true>