fork download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. class Foo
  5. {
  6. public:
  7. typedef std::function<void()> FIn;
  8. typedef void (*FOut)(Foo*);
  9.  
  10. explicit Foo(FIn call): _call(call) { _wrapper = [] (Foo* foo) { foo->_call(); }; }
  11.  
  12. FOut get() const { return _wrapper; }
  13.  
  14. private:
  15. FIn _call;
  16. FOut _wrapper;
  17.  
  18. };
  19.  
  20. int main()
  21. {
  22. Foo foo([] { std::cout << "Hi" << std::endl; });
  23. foo.get()(&foo);
  24. return 0;
  25. }
Success #stdin #stdout 0s 3016KB
stdin
Standard input is empty
stdout
Hi