veselink1 / refl-cpp

Static reflection for C++17 (compile-time enumeration, attributes, proxies, overloads, template functions, metaprogramming).
https://veselink1.github.io/refl-cpp/md__introduction.html
MIT License
1.06k stars 77 forks source link

Is there a way to inspect enum cases? #16

Closed eliemichel closed 4 years ago

eliemichel commented 4 years ago

Sorry to ask questions, I'm just having hard time reading the code, and trial and error is tough with meta-programming... Is there a way to list as strings the enum cases? Basic application would be auto-generating debug function that displays an enum as human-readable text.

veselink1 commented 4 years ago

That is quite alright. The documentation is very lacking at the moment and I am looking into improving that in the future.

Reflecting enums is currently not supported by refl-cpp. The reason being that member_descriptors internally hold constexpr pointers to a field/function.

Have you considered something like magic_enum which uses a different type of trickery and does not require you to manually type out the names of fields?

eliemichel commented 4 years ago

Oh nice this magic_enum is what I'm looking for here :)