fork download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. using namespace std;
  5.  
  6. int foo(int x, int y){
  7. return x+y ;
  8. }
  9.  
  10.  
  11. int main() {
  12. auto foo2 = std::bind(foo, std::placeholders::_1, 2);
  13. cout << foo2(40) << endl;
  14.  
  15. auto foo3 = [] (int x) { return foo(x, 2); };
  16. cout << foo3(40) << endl;
  17. return 0;
  18. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
42
42