I am confused between :
I am looking for the proper way to return an object from a C++ function, in basic C++ (no library handling pointers and freeing memory automatically). I want to know how this is supposed to be done.
Thank you
Modern compilers typically implement the (Named) Return Value Optimization, by which the copy you reference (and would logically expect) is not done.
Ever since Visual Studio 2005 (VC++ 8.0) I don't think twice about returning objects.
What about std::auto_ptr
from <memory>
? Or if C++0x is concerned std::unique_ptr
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With