fork(7) download
  1. #include <utility>
  2.  
  3. struct example
  4. {
  5. void f0(int, int)
  6. {
  7.  
  8. }
  9.  
  10. template<class T>
  11. void f1(T&&, int)
  12. {
  13.  
  14. }
  15. };
  16.  
  17. #define FWD(xs) ::std::forward<decltype(xs)>(xs)
  18.  
  19. template<class T, class... Ts, class... TArgs>
  20. void forwarder(void(T::*fptr)(Ts...), TArgs&&... xs)
  21. {
  22. T instance;
  23. (instance.*fptr)(FWD(xs)..., 0);
  24. }
  25.  
  26. int main()
  27. {
  28. forwarder(&example::f0, 10);
  29. forwarder(&example::f1, 10);
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 3456KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:30:28: error: no matching function for call to 'forwarder(<unresolved overloaded function type>, int)'
  forwarder(&example::f1, 10);
                            ^
prog.cpp:20:6: note: candidate: template<class T, class ... Ts, class ... TArgs> void forwarder(void (T::*)(Ts ...), TArgs&& ...)
 void forwarder(void(T::*fptr)(Ts...), TArgs&&... xs)
      ^
prog.cpp:20:6: note:   template argument deduction/substitution failed:
prog.cpp:30:28: note:   couldn't deduce template parameter 'T'
  forwarder(&example::f1, 10);
                            ^
stdout
Standard output is empty