Sujet : Re: constexpr keyword is unnecessary
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.cDate : 11. Oct 2024, 20:30:02
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vebubq$3p8oj$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
Em 10/11/2024 4:17 PM, Bonita Montero escreveu:
Am 11.10.2024 um 20:11 schrieb Thiago Adams:
constant expression make sense in C. It is not new, it is very old.
const has a definition and it allows non compile-time evaluated
variables.
yes. but?
What I am suggesting again is remove the keyword constexpr. make const do that.
Just to remember C++ was already like that before constexpr. In c++ const could be used as constant expressions.
What C++ could not ensure is that global variables would have a compile time initialization.
In C all global variables are initialized in compile time.
For local variables like...
const int i = ... ;
the compiler must evaluate the initialization expression if it can be computed in compile time then i is "constexpr" does not matter if it have or not the constexpr keyword.