Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2002-02-02 17:55:12

----- Original Message -----
From: "Mark Rodgers" <mark.rodgers_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, February 02, 2002 2:28 PM
Subject: [boost] auto_vector - vector with auto_ptr semantics

> 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.


> Comments anyone?

I've long thought that a specialization for
'std::vector<std::auto_ptr<T> >' would be a good solution to the
auto_ptr-in-container problem. Unfortunately such class could not
copy the 'std::vector' interface completely, and would probably not
even be a true container.

It sounds like your 'auto_vector' avoids some of the problems of a
container of auto_ptrs by conceptually being a container of vanilla
pointers. Unfortunately this has its own set of problems. Consider:

  auto_vector<Cat> cats;
  cats.push_back(new Cat);
  cats[0] = new Cat; // Error: memory leak

I would like to see some form of vector-of-auto_ptr in boost.

Rainer Deyke | root_at_[hidden] |

Boost list run by bdawes at, gregod at, cpdaniel at, john at