I am trying to convert an C++ identifier into a string. So if I have the following enum
enum Example {
EXAMPLE0,
EXAMPLE1
};
I am currently using a little inline function to realise the conversion:
inline std::string example_to_string(Example e) {
switch (e) {
case EXAMPLE0: return "EXAMPLE0"; break;
case EXAMPLE1: return "EXAMPLE1"; break;
default: return ""; break;
}
}
Is there a better way to do this? I have looked everywhere but didn't find anything. In the case above its okay. However, I have larger enums with many identifiers and would love to automate the process.