#include <iostream>
#include <functional>
class Foo
{
public:
typedef std::function<void()> FIn;
typedef void (*FOut)(Foo*);
explicit Foo(FIn call): _call(call) { _wrapper = [] (Foo* foo) { foo->_call(); }; }
FOut get() const { return _wrapper; }
private:
FIn _call;
FOut _wrapper;
};
int main()
{
Foo foo([] { std::cout << "Hi" << std::endl; });
foo.get()(&foo);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KCmNsYXNzIEZvbwp7CnB1YmxpYzoKICAgIHR5cGVkZWYgc3RkOjpmdW5jdGlvbjx2b2lkKCk+IEZJbjsKICAgIHR5cGVkZWYgdm9pZCAoKkZPdXQpKEZvbyopOwoKICAgIGV4cGxpY2l0IEZvbyhGSW4gY2FsbCk6IF9jYWxsKGNhbGwpIHsgX3dyYXBwZXIgPSBbXSAoRm9vKiBmb28pIHsgZm9vLT5fY2FsbCgpOyB9OyB9CgogICAgRk91dCBnZXQoKSBjb25zdCB7IHJldHVybiBfd3JhcHBlcjsgfQoKcHJpdmF0ZToKICAgIEZJbiBfY2FsbDsKICAgIEZPdXQgX3dyYXBwZXI7CiAgICAKfTsKCmludCBtYWluKCkKewogICAgRm9vIGZvbyhbXSB7IHN0ZDo6Y291dCA8PCAiSGkiIDw8IHN0ZDo6ZW5kbDsgfSk7CiAgICBmb28uZ2V0KCkoJmZvbyk7CiAgICByZXR1cm4gMDsKfQ==