mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
clean-up
This commit is contained in:
parent
369642f2b0
commit
86e73be298
1 changed files with 13 additions and 14 deletions
|
|
@ -984,7 +984,6 @@ template <typename E>
|
||||||
return static_cast<underlying_type_t<E>>(value);
|
return static_cast<underlying_type_t<E>>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns underlying value from enum value.
|
// Returns underlying value from enum value.
|
||||||
template <typename E>
|
template <typename E>
|
||||||
[[nodiscard]] constexpr auto enum_underlying(E value) noexcept -> detail::enable_if_t<E, underlying_type_t<E>> {
|
[[nodiscard]] constexpr auto enum_underlying(E value) noexcept -> detail::enable_if_t<E, underlying_type_t<E>> {
|
||||||
|
|
@ -1014,6 +1013,15 @@ template <typename E>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtains index in enum values from static storage enum variable.
|
||||||
|
template <auto V>
|
||||||
|
[[nodiscard]] constexpr auto enum_index() noexcept -> detail::enable_if_t<decltype(V), std::size_t> {
|
||||||
|
constexpr auto index = enum_index<std::decay_t<decltype(V)>>(V);
|
||||||
|
static_assert(index, "magic_enum::enum_index enum value does not have a index.");
|
||||||
|
|
||||||
|
return *index;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns name from static storage enum variable.
|
// Returns name from static storage enum variable.
|
||||||
// This version is much lighter on the compile times and is not restricted to the enum_range limitation.
|
// This version is much lighter on the compile times and is not restricted to the enum_range limitation.
|
||||||
template <auto V>
|
template <auto V>
|
||||||
|
|
@ -1063,7 +1071,7 @@ template <typename E>
|
||||||
|
|
||||||
return {}; // Invalid value or out of range.
|
return {}; // Invalid value or out of range.
|
||||||
} else {
|
} else {
|
||||||
return string{enum_name(value)};
|
return string{enum_name<D>(value)};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1079,6 +1087,9 @@ template <typename E>
|
||||||
return detail::entries_v<std::decay_t<E>>;
|
return detail::entries_v<std::decay_t<E>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allows you to write magic_enum::enum_cast<foo>("bar", magic_enum::case_insensitive);
|
||||||
|
inline constexpr auto case_insensitive = detail::case_insensitive{};
|
||||||
|
|
||||||
// Obtains enum value from integer value.
|
// Obtains enum value from integer value.
|
||||||
// Returns optional with enum value.
|
// Returns optional with enum value.
|
||||||
template <typename E>
|
template <typename E>
|
||||||
|
|
@ -1119,9 +1130,6 @@ template <typename E>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allows you to write magic_enum::enum_cast<foo>("bar", magic_enum::case_insensitive);
|
|
||||||
inline constexpr auto case_insensitive = detail::case_insensitive{};
|
|
||||||
|
|
||||||
// Obtains enum value from name.
|
// Obtains enum value from name.
|
||||||
// Returns optional with enum value.
|
// Returns optional with enum value.
|
||||||
template <typename E, typename BinaryPredicate = std::equal_to<>>
|
template <typename E, typename BinaryPredicate = std::equal_to<>>
|
||||||
|
|
@ -1173,15 +1181,6 @@ template <typename E, typename BinaryPredicate = std::equal_to<>>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtains index in enum values from static storage enum variable.
|
|
||||||
template <auto V>
|
|
||||||
[[nodiscard]] constexpr auto enum_index() noexcept -> detail::enable_if_t<decltype(V), std::size_t> {
|
|
||||||
constexpr auto index = enum_index<std::decay_t<decltype(V)>>(V);
|
|
||||||
static_assert(index, "magic_enum::enum_index enum value does not have a index.");
|
|
||||||
|
|
||||||
return *index;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checks whether enum contains enumerator with such enum value.
|
// Checks whether enum contains enumerator with such enum value.
|
||||||
template <typename E>
|
template <typename E>
|
||||||
[[nodiscard]] constexpr auto enum_contains(E value) noexcept -> detail::enable_if_t<E, bool> {
|
[[nodiscard]] constexpr auto enum_contains(E value) noexcept -> detail::enable_if_t<E, bool> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue