Is there any reason not to use std::make_shared when constructing objects?

前端 未结 3 913
暗喜
暗喜 2021-02-05 13:08

I can\'t think of any situation where

std::shared_ptr obj(new Object(\"foo\", 1));


would be preferred to

auto obj         


        
      
      
      
3条回答
  •  一生所求
    2021-02-05 13:19

    Modern IDEs have "Find usages" feature. If you use std::make_shared to construct the object, when you search for the places where the constructor of that object is called, IDE won't show up the places where std::make_shared is used.

提交回复
热议问题