fork(1) download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. template <class T, class U>
  5. T apply(U stuff, std::function<T (U)> function) { return function(stuff); }
  6.  
  7. int foo(double x) { return x; }
  8.  
  9. int main ()
  10. {
  11. std::cout << apply(42.0, std::function<int(double)>(foo)) << std::endl;
  12. }
  13.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
42