C++11??5?????????
???????????? ???????[ 2015/12/8 11:40:49 ] ??????????????????? ???????
????Kernel Panic ????? C++11 ?е? 5 ???????????????????????????????Unique ?????static_assert??Lambdas ??????
????Auto Type Deduction ??????????
????auto ????????????????? C++ ?????????????????
????std::string something = somethingthatreturnsastring.getString();
????auto something = somethingthatreturnsastring.getString();
????Auto ??????????????????something???????????????ó???????? string ????????????? auto ??????????????????????滻?????????????????????á?
????for(std::vector<T>::iterator it = x.begin(); it != x.end(); i++)
????{
????it->something();
????}
????????????????д???
????for(auto it = x.begin(); it != x.end(); i++)
????{
????it->something();
????}
??????? ??????????????
????Strongly Typed Enums ????????
????????????????Ч??????????????????????????????????? bug?????汾?? C++ ?У?????????????????????趨???????????????磬??????????????????? None??????????????????????????????????????????????????????????????????????????????·????????????????????//myEnum ::All ?? myEnum::All?????????????
????enum class myEnum {None?? One?? All};
????myEnum o = myEnum ::All;
????auto p = myEnum::All;
????// ?????Ч
????Lambdas ????
????Lambda ?????????????????????????????in-place function???????“????????????”?????????????????????????????壩??????????????for ???????????????????????????????????????Σ???????б???????????????????????Lambda ??????????? C++ ??????????????“????????????”??????????????????????????????????????????????ó????????Lambda ???????????????????????
????[]() { }
???????????п?????????????????????
????[]() mutable -> T { }
????????[]??????б??()??????б??{}???????
????Capture List ?????б?
?????????б????????????????????? Lambda ???????????????????????????????????Щ??
??????????[x]
??????????? [&x]
?????????Χ??????????????? [&]
?????3????????????????
????????????????????????????????????????? [x?? &y]
????Argument List ?????б?
?????????б?? C++ ??????????б?????????
????Function Body ??????
??????????????? Lambda ?????????????????е????
????Return Type Deduction
????????????
??????? Lambda ???????????????????????????????????????????????????????decltype(return_statement)
??????? Labmda
?????????? Lambda ?????????? mutable?????磺[]() mutable{ }??????????????????????????????????????????Щ?????????????
???????????????
????int main()
????{
????char s[]="Hello World!";
????int Uppercase = 0;
????//lambda??????????????
????for_each(s?? s+sizeof(s)?? [&Uppercase] (char c) {
????if (isupper(c))
????Uppercase++;
????});
????cout<< Uppercase<<" uppercase letters in: "<< s<<endl;
????}
??????
???·???
??????????????????
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