C++11???????????????
???????????? ???????[ 2015/9/8 11:34:51 ] ????????.NET ???????????
???????????????C++11???????????????
??????????????·??棺
???????????Ч??????array??forward_list???unordered containers??
?????????????????????????move???壻
??????С??????? array
????std::array??????????????????С??size?????????????????c++11?????????????????????????
?????????????????????????????size() == capacity()????
??????????ó???????initializer list?????????г??????
???????????????size?????
????????????????????????
?????????????????????????????????????????
????array<int??6> a = { 1?? 2?? 3 };
????a[3]=4;
????int x = a[5]; // array?????????????0??????x??????0
????int* p1 = a; // ????: std::array????????????????
????int* p2 = a.data(); // ?????data()?????????????????
???????????array????????????vector??????vector??Ч???????????????????????push_back?????????????????????ó?????????????滻c++????????????????????vector??
????????б? forward_list
????c++11????????????????б? forward_list
????????б???????????????λ?????????????????????б?????????????б???????????????????????????????????
????????????????????????????????C????????????????????????std::list??????????????????????????????????????????
????std::forward_list<int> mylist (3??5); // 3 ints with value 5
????for (int& x : mylist ) std::cout << " " << x;
?????????[????????] unordered containers
????hash??????????????????а??????????????gcc ?????汾?У?????????tr1????????У?
??????unordered_map?????unordered_map??????б???????????????洢??
??????map?????????????????????????operator< ???б?????
????hash?汾???????臨????O(1)????????????????????????汾Ч?????
?????????C++11?к?????????????
????// c++0x?У?
????#include <tr1/unordered_map>
????std::tr1:: unordered_map< char??int > map1;
????map1.insert(std::pair<char??int>('a'??100) );
????// C++11?У?
????#include <unordered_map>
????std::unordered_map< char??int > map1;
????map1.insert(std::pair<char??int>('a'??100) );
???????????? constexpr
?????????????Compile-time evaluation????????????
??????????У???Щ???????????????????????ж????????????
????????????????????Щ?????????????????????????????
???????????????????????????????????????????????Ч????
????eg:???????????constexpr
????constexpr int multiply (int x?? int y)
????{
????return x * y;
????}
????// ????????????
????const int val = multiply( 10?? 10 );
????cin >> x;
????// ????????????x??????????????????????????????????????????????????
????const int val2 = mutliply??x??x);
??????????? static_assert
????static_assert????????????????顣?????????棬????????????????????????????????????????????????????????????????е???????????????????????????
????expression?????????????????????false???????????????????string??????????????????磺
????static_assert(sizeof(long) >= 8??
????“64-bit code generation required for this library.”);
????struct S { X m1; Y m2; };
????static_assert(sizeof(S)==sizeof(X)+sizeof(Y)?? ”unexpected padding in S”);
????static_assert???ж?????????????????????????????ж????????????64λ??????????????????static_assert????????????????????????Щ?????????????????????м??顣???磺
????int f(int* p?? int n)
????{
????//????????“p == 0”???????????????
????static_assert(p == 0??
????“p is not null”);
????}
???????????????????????????ж?????????????????????????
??????
???·???
??????????????????
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