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

enum_name returns string_view

This commit is contained in:
terik23 2019-04-21 20:52:14 +05:00
parent 8ddfae18d1
commit 9dc22008a7
4 changed files with 25 additions and 36 deletions

View file

@ -30,9 +30,7 @@ int main() {
// Enum variable to string name.
Color c1 = Color::RED;
auto c1_name = magic_enum::enum_name(c1);
if (c1_name.has_value()) {
std::cout << c1_name.value() << std::endl; // RED
}
std::cout << c1_name << std::endl; // RED
// String enum name sequence.
constexpr auto color_names = magic_enum::enum_names<Color>();