C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Copy-construct, move-construct, and PR-construct

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Wed, 23 Aug 2023 18:10:33 +0300
On Wed, 23 Aug 2023 at 18:07, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:

> If we are to be able to put a PRvalue inside an std::optional in
> C++26, then there's two ways of going about it:
> Strategy 1: Give std::optional a new member function such as
> 'PRemplace', to which you pass a function pointer to allow it to
> invoke the function and put the return value in a pre-allocated
> buffer.
> Strategy 2: Give us PR-construction and PR-assignment.
>
> I'm leaning toward Strategy 2.

I wonder what happened to the third strategy, which is to pass as the
argument of existing emplace an object
that will perform the function invocation in its conversion operator
to the optional's element type, which then
allows doing this without any library or language changes, and has
field experience as a solution to this problem.

Received on 2023-08-23 15:10:47