This is one of the places where I get *REALLY* confused - the 'real' code
has multiple returns. Apologies: I should have included this psuedo code
in the original example. It looks like this.
<snippet>
// v is populated somewhere else
typedef vector
I don't understand C++ well enough to grok a compiler's interpretation of the code, but I seems like I'm creating an extra copy for the return. <snip>
Logically the local variable is copied to the the caller, but since the type of the returned expression matches the return type the compiler is allowed to optimise away that copy, even though the return type has a user-defined copy constructor. In this case you always return a certain named variable, so the compiler can arrange to construct it in the memory location where the caller expects the returned value. This is called the named-return-value optimisation, or NRVO. Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/