Date: Sun, 27 Oct 2024 20:15:35 +0000
On 27/10/2024 20:03, Thiago Macieira via Std-Proposals wrote:
> On Sunday 27 October 2024 12:16:09 Pacific Daylight Time Lénárd Szolnoki via
> Std-Proposals wrote:
>> It's possible to effectively opt-in. Have a static constinit optional, and
>> do the initialisation dance yourself.
>
> Effectively, no, it isn't. That still registers the std::optional destructor on
> first use, so the guard variable and all the verification we've talked about is
> still present.
Eh, right. You want to put static constinit optional into namespace or
class scope, then do the initialization dance in your function.
I have no idea about the implications about destruction. I have a hunch
that this work-around is acceptable most of the time when you don't care
about thread-safe initialization of a particular static variable.
Lénárd
> On Sunday 27 October 2024 12:16:09 Pacific Daylight Time Lénárd Szolnoki via
> Std-Proposals wrote:
>> It's possible to effectively opt-in. Have a static constinit optional, and
>> do the initialisation dance yourself.
>
> Effectively, no, it isn't. That still registers the std::optional destructor on
> first use, so the guard variable and all the verification we've talked about is
> still present.
Eh, right. You want to put static constinit optional into namespace or
class scope, then do the initialization dance in your function.
I have no idea about the implications about destruction. I have a hunch
that this work-around is acceptable most of the time when you don't care
about thread-safe initialization of a particular static variable.
Lénárd
Received on 2024-10-27 20:15:41