fork(1) download
  1. #include <functional>
  2. #include <cstdio>
  3.  
  4. struct C { int dummy1; char const * dummy2; };
  5.  
  6. struct A
  7. {
  8. std::function<void(C)> m_callback;
  9. void foo(){
  10. m_callback(C{123, "foo"});
  11. }
  12. };
  13.  
  14. struct B
  15. {
  16. B(){
  17. a.m_callback = std::bind(&B::NoArgs, this);
  18. }
  19. void NoArgs(){
  20. printf("wtf?");
  21. }
  22.  
  23. A a;
  24. };
  25.  
  26. int main() {
  27. B b;
  28. b.a.foo();
  29. return 0;
  30. }
Success #stdin #stdout 0s 4456KB
stdin
Standard input is empty
stdout
wtf?