Is NRVO part of the spec?
Daniel Murphy via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 7 08:00:29 PST 2015
"Peter Alexander" wrote in message
news:gverkczeotvadwmdowdl at forum.dlang.org...
> Yes, you're right. I suppose what I mean is that it should be guaranteed
> that returning a local Lvalue by value should always be moved to the
> caller destination, rather than copied then destroyed.
>
> S foo() {
> S s;
> return s;
> }
> S s = foo(); // no destructors or postblits should be called here
>
> The spec needs to guarantee this, otherwise unary std.algorithm.move isn't
> guaranteed to work for non-copyable types.
Yeah, the spec needs to guarantee no copies. Kenji Hara has done some work
on this.
More information about the Digitalmars-d
mailing list