Sure it can - but you know that - a compile time computation can be a run time constant. There’s loads of reasons to want constant values built out of compile-time computation. You haven’t had to write any high performance code?
Start with something like
constexpr float angle_threshold = 45.0f;
constexpr float degToRad = M_PI / 180.0f;
constexpr float x_threshold = cosf( angle \* degToRad );
The nice thing about having this be an expression is it’s semantic, and I can tune my angle in degrees, not have some raw number that isn’t adjustable.Maybe I need a small table of these, suddenly running a little code at compile time looks great. Doing it during compilation is a lot nicer than having a script dependency and having to write a build step for it.
The bigger issue with constexpr specifically is that it doesn’t actually guarantee compile time evaluation…