Honestly, iterating all the values with template for (which is instantiating a bunch of branches, not actually iterating) is probably the best way to do this.
We have tools to do a LOT more than getting a string from an enum value because this was implemented like this. It may make the trivial case a bit less trivial but it makes more complicated cases possible.
It's like saying "why do we have to build a string formatting system to write std::print("Hello World");". Simply printing hello world isn't the point. simply printing the value of an enum isn't the point of reflection, it's just something reflection can do easily.
View all comments
Show parent comment
5
u/RoyAwesome May 12 '26
Honestly, iterating all the values with
template for(which is instantiating a bunch of branches, not actually iterating) is probably the best way to do this.We have tools to do a LOT more than getting a string from an enum value because this was implemented like this. It may make the trivial case a bit less trivial but it makes more complicated cases possible.
It's like saying "why do we have to build a string formatting system to write
std::print("Hello World");". Simply printing hello world isn't the point. simply printing the value of an enum isn't the point of reflection, it's just something reflection can do easily.