fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename T, typename F>
  5. void todo(const T& param, const F& function)
  6. {
  7. function(param);
  8. }
  9. void foo(double a)
  10. {
  11. cout << "double " << a << endl;
  12. }
  13.  
  14. void foo(int a)
  15. {
  16. cout << "int " << a << endl;
  17. }
  18.  
  19. int main()
  20. {
  21. int iA = 1051;
  22.  
  23. todo(iA, static_cast<void (*)(int)>(&foo));
  24. todo(iA, static_cast<void (*)(double)>(&foo));
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 4240KB
stdin
Standard input is empty
stdout
int 1051
double 1051