You should create that shared_ptr
like that
std::shared_ptr<int> sp( new int[10], std::default_delete<int[]>() );
You must give other deleter to shared_ptr
You can't use std::make_shared
, because that function gives only 1 parameter, for create pointer on array you must create deleter too.
Or you can use too (like in comments , with array or with vector, which has own deleter)
std::shared_ptr<std::array<int,6>> ptr(std::make_shared<std::array<int, 6>>(std::array<int, 6>()));
How get particular element?
Like that
std::shared_ptr<int> sp(new int[10], std::default_delete<int[]>());
sp.get()[0] = 5;
std::cout << sp.get()[0] << std::endl;