fork(1) download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. int twice(int v)
  5. {
  6. return v*2;
  7. }
  8.  
  9. int negate(int v)
  10. {
  11. return -v;
  12. }
  13.  
  14. int g( std::function<int(int)> f)
  15. {
  16. return f(42);
  17. }
  18.  
  19. int main() {
  20.  
  21. std::cout << g(twice) << std::endl;
  22. std::cout << g(negate) << std::endl;
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
84
-42