4 ms·
Sounds like you’re close to justifying the existence of constexpr, that sounds similar to the summary of what it’s for. I wasn’t trying to justify the existenc
by dahart 2y ago
Sounds like you’re close to justifying the existence of constexpr, that sounds similar to the summary of what it’s for.
I wasn’t trying to justify the existence of constexpr, I was justifying the existence of compile time constant computation in response to what @38_14 said about there being no such thing as a computation that’s constant, which is, you probably agree, a bit silly. The top comment didn’t seem to be talking about constexpr specifically since the point was about computation and they said “constexpr and similar” which I assume includes const, consteval, as well as the general idea of baking the results of compute at compile time.
HN isn’t really the right place to demand justifying the existence of constexpr, but its existence has been debated at length by people who know a lot more about C++ than me. If you want to read about why it exists, there are lots of good places like cppreference.com and isocpp.org and even stack overflow.