incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <>
Subject Re: error on tuple copy ctor
Date Thu, 03 Jul 2008 00:51:31 GMT
Eric Lemings wrote:
>> -----Original Message-----
>> From: Martin Sebor [] On Behalf Of Martin Sebor
>> Sent: Wednesday, July 02, 2008 5:17 PM
>> To:
>> 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 [], p3 of the latest WP (N2691):

    template <class T> void f (T&&);

    int i;
    int j = f (i);

Argument deduction instantiates "f<int&>(T&&&)" which after
collapsing the references is the same as f<int&>(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<int&> is an exact
match for i.


View raw message