C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 11 Aug 2023 14:02:00 +0100
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

Received on 2023-08-11 13:02:18