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

update doc

This commit is contained in:
neargye 2023-08-14 18:41:40 +04:00
parent 4904822db8
commit 45c8b5d92c
3 changed files with 17 additions and 1 deletions

View file

@ -92,6 +92,13 @@ constexpr optional<E> enum_cast(string_view value, BinaryPredicate p) noexcept(i
// color.value() -> Color::GREEN
}
// case insensitive enum_cast
auto color = magic_enum::enum_cast<Color>(value, magic_enum::case_insensitive);
// enum_cast with BinaryPredicate
auto color = magic_enum::enum_cast<Color>(value, [](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }
// enum_cast with default
auto color_or_default = magic_enum::enum_cast<Color>(value).value_or(Color::NONE);
```