Sujet : Re: constexpr keyword is unnecessary
De : thiago.adams (at) *nospam* gmail.com (Thiago Adams)
Groupes : comp.lang.cDate : 13. Oct 2024, 22:12:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vehd3l$r08h$1@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
Em 10/13/2024 3:21 PM, Kaz Kylheku escreveu:
On 2024-10-13, Thiago Adams <thiago.adams@gmail.com> wrote:
What I am suggesting again is remove the keyword constexpr. make const
do that.
Related:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3333.htmI believe clang is already extending const power in more scenarios.
https://godbolt.org/z/h1ha5jfPnstruct X{
int i;
};
int main()
{
const struct X x2 = (struct X){.i=1};
static_assert(x2.i == 1);
}
https://godbolt.org/z/EW797PjEqstruct X{
int i;
};
int main()
{
const int a[] = {1, 2};
const struct X x2 = (struct X){.i=a[0]};
static_assert(x2.i == 1);
}