![A special way to convert string<->enum in C++ using X Macro technique and template specialization : r/cpp A special way to convert string<->enum in C++ using X Macro technique and template specialization : r/cpp](https://external-preview.redd.it/0JPji8Uz6PfvcO587BQ7LmFGwvo3ootUT7yIHHF0ixk.jpg?width=1080&crop=smart&auto=webp&s=14aef6b3ad7145c47bfa675e121cb0246ead5eed)
A special way to convert string<->enum in C++ using X Macro technique and template specialization : r/cpp
![Marcin Moskala on X: "When I work with enums, I like to define enumValueOfOrNull, which returns null when there is no enum value corresponding to the name, instead of throwing an exception. Marcin Moskala on X: "When I work with enums, I like to define enumValueOfOrNull, which returns null when there is no enum value corresponding to the name, instead of throwing an exception.](https://pbs.twimg.com/media/FlI6D4gWIAEBzIh.jpg)
Marcin Moskala on X: "When I work with enums, I like to define enumValueOfOrNull, which returns null when there is no enum value corresponding to the name, instead of throwing an exception.
![Maintenance-free Enum to String in Pure C++ with "Better Enums" - Engines and Middleware - Tutorials - GameDev.net Maintenance-free Enum to String in Pure C++ with "Better Enums" - Engines and Middleware - Tutorials - GameDev.net](https://uploads.gamedev.net/783592500a1d7eda3f481e7169615eb3.png)