1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-09 23:34:23 +00:00
This commit is contained in:
neargye 2022-10-11 19:01:04 +04:00
parent 1b1194bcd5
commit 159a35006d
2 changed files with 12 additions and 9 deletions

View file

@ -93,6 +93,8 @@ constexpr optional<E> enum_cast(string_view value, BinaryPredicate p) noexcept(i
if (color.has_value()) {
// color.value() -> Color::GREEN
}
auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
```
* Integer to enum value.
@ -103,6 +105,8 @@ constexpr optional<E> enum_cast(string_view value, BinaryPredicate p) noexcept(i
if (color.has_value()) {
// color.value() -> Color::RED
}
auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
```
## `enum_value`