Note: if you've a smart pointer you mat not have to do a
reset() on it - if it goes out of scope (in the case of
unique_ptr) - or the last instance holding a pointer to the
memory (for shared_ptr) - the memory is deallocated automa-
tically - the reset() is part of the smart pointers destruc-
tion.
Now, about the usefulness of new/delete: I think it depends
a bit on what you're doing. Some of the stuff I do is inter-
facing external devices used in physics and chemistry labs,
and there you often have to fetch lots of data (think, for
example, a trace from an oscilloscope which, with modern
devices, can consist of hundreds of MBs of data). Now, at
a low level you must use system functions like read() that
expect a buffer the data get read into. Of course, you could
create a local buffer large enough, read the data into it
and then copy them all over to a vector. But that would at
least double the memory used (at least temporarily) and
would use up some extra time. And what you then typically
do with the data doesn't require any of the bells and
whistles a vector comes with - often it is nothing more
exciting than writing them to a file. So it's simply
more efficient not to use an extra array but an allocated
buffer that one deletes once the data are safely on the
disk.
It would be different if one would be able to write directly
to the vectors memory area and change it's size afterwards,
but that's not allowed.
So I'd say that vectors tend to be the best choice when
you have something that often grows and shrinks but when
all you need is some temporary (but not local to a single
function or method) buffer which doesn't change in size
an allocated array will do as well and, in a number of
situations, even better.
An alternative in such situations might seem to be a std::array,
but there's the problem that you know the required size only
in the method that "talks" to the device (which will tell you
how many data it's got for you). And this makes it, as far
as I can see, impossible to get it (the array) out of this
method since the size is an essential part of the std::array
you've got to specify it in either the return value type or
for an argument of the method. Also template "magic" won't
help since the size isn't something known at compile time.
But perhaps someone else here has a clever solution for
this...