Search⌘ K

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

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