本文共 1562 字,大约阅读时间需要 5 分钟。
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????IO??unique_ptr???????????????????????????????????????????????????????????????????????????????????????????????????????
?C++????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????int i = 42;??i???????????????????????????
?????C++???????????????????????????????????????????????????
???????????????
move????????????C++??????std::move???????????????????????????????
int rr3 = std::move(rr1); // ??
?C++?????????????????????????????????????????????????????????????
????StrVec?push_back??????????
void StrVec::push_back(const std::string& s) { // ????}void StrVec::push_back(std::string&& s) { // ????} ???StrVec??push_back??????????
inline void StrVec::push_back(const std::string& s) { chk_n_alloc(); // ??????? alloc.construct(first_free++, s); // ????}inline void StrVec::push_back(std::string&& s) { chk_n_alloc(); // ??????? alloc.construct(first_free++, std::move(s)); // ????} ???????
StrVec vec;std::string s = "some string or another";vec.push_back(s); // ??`push_back(const std::string&)`vec.push_back("done"); // ??`push_back(std::string&&)` ?????????????????????????????????????????????
转载地址:http://gbdz.baihongyu.com/