fork download
  1. struct blah
  2. {
  3. template<class t>
  4. blah(void(*)(t), t){}
  5. };
  6.  
  7. void Func(int i) {}
  8. void Func2(int& i) {}
  9.  
  10. void test()
  11. {
  12. int i = 3;
  13. blah b(Func, i);
  14. blah b2(Func2, i);
  15. }
  16.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void test()’:
prog.cpp:14:20: error: no matching function for call to ‘blah::blah(void (&)(int&), int&)’
prog.cpp:14:20: note: candidates are:
prog.cpp:4:4: note: template<class t> blah::blah(void (*)(t), t)
prog.cpp:4:4: note:   template argument deduction/substitution failed:
prog.cpp:14:20: note:   deduced conflicting types for parameter ‘t’ (‘int&’ and ‘int’)
prog.cpp:1:8: note: constexpr blah::blah(const blah&)
prog.cpp:1:8: note:   candidate expects 1 argument, 2 provided
prog.cpp:1:8: note: constexpr blah::blah(blah&&)
prog.cpp:1:8: note:   candidate expects 1 argument, 2 provided
stdout
Standard output is empty