Boost logo

Boost Users :

Subject: [Boost-users] Returning by value, was: [Range] non-const range reference
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2010-04-23 05:58:31


On Fri, Apr 23, 2010 at 9:51 AM, Neil Groves <neil_at_[hidden]>wrote:

>
> On Thu, Apr 22, 2010 at 11:43 AM, Robert Jones <robertgbjones_at_[hidden]>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.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net