From: Mark Rodgers (mark.rodgers_at_[hidden])
Date: 2002-02-02 16:28:43


I have a class template I call auto_vector. It's a simple
idea and I'm sure many others have done something similar
but if no-one else is planning on submitting theirs, I'm
happy to contribute mine.

To summarise, it is a vector of pointers but it has the
following differences from an ordinary vector:

- Deletes its contained pointers on destruction.

- Deletes erased elements in erase.

- Copy and assignment have auto_ptr sematics, i.e. use an
  auto_vector_ref and clear the source object. I've
  implemented this using swap, so passing and returning
  auto_vectors by value is relatively cheap.

- Adds an overloaded insert taking an auto_ptr which is
  shorthand for

      v.insert(pos, ap.get()); ap.release();

- Adds a release function (erase but return instead of
  destroy).

I can boostify the code really quickly (just change the
namespace and copyright) and I have some tests. If there
is any interest, I'll upload these to the vault and start
on some documentation.

Comments anyone?

Mark