Why would I std::move an std::shared_ptr?

前端 未结 6 1920
一整个雨季
一整个雨季 2021-01-29 19:14

I have been looking through the Clang source code and I found this snippet:

void CompilerInstance::setInvocation(
    std::shared_ptr          


        
6条回答
  •  醉话见心
    2021-01-29 19:40

    At least with libstdc++ you should get the same performance with move and assignment because operator= calls std::move on the incoming pointer. See: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/shared_ptr.h#L384

提交回复
热议问题