Originally the rvalue reference proposal said that the transformation happens if P
is "an rvalue reference type". However, a defect report later noticed
Additionally, consider this case:
template <class T> void f(const T&&);
...
int i;
f(i);
If we deduce T
as int&
in this case then f(i)
calls f<int&>(int&)
, which seems counterintuitive. We prefer that f<int>(const int&&)
be called. Therefore, we would like the wording clarified that the A&
deduction rule in 14.8.2.1 [temp.deduct.call] paragraph 3 applies only to the form T&&
and not to cv T&&
as the note currently implies.
There appears to have been a time period where const T &&
, with T
being U&
, was transformed to const U&
. That was changed to be consistent with another rule that says that const T
, where T
is U&
would stay U&
(cv-qualifiers on references are ignored). So, when you would deduce T
in above example to int&
, the function parameter would stay int&
, not const int&
.
In the defect report, the reporter states "We prefer that f<int>(const int&&)
be called", however provides no reason in the defect report. I can imagine that the reason was that it seemed too intricate to fix this without introducing inconsistency with other rules, however.
We should also keep in mind that the defect report was made at a time where rvalue references could still bind to lvalues - i.e const int&&
could bind to an int lvalue. This was prohibited only later on, when a paper by Dave & Doug, "A Safety Problem with RValue References", appeared. So, it seems to me that a deduction that works (at that time) was worth more than a deduction that simply was counter intuitive and dropped qualifiers.