fork download
  1. #include <iostream>
  2.  
  3. // 2 overloads, comment one and it will work
  4. void f();
  5. void f(int);
  6.  
  7. template<typename T>
  8. void my_transform(T&& functor){}
  9.  
  10. int main()
  11. {
  12. my_transform(f); // cannot deduce the type of f due to overloads
  13. }
  14.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:12:19: error: no matching function for call to 'my_transform(<unresolved overloaded function type>)'
     my_transform(f); // cannot deduce the type of f due to overloads
                   ^
prog.cpp:12:19: note: candidate is:
prog.cpp:8:6: note: template<class T> void my_transform(T&&)
 void my_transform(T&& functor){}
      ^
prog.cpp:8:6: note:   template argument deduction/substitution failed:
prog.cpp:12:19: note:   couldn't deduce template parameter 'T'
     my_transform(f); // cannot deduce the type of f due to overloads
                   ^
stdout
Standard output is empty