Copy elision

Beyond that, the standard also describes a few situations where copying can be eliminated even if this would alter the program's behavior, the most common being the return value optimization (see below).

C++17 Provides for "guaranteed copy elision", a prvalue is not materialized until needed, and then it is constructed directly into the storage of its final destination.

[10][2] The term return value optimization refers to a special clause in the C++ standard that goes even further than the "as-if" rule: an implementation may omit a copy operation resulting from a return statement, even if the copy constructor has side effects.

Returning a larger object of class type may require more expensive copying from one memory location to another.

In the early stages of the evolution of C++, the language's inability to efficiently return an object of class type from a function was considered a weakness.

One common case is when a function may return different named objects depending on the path of execution:[11][14][16]