Eric Lemings wrote:
>
>
>> -----Original Message-----
>> From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor
>> Sent: Wednesday, July 02, 2008 5:17 PM
>> To: dev@stdcxx.apache.org
>> Subject: Re: error on tuple copy ctor
>>
>> Eric Lemings wrote:
>>>
> ...
>> AFAICS, this is the same as S(S&&).
I was wrong. S::S(S&&&) is the same thing as S::S(S&). I.e., "an
rvalue reference to an lvalue reference" collapses into a plain
old (lvalue) reference.
> Doesn't preferring a template
>> over an ordinary function with the same signature seem wrong?
>
> Wrong, possibly. Certainly not what one might expect.
I *think* I understand the rules now. Consider the example
in [temp.deduct.call], p3 of the latest WP (N2691):
template void f (T&&);
int i;
int j = f (i);
Argument deduction instantiates "f(T&&&)" which after
collapsing the references is the same as f(T&). I.e.,
we end up calling a specialization of f for int&, which is
a better match than an overload (or specialization) of f for
int&&, since i is an lvalue and binding a (named) lvalue to
an rvalue (reference) involves an lvalue to rvalue conversion.
In fact, the generated specialization of f is an exact
match for i.
Martin