C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Declare as constinit, define as constexpr?

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Tue, 12 Dec 2023 20:00:59 +0000
On Tue, 2023-12-12 at 16:48 -0300, Thiago Macieira via Std-Proposals
wrote:
> On Tuesday, 12 December 2023 16:37:50 -03 Ville Voutilainen wrote:
> > > If you want this to change, it needs to be a paper.
> >
> > Sure. Just another lil' addition: quite like we can already write
> >
> > extern const int x;
> >
> > constexpr int x = 42;
>
> constexpr are implicitly inline, so these two don't actually work
> independently. At a minimum you must ensure that the former is
> visible before
> the latter. Or write extern constexpr.

constexpr is not implicitly inline for namespace scope non-template
variables.

>
> > it seems eminently reasonable to be able to write
> >
> > extern constinit const int x;
> >
> > constexpr int x = 42;
>
> What's the point of an extern constinit without the initialisation?
> One does
> not need to know how to initialise this variable to use it. And
> without the
> initialiser, how would the constinit keyword make any difference in
> this line?
>
> So, is this different from the case above?
>
> > The "we can already write" bit convinces me that we should just do
> > this. But yes, agreed, as I said, a paper,
> > please, not an issue submission. Core would need to punt the issue
> > to
> > Evolution to be handled as an extension
> > anyway, so better just write a paper and send it to Evolution.
>
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering
>
>
>

Received on 2023-12-12 20:01:06