On Fri, Jul 5, 2013 at 4:28 PM, Jens Weller wrote:
Actually its already supported, but you'll need a custom deleter:
http://stackoverflow.com/questions/8624146/c11-standard-scoped-array-wrapper...
No, it is not. Not in the way we mean. std::unique_ptr supports T[] and
allows operator[] but std::shared_ptr does not. Boost's boost::shared_ptr
is different to std::shared_ptr in this regard (as of 1.53.0).
boost::shared_ptr is like std::unique_ptr in that you now have
operator[] instead of operator->. With boost::shared_ptr you can
access array elements with p[index]. With std::shared_ptr<T> you only have
operator-> so if you used it for an array, you'd have to use .get() first
and then access array elements with operator[]. i.e. p.get()[index].
And, as I mentioned in the other e-mail, std::shared_array has no
make_shared or allocate_shared. I have added support for make_shared
and allocate_shared for boost::shared_ptr so again,
boost::shared_ptr should be preferred if you want an efficient way to do
these allocations.
boost::shared_array<T> p(new T[size]) is two allocations while
boost::shared_ptr p = boost::make_shared(size); is one allocation.
Glen