Date: Tue, 28 Nov 2023 12:34:21 +0000
On Tue, 28 Nov 2023 at 12:01, Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Let's say I have a variable defined as follows:
>
> optional< future<bool> > var;
>
> And let's say I assign the return value of an invocation of 'async' to
> it. Later I wait on the future object for 3 seconds, and it's not
> ready after 3 seconds so I assume my thread is frozen and so I give up
> on it.
>
> I want to reuse my 'var' variable, but I don't want to call the
> destructor of the future object. In this circumstance, it would be
> nice to be able to do:
>
> var.abandon();
>
> The member function "abandon" would set the 'var' object to having no
> value -- but it doesn't call the destructor of T.
>
You can just move the contained value to another object which you don't
destroy. This doesn't need to be added to std::optional.
std-proposals_at_[hidden]> wrote:
> Let's say I have a variable defined as follows:
>
> optional< future<bool> > var;
>
> And let's say I assign the return value of an invocation of 'async' to
> it. Later I wait on the future object for 3 seconds, and it's not
> ready after 3 seconds so I assume my thread is frozen and so I give up
> on it.
>
> I want to reuse my 'var' variable, but I don't want to call the
> destructor of the future object. In this circumstance, it would be
> nice to be able to do:
>
> var.abandon();
>
> The member function "abandon" would set the 'var' object to having no
> value -- but it doesn't call the destructor of T.
>
You can just move the contained value to another object which you don't
destroy. This doesn't need to be added to std::optional.
Received on 2023-11-28 12:34:36