Why are by-value parameters excluded from NRVO?

Here’s why copy elision doesn’t make sense for parameters. It’s really about the implementation of the concept at the compiler level. Copy elision works by essentially constructing the return value in-place. The value isn’t copied out; it’s created directly in its intended destination. It’s the caller who provides the space for the intended output, and … Read more

Understanding return value optimization and returning temporaries – C++

In two first cases RVO optimization will take place. RVO is old feature and most compilers supports it. The last case is so called NRVO (Named RVO). That’s relatively new feature of C++. Standard allows, but doesn’t require implementation of NRVO (as well as RVO), but some compilers supports it. You could read more about … Read more

Why does std::move prevent RVO (return value optimization)?

The cases where copy and move elision is allowed is found in section 12.8 ยง31 of the Standard (version N3690): When certain criteria are met, an implementation is allowed to omit the copy/move construction of a class object, even if the constructor selected for the copy/move operation and/or the destructor for the object have side … Read more