fork download
  1. template<typename T>
  2. void foo(T&& x, T y) {
  3. }
  4.  
  5. int main() {
  6. int x;
  7. foo(x,x);
  8. return 0;
  9. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:7:9: error: no matching function for call to ‘foo(int&, int&)’
  foo(x,x);
         ^
prog.cpp:7:9: note: candidate is:
prog.cpp:2:6: note: template<class T> void foo(T&&, T)
 void foo(T&& x, T y) {
      ^
prog.cpp:2:6: note:   template argument deduction/substitution failed:
prog.cpp:7:9: note:   deduced conflicting types for parameter ‘T’ (‘int&’ and ‘int’)
  foo(x,x);
         ^
stdout
Standard output is empty