Boost logo

Boost :

Subject: Re: [boost] rvalue ref best practices?
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-06-12 12:02:19


on Mon Jun 11 2012, "Simonson, Lucanus J" <lucanus.j.simonson-AT-intel.com> wrote:

>>In C++03, func_modify() would be the choice of performance-conscious
>> programmers.
>>In C++11, as we've told that "return by value is free" and the syntax
>> is more elegant, I'm afraid everyone will write "func_factory".
>>And func_factory() is less efficient when used in loops and other
>> situations where resource reusing is essential.
>
> If you aren't in a loop you probably don't care about performance. I
> know I intend to stick with pass by reference. It is very useful to
> clearly understand and be able to easily reason about the ownership of
> resources in a program.

If that's your primary concern, why on earth wouldn't you use
pass-by-value?

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk