Mapping enum values to strings in C++
问题 Is there a way to, at runtime, map the value of an enum to the name? (I'm building with GCC.) I know GDB can do it and I'm willing to use something that's unportable and mucks with debug data. Edit: I'm looking for a solution that doesn't require modifying the original enum declaration nor hand copying all the values out in a mapping function. I already know how to do both of those. Effectively; I want a function that does whatever GDB does when it formats runtime enum values. 回答1: If you don