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:
parent
8ddfae18d1
commit
9dc22008a7
4 changed files with 25 additions and 36 deletions
|
|
@ -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>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue