Replies: 1 comment
-
What you are asking for is enum reflection. Abseil won't be implementing that. https://github.com/Neargye/magic_enum is a library that I know of that does that. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The flags library has pretty good support for enum valued flags via the
AbslParseFlag
andAbslUnparseFlag
extension points. In the course of maintaining a codebase that uses it, one thing that came up is divergence between the manually written help message and the set of enum values. I.e.,As you can imagine, if I add
kYellow
tomy_ns::MyEnumType
and corresponding support inAbslParseFlag
andAbslUnparseFlag
, the help message will not be updated. I have to grep the entire codebase for all uses of this enum as a flag and update the error messages.I'd like to explore the design space for synthesizing the help message automatically. Ideally, it would take advantage of
AbslUnparseFlag
to iterate over all enum values (!) and return a string help message, potentially with a preamble and epilogue.As I type this, I realize that the developer could of course manually do this as:
Beta Was this translation helpful? Give feedback.
All reactions