Liste des Groupes | Revenir à cl c |
Em 10/19/2024 6:48 PM, Keith Thompson escreveu:[...]
My reasons for not wanting `const int c = 2;` to make c a constant>
expression have nothing to do with any theoretical difference in
generated code.
>
My reason is that "const" and "constant" are two almost entirely
distinct concepts. Conflating them makes the language more confusing.
Making the name of a "const" object a constant expression adds no new
capabilities beyone what we already have with "constexpr".
I see some differences but not enough to justify a new keyword and I
think it also generates confusion. So it is a matter of choosing what
that of confusion we want.
For instance, in file scope,
>
const int a = 1;
constexpr int b =1;
>
In both cases, because it is file scope, a and b need to be
initialized with constant expressions. I don´t see anything more
special in b compared with a to make any distinction.
Les messages affichés proviennent d'usenet.