????????????????
????????????LB?????????LB??????????????????????LB??????????????????LB?????????????????????????????????????????á??????????????functor???????????????LB????????std::function???????????auto lb?????????
????std::function <void(int)> lb; //lb is a function which takes an integer and returns void
???????????????壬??????????????LB??????????????????????????????????????????????????
struct MyLambda
{
std::function <int (int)> _lbda;//line1
int _extra;
};
MyLambda TestLambdaObj(int t)
{
MyLambda ret;
if (t == 1)
{
ret._extra = t;
ret._lbda = [=](int x)  -> int { return t + x; }; //line2
return ret;
}
else
{
ret._extra = t;
ret._lbda = [=](int x)  -> int { return t * x; };//line3
return ret;
}
}
void TestLambdaFun2(int t)
{
MyLambda ret = TestLambdaObj(t);
int v = ret._lbda(t);                                //line4
printf(“v is ‘%d’ for type %d”?? v?? t);
}
?????????????MyLambda???????????????????function???_lbda??????C++ SPEC??????????LB??????????????????????????????????????????????????????line2??line3???? ???????function??????line4????
???????????
????function??????????“???”???????????γ?????LB?????????line2??line3????
??????LB?????function??????????????????line4????????????????????????????????????????????inline????????????????????????
?????????closure????LB?????????
???????????????LB??????std::function?????????“???”??
????C++??LB??????????????????????class???????syntax sugar?????????std::function???????????????????
????auto sum = 0;
????auto step = 2;
????auto lb = [&](int i){ sum += i + step; }//capture sum and step by ref
????lb?γ???????????????????з?????sum??step??????class????????????????????10?д???