
On Fri, Apr 23, 2010 at 9:51 AM, Neil Groves
On Thu, Apr 22, 2010 at 11:43 AM, Robert Jones
wrote: Returning containers by value seems to be the 'right way' now, as RVO should sort out the copy elision.
I'm not convinced that this is the 'right way'. I find that for trivial examples the copy is optimized away, but that on many compilers at various levels of call depth the copy construction occurs causing a huge performance degradation. I suspect that the 'right way' is still by using references in C++03 and by using move constructors in C++0x.
This is concerning - anybody else have any experience to support this? My original remark was prompted by http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/ penned by Dave A. If compilers don't really do this consistently I need to write my code rather differently by default! - Rob.