Return Value Optimization: specification, requirements?
belka at caraus.de
Sat Feb 2 11:26:02 UTC 2019
On Saturday, 2 February 2019 at 09:58:25 UTC, XavierAP wrote:
> I've heard here and there that D guarantees RVO, or is even
> specified to do so...
> Is it spelled out in the language specification or elsewhere? I
> haven't found it.
The D spec is often not the right place to look for the
specification of the D language.
But yes D guarantees RVO. DMD frontend has RVO-tests and
functions like std.algorithm.mutation.move rely on RVO and
wouldn't work (and be possible) without RVO.
> Do you know the exact requirements for RVO or NRVO to be
> possible in theory, and to be guaranteed in practice in D? Does
> it depend only on what is returned, or does it depend how it's
It is just plain RVO, I'm not aware of any differences for
different types or kinds of cunstruction.
> I know I can debug to find out case by case, but that's the
> kind of C++ stuff I want to avoid... I want to know the
More information about the Digitalmars-d-learn