top | item 32248121

(no title)

soylentgraham | 3 years ago

Any chance anyone knows how this compares to magic_enum (which iirc is c++17+ only? Though c++17 seems to be supported every platform i work on now)

No string -> enum would probably be a non-starter for me though

discuss

order

mehrdadn|3 years ago

To my knowledge magic_enum has some severe limitations; for example, it limits the range of enum values, it cannot handle duplicate enum values, it uses compiler-specific hackes, etc. There is a list of them outlined at [1]. Before writing this library I did take a look around for existing ones (there's also wise_enum [2] for example), but I couldn't find any that supports all of the functionality implemented here.

Update: And I'm glad to see interest! I just updated the repo to add a parse_enum function for converting strings to enums as well.

[1] https://github.com/Neargye/magic_enum/blob/master/doc/limita...

[2] https://github.com/quicknir/wise_enum