fork(3) download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. template <typename T>
  7. void foo(function<T(const T&, const T&)> op, const T& lhs, const T& rhs) {
  8. cout << op(lhs, rhs) << endl;
  9. }
  10.  
  11. int main() {
  12. function<int(const int&, const int&)> op = plus<int>();
  13.  
  14. foo(op, 13, 42);
  15.  
  16. //foo(plus<int>(), 13, 42);
  17. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
55