C++11???????????????
???????????? ???????[ 2015/9/8 11:34:51 ] ????????.NET ???????????
??????????δ??????????????????????????
????template <typename T1?? typename T2>
????auto add(T1 t1?? T2 t2) -> decltype(t1 + t2)
????{
????return t1 + t2;
????}
???????????????д?????′?????????????????
????std::cout << add(1?? 3.14) << std::endl;
????std::cout << add("one"?? 2) << std::endl;
?????????????4.14??”e”???????????????????????????????????н????????????
template <typename T1?? typename T2>
auto add(T1 t1?? T2 t2) -> decltype(t1 + t2)
{
static_assert(std::is_integral<T1>::value?? "Type T1 must be integral");
static_assert(std::is_integral<T2>::value?? "Type T2 must be integral");
return t1 + t2;
}
error C2338: Type T2 must be integral
see reference to function template instantiation 'T2 add<int??double>(T1??T2)' being compiled
with
[
T2=double??
T1=int
]
error C2338: Type T1 must be integral
see reference to function template instantiation 'T1 add<const char*??int>(T1??T2)' being compiled
with
[
T1=const char *??
T2=int
]
????move????????????
????move????????????
???????????????????????????????????????????????????move???????????????????????????????????????????const T&???????
????void incr(int& a) { ++a; }
????int i = 0;
????incr(i); // i???1
????//????0??????????
????incr(0);
????// 0????????????????????const?????int&??
????// ??????У????????????????????????0???????????
????// ???????int&?У????????????????????????????????
????// ??????????????κθ???????????????
????// ???????????????????????????const???????????const???????
????// ??????е?
????”&&”???“???????”????????????????????????????????????
????X a;
????X f();
????X& r1 = a; // ??r1????a(??????)
????X& r2 = f(); // ????f()??????????????????
????X&& rr1 = f(); // OK????rr1???????????
????X&& rr2 = a; // ????????????????rr2???????a
???????????o?????
????template<class T> swap(T& a?? T& b) // ?????swap????
????{
????T tmp(a);// ??????????"a"
????a = b; // ??????????"b"
????b = tmp; // ??????????tmp(??a)
????}
???????T?????????????????????????????string??vector?????????swap()???????????????????????????????????????Щ??????????????????????????a??b??tmp????????“???”???????tmp??????a??b???????
?????????????????????????“???”?????????“????”?????????????????????????“???”????????????????????????s1=s2????????????s2??????????????????s1“???”s2?????????洢??
??????????????move()?????????????????“???”??
????template <class T>
????void swap(T& a?? T& b) //“????swap”???????????£?
????{
????T tmp = move(a); // ????a?????Ч???????????????move??tmp?????
????a = move(b); // ????b?????Ч???????????????move??a?????????a????“???????”???
????b = move(tmp); // ????tmp?????Ч???????????????move??b?????????b????“???????”???
????}
????move(x) ??ζ??“??????x??????????”????move()?????rval()??????????????μ????move()?????ú?????????C++11?У?move()??庯????????????????????
?????????????????????????????????????????????????????????????????????????
????move?????е???
????????move??std::sort()??std::set::insert()??????copy?????汾??15????????????????????????в??????????????????????????????????????????????????????????string??vector???????????swap??????????copy??????????????????????а?????move?????????????????±?????л??????
????move??????????
??????C++11???????У????е??????????????????????????????????????Щ?????????????????insert()??push_back()?? ?????????????????????汾???????????????????????????£??????????????????????????????Щ????鸚???????????????
??????vector?????????“?????????(move constructors)”??“????????????(move assignments”??“???”?????????????????
????template<class T> class vector {
????// …
????vector(const vector&); // ??????????
????vector(vector&&); // ?????????
????vector& operator= (const vector&); // ???????????
????vector& operator =(vector&&); // ??????????
????}; //??????????????????????????????
????// ??const????????ò?????????????????????????ò????????
??????????????move????????????????????????????????????Ч???????з????????????
????vector<int> make_random(int n)
????{
????vector<int> ref(n);
????// ????0-255?????????
????for(auto x& : ref) x = rand_int(0??255);
????return ref;
????}
????vector<int> v = make_random(10000);
????for (auto x : make_random(1000000)) cout << x << ' ';
?????????????????vector??б?????????(vector ref?????????????????????stack??????????move assignment?????????t??????????????)????????????????????÷?????????洢????????vector??????????????????????????????????????????????????vector????????д??????????????
?????????ò??? Emplace operations
??????????????£?push_back()??????????????????????????????????????????Ч?????????????????????????????????????????п???/??????????????????vector?з????????????????????????????????????????????????????????????”??????”??emplace?????????putting in place????
?????????emplace_back()???????
????vector<pair<string??int>> vp;
????string s;
????int i;
????while(cin>>s>>i) vp.emplace_back(s??i);
????emplace_back()???????????????????????????????????????????emplace_back()????push_back()????Ч?????????????????????????????????????????????????????????????????????????????????????ɡ?
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????C++????????????
???·???
??????????????????
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 ??????