fork(2) download
  1. #include <iostream>
  2. #include <functional>
  3. using namespace std;
  4.  
  5. template <typename Fnc, typename Args>
  6. void t (Fnc f, Args arg) {
  7. f (arg);
  8. }
  9.  
  10. void foo (int x) {
  11. cout<<x;
  12. }
  13. void bar (int& x) {
  14. cout << ++x;
  15. }
  16.  
  17. int main () {
  18. int x=2;
  19. t (foo, x);
  20. t<function<void(int&)>,int&> (bar, x);
  21. cout << x;
  22. }
  23.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
233