fork(1) download
  1. #include <functional>
  2.  
  3. void f(int x)
  4. {
  5. printf("%d\n", x);
  6. }
  7.  
  8. typedef void (*fp)(int);
  9.  
  10. int main()
  11. {
  12. std::function<void (int)> g1 = std::bind(f, std::placeholders::_1);
  13. g1(1); //print 1
  14.  
  15. fp g2(f);
  16. g2(2); //print 2
  17.  
  18. fp g3 = *g1.target<fp>();
  19. g3(3);
  20.  
  21. return 0;
  22. }
Runtime error #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
Standard output is empty