C++ Logo

std-proposals

Advanced search

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

From: Breno Guimarães <brenorg_at_[hidden]>
Date: Fri, 11 Aug 2023 10:34:41 -0300
I completely misunderstood the proposal. I thought you were just proving
it's possible to be done, thus the compiler should do it. But your idea is
to propose a function to do this as a library feature right?
In that case, it loses the appeal since I have to do transformations
manually. If the compiler can do it, why should we do it manually?

On Fri, Aug 11, 2023 at 10:21 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:

> On Fri, Aug 11, 2023 at 2:17 PM Breno Guimarães <brenorg_at_[hidden]> wrote:
> >
> > Does it work for cases where there are multiple named objects?
> >
> > std::mutex foo(bool b)
> > {
> > std::mutex m1, m2;
> > if (b)
> > return m1;
> > else
> > return m2;
> > }
>
>
> Since a mutex can neither be moved nor copied, you would have to do
> something like:
>
> void foo2(std::mutex *const p, bool const b)
> {
> if ( b )
> ::new(p) std::mutex( ............... );
> else
> ::new(p) std::mutex( ............... );
> }
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-08-11 13:34:53