CppCoreGuidelines icon indicating copy to clipboard operation
CppCoreGuidelines copied to clipboard

Improve reasoning and examples for F.48

Open eisenwave opened this issue 2 years ago • 0 comments

With guaranteed copy elision, it is now almost always a pessimization to expressly use std::move in a return statement.

The reasoning in F.48 is misleading because it only refers to guaranteed copy elision, but the example listed underneath shows NRVO, for which this elision is not guaranteed.

I think it the reasoning is much better if it is made clear to the reader that a return statement will always move local variables. It is also helpful to distinguish between RVO and NRVO in the example, as the two have optimization differences.

eisenwave avatar Jun 23 '23 22:06 eisenwave