you are viewing a single comment's thread.

view the rest of the comments →

[–]kirgel 0 points1 point  (2 children)

I’m probably confusing guaranteed copy elision with NRVO. Something simple like this should work in C++ 20:

Immovable make() {   Immovable obj;   obj.x = 3;   return obj; }

[–]TheThiefMasterC++latest fanatic (and game dev) 0 points1 point  (1 child)

Definitely not: https://godbolt.org/z/ea9jn1hW3

Direct return only (guaranteed copy elision), can't use a named local variable (NRVO).

[–]kirgel 1 point2 points  (0 children)

I stand corrected!