This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
An rvalue reference type involving a template parameter receives special treatment in template argument deduction in 13.10.3.2 [temp.deduct.call] paragraph 3:
If P is an rvalue reference to a cv-unqualified template parameter and the argument is an lvalue, the type “lvalue reference to A” is used in place of A for type deduction.
Does this rule apply when the parameter type involves an alias template instead of using a template parameter directly? For example:
template<class T> using RR = T&&;
template<class T> struct X {};
template<class T> struct X<T&&>; // Leave incomplete to possibly trigger an error
template<class T> void g(RR<T> p) {
X<decltype(p)> x;
}
int main() {
int x = 2;
g(x);
}
There is implementation variance on the treatment of this example.
Additional note (October, 2013):
It was observed that the type of the parameter would be the same whether written as T&& or as RR<T>, which would require that deduction be performed the same, regardless of how the type was written.
Rationale (September, 2013):
Because the types of the function parameters are the same, regardless of whether written directly or via an alias template, deduction must be handled the same way in both cases.