C++ Logo


Advanced search

Re: [std-proposals] Return Value Optimisation whenever you need it (guaranteed elision)

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Fri, 11 Aug 2023 22:13:42 -0400
On Fri, Aug 11, 2023 at 3:46 PM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> But unrelated to NRVO, the function 'PutRetvalIn' which I describe in my paper achieves something that isn't currently possible in the language. We /should/ be able to put a function's return value on the heap or inside a global std::optional.

But there already is. This:

PutRetvalIn(p)(Func)(5, 6.3, 8.4f);

Is functionally equivalent to:

p = new(p) mutex(Func(5, 6.3, 8.4f));

There's no equivalent for `optional`, but that's nonsensical.

Received on 2023-08-12 02:13:55