#include <iostream>
using namespace std;
template <typename T>
void Foo(T&& a) { }
int main() {
int w=1;
Foo<int*>(&w);//why no gg?
int *w2;
Foo<int*>(w2);//why gg?
// your code goes here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0ZW1wbGF0ZSA8dHlwZW5hbWUgVD4Kdm9pZCBGb28oVCYmIGEpIHsgIH0KaW50IG1haW4oKSB7CglpbnQgdz0xOwoJRm9vPGludCo+KCZ3KTsvL3doeSBubyBnZz8KCWludCAqdzI7CglGb288aW50Kj4odzIpOy8vd2h5IGdnPwoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJcmV0dXJuIDA7Cn0=
prog.cpp: In function 'int main()':
prog.cpp:9:14: error: no matching function for call to 'Foo(int*&)'
Foo<int*>(w2);//why gg?
^
prog.cpp:9:14: note: candidate is:
prog.cpp:4:6: note: template<class T> void Foo(T&&)
void Foo(T&& a) { }
^
prog.cpp:4:6: note: template argument deduction/substitution failed:
prog.cpp:9:14: note: cannot convert 'w2' (type 'int*') to type 'int*&&'
Foo<int*>(w2);//why gg?
^