C++11 Lambda?????????
???????????? ???????[ 2015/1/22 14:08:59 ] ????????Net ???????
?????塢{??????}?????????????????????????????????????????
?????????????????????????????????????????????????????м???????????ο???
class CTest
{
public:
CTest() : m_nData(20) { NULL; }
void TestLambda()
{
vector<int> vctTemp;
vctTemp.push_back(1);
vctTemp.push_back(2);
// ???????????????????1 2
{
for_each(vctTemp.begin()?? vctTemp.end()?? [](int v){ cout << v << endl; });
}
// ?????????????????????п????????????????this?????????11 12
{
int a = 10;
for_each(vctTemp.begin()?? vctTemp.end()?? [=](int v){ cout << v+a << endl; });
}
// ?????÷?????????????????п????????????????this?????????11 13 12
{
int a = 10;
for_each(vctTemp.begin()?? vctTemp.end()?? [&](int v)mutable{ cout << v+a << endl; a++; });
cout << a << endl;
}
// ????????????????a???????11 13 10
{
int a = 10;
for_each(vctTemp.begin()?? vctTemp.end()?? [a](int v)mutable{ cout << v+a << endl; a++; });
cout << a << endl;
}
// ?????÷????????????a???????11 13 12
{
int a = 10;
for_each(vctTemp.begin()?? vctTemp.end()?? [&a](int v){ cout << v+a << endl; a++; });
cout << a << endl;
}
// ????this???????21 22
{
for_each(vctTemp.begin()?? vctTemp.end()?? [this](int v){ cout << v+m_nData << endl; });
}
// ??b??????????????????????????????11 12 17
{
int a = 10;
int b = 15;
for_each(vctTemp.begin()?? vctTemp.end()?? [=?? &b](int v){ cout << v+a << endl; b++; });
cout << b << endl;
}
// ????????????????????????????????2 3
{
for_each(vctTemp.begin()?? vctTemp.end()?? [](int &v){ v++; });
for_each(vctTemp.begin()?? vctTemp.end()?? [](int v){ cout << v << endl; });
}
// ???Lambda????
{
[](){}();
[]{}();
}
}
private:
int m_nData;
};
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
?????????????????(java .net ?????).Net?й???????????Asp.net MVC??ζ???????????????????????Trim????Asp.Net WebForm????????????.Net??????????С????asp.net ???????????.Net??????????????????Linux???Jexus?й?Asp.Net Core??ó??????????????????Netflix?????????C#????????????Log4net??????asp.net??????????????ASP.NET???????JSON?????????????????? .NET ?? Java ???? IT ???.Net??Ч???????????????ù???ASP.NET MVC???????????Щ?£?Linux Netlink???????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????