Boost logo

Boost :

Subject: Re: [boost] rvalue ref best practices?
From: Nevin Liber (nevin_at_[hidden])
Date: 2012-06-13 14:41:32


On 12 June 2012 18:08, Ion Gaztañaga <igaztanaga_at_[hidden]> wrote:

> If I modify my implementation because I no longer need the internal copy
> (e.g. the copy was required by an internal function/helper function), I
> can't optimize the code and change the signature of the function to take a
> reference, as name mangling changes and I'll need to recompile the caller.
> If I offer both lvalue and rvalue reference variants I type a bit more but
> I can safely change the implementation.

On 13 June 2012 12:48, Mathias Gaunard <mathias.gaunard_at_[hidden]> wrote:

> On 06/13/2012 04:12 PM, Peter Dimov wrote:
>
> Or 2^N overloads, if there's more than one argument to consume.
>>
>
> In which case, make your constructor a template so that all those
> overloads get generated through template instantiation, making use of the
> template type resolution mechanism specifically designed for perfect
> forwarding.
>

But if your constructor is a template, that code resides in the header, so
don't you end up recompiling the caller anyway?

-- 
 Nevin ":-)" Liber  <mailto:nevin_at_[hidden]>  (847) 691-1404

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