Before boost 1.53, it shared_ptrshould be used for a pointer to a single object.
After 1.53, since it shared_ptrcan be used for array types, I think this is almost the same as shared_array.
But at the moment, I do not consider it appropriate to use an array type in shared_ptr, because C ++ 11 std::shared_ptrhas a slightly different behavior in terms of array type compared to boost::shared_ptr.
See shared_ptr in an array: should I use it? as a reference for a difference.
So, if you want your code to be compatible with C ++ 11 and use it instead std::shared_ptr, you should use it carefully. Because:
, , ( ), .
std::shared_ptr<int[]> a(new int[5]);
std::shared_ptr<int> b(new int[5], std::default_delete<int[]>());
boost::shared_ptr<int[]> c(new int[5]);
, , , , ,
std::shared_ptr<T> a(new T[5]);
boost::shared_ptr<T> b(new T[5]);
shared_ptr std boost .
: boost:: ptr_vector, . FYI, .