fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. typedef std::function<void(int)> fp_t;
  5.  
  6. void bar(int) {}
  7.  
  8. void baz(fp_t fp)
  9. {
  10. if (fp != nullptr)
  11. {
  12. std::cout << "true \n";
  13. fp(0);
  14. }
  15. else
  16. {
  17. std::cout << "false \n";
  18. }
  19. }
  20.  
  21. int main()
  22. {
  23. bool foo = false;
  24. baz(foo ? &bar : nullptr);
  25. }
Runtime error #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
Standard output is empty