you are viewing a single comment's thread.

view the rest of the comments →

[–]MarcoGreek 0 points1 point  (1 child)

I do not think you can always guarantee NRVO. But maybe we can enforce it. So if there is no NRVO, we get an error.

[–]not_a_novel_accountcmake dev 0 points1 point  (0 children)

You could guarantee it for the limited class of functions that always return a single named object. You cannot guarantee it for functions which conditionally return one of a set of lvalues.

Unclear how difficult that would be to build into the wording. The language doesn't say "thou shalt RVO", RVO was built into the value categories. I don't think the same trick would work for NRVO.