- unique_ptr直接支持动态数组,也支持下标访问。当然了,也可以用get获取内置指针来访问。
- shared_ptr不支持直接动态数组,所以需要用户提供删除器,只能用get获取内置指针来访问。
int main()
{
unique_ptr<int[]> upArr(new int[10]);
upArr[3] = 10;
upArr.get()[3] = 11;
cout << upArr[3] << endl;
shared_ptr<int> spArr(new int[10], [](int *p){delete []p;});
spArr.get()[3] = 10;
cout << spArr.get()[3] << endl;
return 0;
}