fork download
  1. #include <iostream>
  2. using namespace std;
  3. template <typename T>
  4. void Foo(T&& a) { }
  5. int main() {
  6. int w=1;
  7. Foo<int*>(&w);//why no gg?
  8. int *w2;
  9. Foo<int*>(w2);//why gg?
  10. // your code goes here
  11. return 0;
  12. }
Compilation error #stdin compilation error #stdout 0s 3136KB
stdin
Standard input is empty
compilation info
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?
              ^
stdout
Standard output is empty