On Fri, Jul 5, 2013 at 4:09 PM, niXman wrote:
Even in Boost, as of 1.53.0, shared_ptr is a better alternative
2013/7/6 Glen Fernandes
than
shared_array<T>.
Why?
Because it is consistent with unique_ptr now. You have unique_ptr<T> which
has operator-> and unique_ptr which has operator[]. Now (as of Boost
1.53.0) you have shared_ptr<T> which has operator-> and shared_ptr
which has operator[].
Furthermore, I also contributed boost::make_shared and
boost::allocate_shared for T[] and T[N]. See:
http://www.boost.org/doc/libs/1_54_0/libs/smart_ptr/make_shared_array.html
These do not exist for Boost shared_array, thus prefer Boost shared_ptr
with T[] or T[N] for arrays if you want an efficient way to create a shared
array: i.e. single allocation with shared_ptr p =
make_shared(size), instead of two allocations with shared_array<T>
p(new T[size]).
Glen