C++ Logo


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:17:27 -0300
Does it work for cases where there are multiple named objects?

std::mutex foo(bool b)
    std::mutex m1, m2;
    if (b)
        return m1;
        return m2;

Em sex., 11 de ago. de 2023 10:02, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> escreveu:

> I've written a paper on ensuring the elision of a move/copy operation
> when returning a class by value from a function. C++17 already ensures
> elision when it comes to Return Value Optimisation (RVO), but not when
> it comes to Named Return Value Optimisation (NRVO).
> Of the 27 platforms this is tested and working on, I've had to write
> implementations in assembler for 4 of them: arm64, m68k, hppa, sh4.
> I could spend another month on this paper but I need to think
> "progress not perfection" and release a draft. In the next draft I'll
> deal with:
> (1) Ensuring correct use of 'noexcept' with
> std::function<void(void)noexcept>
> (2) Use concepts or SFINAE to make sure the class is nonmovable
> and noncopyable
> No. 2 is important because some of the calling conventions will return
> in registers unless the class is unmovable and uncopyable.
> I have 27 workflows up on Github which show it tested and working on
> various operating systems, compilers and CPU's:
> https://github.com/healytpk/nrvo
> The PDF file of my paper is attached to this email, and you can also
> download the latest draft from:
> http://virjacode.com/downloads/nrvo/paper_nrvo_latest.pdf
> File attached: paper_nrvo_draft001.pdf
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-08-11 13:17:40