1 Dec
2010
1 Dec
'10
8:12 p.m.
On Wed, Dec 1, 2010 at 12:48 AM, John B. Turpish
On Tue, Nov 30, 2010 at 10:06 AM, Robert Jones
wrote: Something that just returns it's single argument, eg.,
template <typename T> T identity( T t ) { return t; } ... (I need this because I need to pass a function object which simply returns an object I already have - maybe I've missed a more obvious method?)
The way you wrote it, wouldn't that actually return a temporary that is a copy of the object you already have? (rather than a const T& or something)
I guess most compilers would apply some form of elision/return value optimization? Cheers, F.