language: C++11 (gcc-4.7.2)
date: 226 days 19 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <functional>
 
using namespace std;
 
int foo(int x, int y){
   return x+y ;
}
 
 
int main() {
    auto foo2 = std::bind(foo, std::placeholders::_1, 2);
    cout << foo2(40) << endl;
 
    auto foo3 = [] (int x) { return foo(x, 2); };
    cout << foo3(40) << endl;
    return 0;
}