We all know that
Foo returnAFoo()
{
return Foo();
}
will be compiled with optimization of the return value, so a copy of the value will not be accepted, even if the copy constructor Foohas side effects. But there will be
Foo returnAFoo()
{
Foo f = Foo();
return f;
}
also? The second design may be useful when debugging. But can I discard important optimization? Perhaps I need to write an explicit move constructor?
source
share