mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-10 23:44:29 +00:00
15 lines
423 B
C++
15 lines
423 B
C++
#include <magic_enum.hpp>
|
|
|
|
#include <cstdlib>
|
|
|
|
enum class Color : int { RED = -10, BLUE = 0, GREEN = 10 };
|
|
|
|
int main() {
|
|
auto res1 = magic_enum::enum_name(Color::RED);
|
|
auto res2 = magic_enum::enum_cast<Color>("BLUE");
|
|
auto res3 = magic_enum::enum_cast<Color>(10);
|
|
|
|
bool success = (res1 == "RED") && (res2.value() == Color::BLUE) && (res3.value() == Color::GREEN);
|
|
|
|
return success ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
}
|