#include <iostream>
class Base {
public:
virtual ~Base() {}
virtual void call(int i) = 0;
};
template<class F>
class Foo : public Base {
F f;
public:
Foo(F f) : f(f) {}
virtual void call(int i) { f(i); }
};
class Holder {
Base* b;
public:
template<class F>
Holder(F f) : b(new Foo<F>(f)) {}
~Holder() { b->call(0); delete b; }
};
void foo(int i, int j = 0) { std::cout << i << std::endl; }
int main() {
Holder h(foo);
}