shared_ptr<X> p1 {newX{2} };// badauto p = make_shared<X>(2); // good AI代码助手复制代码 The make_shared() version mentions X only once, so it is usually shorter (as well as faster) than the version with the explicit new. make_shared方式只是用一次X对象,因此它通常比显式调用n...
int main () { std::shared_ptr<int> foo = std::make_shared<int> (10); // same as: std::shared_ptr<int> foo2 (new int(10)); auto bar = std::make_shared<int> (20); auto baz = std::make_shared<std::pair<int,int>> (30,40); std::cout << "*foo: " << *foo << ...