Thanks,
Siegfried
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
std::tr1::array<T, N> extremely closely mimics a C array T[N]. It
should be used when you are using fixed-length data, or have some
other reason to fix your memory at compile time. It should be used in
place of a C array whenever possible.
boost::ptr_vector<T> exists as a replacement for std::vector<T*> when
you want the ptr_vector to automatically call the deleter on the
contained objects. It also has the advantage of providing a slightly
nicer interface - operator[] dereferences the pointer, for instance.
With a no-op deleter, it is essentially the same as vector except that
it that slightly nicer interface.
std::vector<T> is for the remainder of cases, but you should note that
there is also std::list and std::deque, which provide different
options for container use. In particular, deque is oftentimes a better
choice in cases where vector is used - it is very similar, but it does
not provide contiguous allocation. In return, however, it provides
constant-time insertions and deletions at either end of the sequence,
which can be very useful compared to a vector.
Sean
array is for statically sized collections, while vector is for
dynamically sized and resizable ones.
ptr_vector is a wrapper around vector when you're holding pointers and
must own them. Ideally this shouldn't be needed: a vector of
unique_ptr provides the same functionality, except it requires C++0x.