4 ms·
Constexpr as a keyword which slowly applies in more places over decades is technically indefensible. It has generated an astonishing quantity of work for the co
by JonChesterfield 1y ago
Constexpr as a keyword which slowly applies in more places over decades is technically indefensible. It has generated an astonishing quantity of work for the committee over the years though which in some sense is a win.
I think there's something in the psychology of developers that appreciates the byzantine web of stuff which looks like it will work but doesn't.
- zombot 1y agoHow is it technically indefensible?
- JonChesterfield 1y agoInstead of annotating functions with "maybe this will be evaluated by the compiler", you can not do that, and the compiler will still evaluate them as a QoI thing. The usual justification is that it's a helpful comment for developers. Consteval being much the same idea. And constinit also the same idea. An alternative design would be "global initialisations are evaluated at compile time where possible, like everything else, and you don't need to annotate anything to get that". Which would require exactly the same compiler work as constexpr but wouldn't leave that word scattered around codebases in similar fashion to register.