????????????????????? right angle brackets
??????C++98????У????д?????????????????????壺
????vector<vector > vector_of_int_vectors;
????????????????????’>‘????????????????????????д??>>????п????????????????????????????????????????????????C++????????????????maximal munch rule)?????????????????????????????????
????vector<vector> vector_of_int_vectors;
??????C++98?У????????????????????????????(‘>’)?????п??????????????????????????”>>”??????????C++0x???????????????????????????(‘>’)???????????????б???β??
????????????????????????????????????????????“????/???”?????????????????????£?
???????????????????й???token??
???????????????????
?????????饗??????????????????
??????Щ???????????????????Щ???????У?????????????????????????????????”>>”???????????token???????ζ???????????????????????????????????????壨???????????????????????£????????????????壩??????????????????????????????б??????????????????“???”??????????α????????????????????????????????????????????????C++ ???????????????????????????????????????????????????????????????????????????????????ε?????????????????????????????????
????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 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)”??????(???????????)??????????????????????д“???б??????????????”?????????(ww):
????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 myvector (myints?? myints+8);
??????????????????????
????std::vector 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 iv{1?? 2?? 3};
????map<int?? string>  m{{1?? "a"}?? {2?? "b"}};
????string str{"Hello World"};
??????????????“{}?б?”????????г?????????????????????????????????????std::initializer_list?????????????????????????????磺
????void f(initializer_list);
????f({1??2});
????f({23??345??4567??56789});
????f({});
????// ????б??????????f()
????f{1??2};
????// ?????????????÷???( )
????years.insert({{"Bjarne"??"Stroustrup"}??{1950?? 1975?? 1985}});
??????????б?????????????????????????????е????????????????????T?? ????????T?????)??
?????????????????·???????“??????б??????”??
????template class vector {
????public:
????// ??????б??????
????vector (std::initializer_list s)
????{
????// ?????????????
????reserve(s.size());
????//
????// ????????????
????uninitialized_copy(s.begin()?? s.end()?? elem);
????sz = s.size();
????// ??????????size
????}
????// ... ?????????????? ...
????};
???????“{}?????”?????????????????????????????????????????????????????磬std::vector???????????????int???????????????????г?????б?????????
vector v1(7);
// OK: v1??7?????
v1 = 9;
// Err: ?????int????vector
vector v2 = 9;
// Err: ?????int????vector
void f(const vector&);
f(9);
// Err: ?????int????vector
vector v1{7};
// OK: v1?????????????7.0
v1 = {9};
// OK: v1?????????????9.0
vector v2 = {9};
// OK: v2?????????????9.0
f({9});
// OK: f?????????б?{9}???????????
vector<vector> vs = {
vector(10)??
// OK?? ???????(10??????????????0.0)
vector{10}??
// OK?????????(1????????10.0)
10
// Err ??vector??????????????
};
?????????????initializer_list???????????????н??ж???????磺
????void f(initializer_list args)
????{
????for (auto p=args.begin(); p!=args.end(); ++p)
????cout << *p << " ";
????}
?????????????std::initializer_list????????????????????????б????????
???????????????string?????????????????г?????б???????????????????б??????????????????б??????????“????”???“???л?for???”??á?