There are a few limitations for magic_enums but I’ve never hit them in practice. I’m hoping that the Reflection TS will let this kind of thing be done without hacks eventually because it really is a joy to use. Most recently, I’ve used it with a command-line argument parser so I can just expose an enum as a flag type and the argument parser will permit any of the enum values with no additional code and bind that to an enum variable of the correct type that I provide to the argument parser.
__asm__("# test begin");
- this is a fun one, never seen it before. Great for comparing efficiency!I’m reminded of a much older technique: the X Macro (and also at Wikipedia).
Wow, that is a truly sick hack. (In the positive sense!) It would never have occurred to me to (ab)use
PRETTY_FUNCTION
that way.I am totally grabbing that magic_enums library — I’ve been wanting such functionality for ages.
There are a few limitations for
magic_enums
but I’ve never hit them in practice. I’m hoping that the Reflection TS will let this kind of thing be done without hacks eventually because it really is a joy to use. Most recently, I’ve used it with a command-line argument parser so I can just expose an enum as a flag type and the argument parser will permit any of the enum values with no additional code and bind that to an enum variable of the correct type that I provide to the argument parser./me shivers with delight