C++ Logo

std-proposals

Advanced search

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

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Sat, 12 Aug 2023 19:57:56 +0100
On Sat, 2023-08-12 at 08:43 -0700, Thiago Macieira via Std-Proposals
wrote:
> On Saturday, 12 August 2023 08:33:27 PDT Thiago Macieira via Std-
> Proposals
> wrote:
> > So I'll help. Of what it provided, this is the only one that is a
> > currently
> > accepted and acceptable syntax:
> >
> > int nrvo monkey;
> >
> > With nrvo being a new keyword, possibly context-sensitive like
> > final and
> > override.
>
> You know what would help here? Not having a new keyword. So if we
> could reuse
> an existing keyword in a way that it can't today be used, it could
> convey the
> meaning we need.
>
> And there is such a keyword: return.
>
> int return monkey;
>
> This would probably require that the keyword not appear in the first
> position,
> so as to not be confused for a return statement.

In an other forum I floated the idea of using the phrase "for return"
here. It got mixed reception.

So something like:

Widget create_widget() {
  for return Widget w;
  cook(w);
  return w;
}

Cheers,
Lénárd

>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering
>
>
>

Received on 2023-08-12 18:58:02