
(i know i have been advocating pass-by-value, but....) On 13/giu/2012, at 19.41, Nevin Liber <nevin@eviloverlord.com> wrote:
On 12 June 2012 18:08, Ion GaztaƱaga <igaztanaga@gmail.com> 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@ens- lyon.org> 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?
You can have a thin template forwarding to a single externally compiled implementation using for example rvalue references for all parameters. The template would copy or move depending on the actual parameter type. -- gpd