We all know that
Foo returnAFoo()
{
return Foo();
}
will be compiled with return value optimisation so a value copy will not be taken even if the copy constructor of Foo
has side effects. But will
Foo returnAFoo()
{
Foo f = Foo();
return f;
}
too? The second construct can be helpful when debugging. But am I throwing away an important optimisation in doing so? Perhaps I need to write an explicit move constructor?