是否std::make_unique有像任何效率优势std::make_shared?
与手动构建相比std::unique_ptr:
std::make_unique<int>(1); // vs
std::unique_ptr<int>(new int(1));
Run Code Online (Sandbox Code Playgroud) 很抱歉这个问题,我一直在做Python和JS太多了,现在回到C++来分配一个数组.
怎么能比这更容易:
float* d1 = (float*)calloc(4,sizeof(float));
d1[0] = 1;
d1[1] = 2;
d1[2] = 3;
d1[3] = 4;
Run Code Online (Sandbox Code Playgroud)
我习惯了d1 = [1,2,3,4],不能把头包裹起来......