博客
关于我
C++ Primer 5th笔记(chap 13 拷贝控制) 对象移动
阅读量:83 次
发布时间:2019-02-26

本文共 1547 字,大约阅读时间需要 5 分钟。

C++???????????????

?????????

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

????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/

    你可能感兴趣的文章
    Objective-C实现integerPartition整数划分算法(附完整源码)
    查看>>
    Objective-C实现interpolation search插值搜索算法(附完整源码)
    查看>>
    Objective-C实现Interpolation search插值查找算法(附完整源码)
    查看>>
    Objective-C实现intersection交集算法(附完整源码)
    查看>>
    Objective-C实现intro sort内省排序算法(附完整源码)
    查看>>
    Objective-C实现inverse matrix逆矩阵算法(附完整源码)
    查看>>
    Objective-C实现inversions倒置算法(附完整源码)
    查看>>
    Objective-C实现isalpha函数功能(附完整源码)
    查看>>
    Objective-C实现islower函数功能(附完整源码)
    查看>>
    Objective-C实现isPowerOfTwo算法(附完整源码)
    查看>>
    Objective-C实现isupper函数功能(附完整源码)
    查看>>
    Objective-C实现ItemCF算法(附完整源码)
    查看>>
    Objective-C实现ItemCF算法(附完整源码)
    查看>>
    Objective-C实现iterating through submasks遍历子掩码算法(附完整源码)
    查看>>
    Objective-C实现iterative merge sort迭代归并排序算法(附完整源码)
    查看>>
    Objective-C实现jaccard similarity相似度无平方因子数算法(附完整源码)
    查看>>
    Objective-C实现Julia集算法(附完整源码)
    查看>>
    Objective-C实现jump search跳转搜索算法(附完整源码)
    查看>>
    Objective-C实现jumpSearch跳转搜索算法(附完整源码)
    查看>>
    Objective-C实现k nearest neighbours k最近邻分类算法(附完整源码)
    查看>>