...

/

Named Return Value Optimization

Named Return Value Optimization

Here we learn about how compilers use NRVO and Eliding to optimize.

Compilers and NRVO

Compilers are even smarter, and they can el​ide in cases when you return a named object - it’s called Named Return Value Optimization - NRVO

Press + to interact
Test Create()
{
Test t;
// several instruction to initialize 't'...
return t;
}
auto n = Create(); // temporary will be usually elided
...