std::vector.
You immediately feel the "impedance mismatch" between the Standard
vector value interface and the stored pointers. One extra
* (dereference) is necessary to reach the pointed-to objects.
This is annoying especially when you use algorithms.
ptr_vector<T> is a wrapper for
Standard vector<T*> that cuts one level of indirection for
iterators and member functions. In essence, ptr_vector lets
you treat a vector of pointers as if it were
a vector of values.
In many cases, this is exactly what you want.
ptr_vector<string> vec;
vec.push_back (new string ("Hello, "));
vec.push_back (new string ("world!"));
cout << vec[0] << vec[1] << endl;
ptr_vector source code
ptr_vector
should compile with most, at least modestly, Standard conforming C++
compilers and Standard libraries.
The Unit Tests were successfully compiled and run with: