TITLE: returning objects by value efficiently (Newsgroups: comp.lang.c++.moderated) [ This is a well-known technique for improving efficiency when you have to return an object by value. -adc ] AUTHOR: clamage@Eng.Sun.COM (Steve Clamage), 2 May 96 [...] If you write code like this: T f() { T val; ... return val; } the compiler is obliged to create and destroy the local variable "val" and return a copy. (Actually, there is currently some discussion in the C++ Committee about relaxing that rule, but I don't know what the outcome will be. The difficulty is the violence it would do to the C++ object model and to the meaning of sequence points.) But if you can write the code like this: T f() { ... return T(...); } the compiler is allowed to construct the returned value directly in the target, possibly avoiding an extra copy.