Boost logo

Boost :

Subject: Re: [boost] [shared_array] Why not in C++11 ?
From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2013-07-05 21:35:27

> On Fri, Jul 5, 2013 at 4:09 PM, niXman <i.nixman_at_[hidden]> wrote:
> 2013/7/6 Glen Fernandes
> > Even in Boost, as of 1.53.0, shared_ptr<T[]> is a better alternative
> > shared_array<T>.
> Why?

Because it is consistent with unique_ptr now. You have unique_ptr<T> which
has operator-> and unique_ptr<T[]> which has operator[]. Now (as of Boost
1.53.0) you have shared_ptr<T> which has operator-> and shared_ptr<T[]>
which has operator[].

Furthermore, I also contributed boost::make_shared and
boost::allocate_shared for T[] and T[N]. See:

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<T[]> p =
make_shared<T[]>(size), instead of two allocations with shared_array<T>
p(new T[size]).


Boost list run by bdawes at, gregod at, cpdaniel at, john at