3 ms·
constexpr on a variable declaration does that (i.e. it's still superfluous on function declarations, which is where it clutters code by far the most). But even
by dataflow 5y ago
constexpr on a variable declaration does that (i.e. it's still superfluous on function declarations, which is where it clutters code by far the most). But even for that, there was already std::integral_constant which would've forced this, and they could've just updated it to C++20 via template<auto Value> static const auto constant = Value; if they really wanted to. Or added an [[attribute]] for variable declarations, just like how we have [[likely]] etc. No need to introduce a whole new keyword for this, especially not in a ton of other contexts.
- electroly 5y agoThose suggestions, honestly, don't sound better than the keyword to me. I think you're taking it as a given that if a keyword can be avoided, it must be avoided, but I don't fundamentally agree with that at all.
- dataflow 5y agoI mean your (only?) argument for the constexpr keyword at this point is "it can be a keyword and I feel like it should be, even when I acknowledge it's redundant" then by all means go ahead. Personally I don't think that's a good way to do language design, but I can't argue with subjective feelings and aesthetics and I was never intending to. I'm pretty sure that's not one of the bases on which it made it into the standard though, and those are what I'm trying to address.