#include <iostream>
#include <functional>
using namespace std;

template <typename Fnc, typename Args>
void t (Fnc f, Args arg) {
  f (arg);
}

void foo (int x) {
  cout<<x;
}
void bar (int& x) {
  cout << ++x;
}

int main () {
  int x=2;
  t (foo, x);
  t<function<void(int&)>,int&> (bar, x);
  cout << x;
}
