C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 20 May 2024 10:43:00 +0100
On Mon, May 20, 2024 at 9:25 AM Frederick Virchanza Gotham wrote:
>
> ------ Step 3: Tell the compiler to take your optifunc and convert it
> into a NRVO function
>
> using Func2 = std::nrvo_from_optifunc(Func);


Rules for optifuncs that are converted by the compiler into NRVO functions:

Rule 1: If an optifunc returns before the argument is emplaced,
behaviour is undefined (or instead maybe throw "std::optifunc_empty").
Rule 2: If an exception is thrown and propagates outside the function
before the argument is emplaced, nothing special happens
Rule 3: If an exception is thrown and propagates outside the function
after the argument is emplaced, the argument is destroyed before the
exception propagates
Rule 4: Where Rule No. 3 is enforced, the argument is the last object
to be destroyed (irrespective of order of construction).

Received on 2024-05-20 09:43:14