What is the proper way to return an object from a C++ function?

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.

Leave a Comment