????lambda??????????
????????????????д????/????????function object???????????????????????????Cmp???????????C++98????У???????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????
????bool myfunction (int i??int j) { return (i<j); }
????struct myclass {
????bool operator() (int i??int j) { return (i<j);}
????} myobject;
????int main()
????{
????int myints[] = {32??71??12??45??26??80??53??33};
????std::vector<int> myvector (myints?? myints+8);
????// using function as comp
????std::sort (myvector.begin()?? myvector.end()?? myfunction);
????// using function object as comp
????std::sort (myvector.begin()?? myvector.end()?? myobject);
????}
?????????????????lambda??????????”inline”??????д???????
????sort(myvector.begin()?? myvector.end()?? [](int i?? int j) { return i< j; });
???????????У?lambda?????????????????STL???????????
???????????? Raw string literals
???????磬??????regex????д??????????????????????е??б??’’?????????“???(escape)”??????(???????????)??????????????????????д“???б??????????????”?????????(w\w):
????string s = "\w\\\w";  // ???????????????
???????????????????????C++??????У??????????????????????б?????????б??????????????????C++11??????????????б?????????????б????????????????????????????
????string s = R"(w\w)";  // ok
????????begin()??end()
????????begin()??end()?????????????????????????????????????????????????????????÷??????????????е?STL?????????????????????????????????????????????????????κ????????C???????????????????????????????
????????????????????????????????????????????????????std::vector???滻??C???????顣?????????????????????
????int arr[] = {1??2??3};
????std::for_each(&arr[0]?? &arr[0]+sizeof(arr)/sizeof(arr[0])?? [](int n) {std::cout << n << std::endl;});
????auto is_odd = [](int n) {return n%2==1;};
????auto begin = &arr[0];
????auto end = &arr[0]+sizeof(arr)/sizeof(arr[0]);
????auto pos = std::find_if(begin?? end?? is_odd);
????if(pos != end)
????std::cout << *pos << std::endl;
?????????÷?????begin()??end()?????????????????????
????int arr[] = {1??2??3};
????std::for_each(std::begin(arr)?? std::end(arr)?? [](int n) {std::cout << n << std::endl;});
????auto is_odd = [](int n) {return n%2==1;};
????auto pos = std::find_if(std::begin(arr)?? std::end(arr)?? is_odd);
????if(pos != std::end(arr))
????std::cout << *pos << std::endl;
???????????????std::vecto????????????????????ζ?????????д?????????????????????begin()??end()???????
??????????б????????????? Initializer lists
??????C++98?У???vector????????????????????????
????int myints[] = { 10?? 20?? 30?? 30?? 20?? 10?? 10?? 20 };
????std::vector<int> myvector (myints?? myints+8);
??????????????????????
????std::vector<int> second ={10?? 20?? 30?? 30?? 20?? 10?? 10?? 20};
??????????????????????????????????á????±?????????x??y??z??string??????Nocase???????Сд????е??????????
????auto x = max({x??y??z}??Nocase());
??????????б?????????顣?????????map??string????????????????????????г??????
????int arr[3]{1?? 2?? 3};
????vector<int> iv{1?? 2?? 3};
????map<int?? string>  m{{1?? "a"}?? {2?? "b"}};
????string str{"Hello World"};
??????????????“{}?б?”????????г?????????????????????????????????????std::initializer_list?????????????????????????????磺
????void f(initializer_list<int>);
????f({1??2});
????f({23??345??4567??56789});
????f({});  // ????б??????????f()
????f{1??2}; // ?????????????÷???( )
????years.insert({{"Bjarne"??"Stroustrup"}??{1950?? 1975?? 1985}});
??????????б?????????????????????????????е????????????????????T?? ????????T?????)??
?????????????????·???????“??????б??????”??
????template<class E> class vector {
????public:
????// ??????б??????
????vector (std::initializer_list<E> s)
????{
????// ?????????????
????reserve(s.size());    //
????// ????????????
????uninitialized_copy(s.begin()?? s.end()?? elem);
????sz = s.size(); // ??????????size
????}
????// ... ?????????????? ...
????};
???????“{}?????”?????????????????????????????????????????????????????磬std::vector???????????????int???????????????????г?????б?????????
????vector<double> v1(7); // OK: v1??7?????<br />
????v1 = 9;         // Err: ?????int????vector
????vector<double> v2 = 9;    // Err: ?????int????vector
????void f(const vector<double>&);
????f(9);               // Err: ?????int????vector
????vector<double> v1{7};     // OK: v1?????????????7.0
????v1 = {9};           // OK: v1?????????????9.0
????vector<double> v2 = {9};  // OK: v2?????????????9.0
????f({9});  // OK: f?????????б?{9}???????????
????vector<vector<double>> vs = {
????vector<double>(10)?? // OK?? ???????(10??????????????0.0)
????vector<double>{10}?? // OK?????????(1????????10.0)
????10          // Err ??vector??????????????
????};
?????????????initializer_list???????????????н??ж???????磺
????void f(initializer_list<int> args)
????{
????for (auto p=args.begin(); p!=args.end(); ++p)
????cout << *p << " ";
????}
?????????????std::initializer_list????????????????????????б????????
???????????????string?????????????????г?????б???????????????????б??????????????????б??????????“????”???“???л?for???”??á?