Boost logo

Boost :

Subject: Re: [boost] rvalue ref best practices?
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2012-06-11 07:14:11

On Sun, Jun 10, 2012 at 3:24 PM, Mathias Gaunard
<mathias.gaunard_at_[hidden]> wrote:
> On 09/06/2012 22:49, Giovanni Piero Deretta wrote:
>> As per ,
>> if the function is likely to consume or copy the parameter, the best
>> solution is to pass by value. This means you'll only need to provide a
>> single overload.
> That is not true. This technique only applies if you need to make a copy at
> an arbitrary place, not in a particular subobject.

Apart from the fact that "an arbitrary place" in your sentence would
seem to cover anything, to what subobject are you referring to? The
only thing I can think of is assignment operators of derived classes
that need to forward to base classes. In that case I agree that pass
by value does not work very well (I usually still use pass by value,
but implement operator= in term of swap, which forwards to the base
class swap).


Boost list run by bdawes at, gregod at, cpdaniel at, john at