Copy elision is the construction of an object directly in its final place, which removes a copy or move. Since C++17 it is guaranteed when an object is initialised from a prvalue of its type: T x = T(...), T x = f() with f returning a prvalue, and return T(...);. When a function returns a named local object, the compiler may also build it in the caller’s object (the named return value optimisation), but is not required to; if it does not, the return moves.
Computer Science · Glosario