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

update readme

This commit is contained in:
neargye 2019-04-02 14:54:55 +05:00
parent 6a5fe48e4b
commit f2c3bd8fe5

View file

@ -46,16 +46,16 @@ if (color_name.has_value()) {
constexpr auto cx_color = Color::BLUE;
// Static storage enum variable to string enum name.
auto cx_color_name = magic_enum::enum_to_string<cx_color>();
constexpr auto color_name = magic_enum::enum_to_string<cx_color>();
if (color_name.has_value()) {
// cx_color_name.value() -> "BLUE"
// color_name.value() -> "BLUE"
}
```
* String to enum
```cpp
// String enum name to enum variable.
auto color = magic_enum::enum_from_string<Color>("GREEN");
constexpr auto color = magic_enum::enum_from_string<Color>("GREEN");
if (color.has_value()) {
// color.value() -> Color::GREEN
}