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

前端 未结 6 2010
一整个雨季
一整个雨季 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:55

    By using move you avoid increasing, and then immediately decreasing, the number of shares. That might save you some expensive atomic operations on the use count.

提交回复
热议问题