Lets say I have this piece of code:
class Base {
public:
void f() {}
private:
int n;
};
Base foo()
{
Base b;
// processing
return b;
}
Base doesn't have a copy constructor defined and looking at its members the compiler won't synthesise one.
Is Named Return Value (NRV) optimisation applied for this code ? What is the exact rule when a compiler would apply NRV ?