mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
fix #215
This commit is contained in:
parent
1b1194bcd5
commit
159a35006d
2 changed files with 12 additions and 9 deletions
|
|
@ -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`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue