I often need to deal with dynamically-allocated arrays in C++, and hence rely on Boost for scoped_array, shared_array, and the like. After reading through Stroustrup's C++11 FAQ and the C++11 Reference Wiki, I could not find a suitable replacement for these dynamic array wrappers that is provided by the C++11 standard. Is there something that I have overlooked, or do I have to continue relying on Boost?
Thank you very much for your help!
There is a specialization of
unique_ptr
, likeunique_ptr<T[]>
.When you run it, you will get this messages.
If you want to use
shared_ptr
, you should usestd::default_delete<T[]>
for deleter since it doesn't have one likeshared_ptr<t[]>
.So far as vectors are intended as array wrappers, what if you use any suitable smart pointer with the vector as inner object?