int _lambda0(int x, int y)
{
return (x + y + x * y) * 2;
}
void test_lambda()
{
auto _lambda1 = [] (int x, int y) {
return x + y + x * y;
};
std::function<int(int, int)> _lambda2 = _lambda1;
std::function<int(int, int)> _lambda3 = _lambda0;
using namespace std::placeholders;
std::function<int(int)> _lambda4 = std::bind(_lambda0, _1, 20);
int a = _lambda1(10, 20);
int b = _lambda2(10, 20);
int c = _lambda3(10, 20);
int d = _lambda4(10);
printf("%d, %d, %d", a, b, c);
}
用起来就这些了,不必理论,弄死脑细胞。