Boost logo

Boost :

From: Mark Rodgers (mark.rodgers_at_[hidden])
Date: 2002-02-25 13:49:23

From: "Rainer Deyke" <root_at_[hidden]>
> > From: "Rainer Deyke" <root_at_[hidden]>
> > > From: "Peter Dimov" <pdimov_at_[hidden]>
> > > > What are the main differences between auto_vector<T> and vector<
> > > > shared_ptr<T> > ?
> > >
> > > 'vector<shared_ptr<T> >' does not enforce strict ownership,
> >
> > Why is this a good thing? If I have a raw pointer and the
> auto_vector<>
> > dies, I'm left with a dangling pointer.
> It is useful as a statement of intent. A strict ownership hierarchy
> simplifies things. For instance, you never have to worry about
> reference cycles.

Also, the dangling pointer is no problem if it is not used,
whereas the mere existence of a dangling shared pointer prevents a
destructor being called when it should be. That might be important.

To answer Peter's original question in another way, the difference is
pretty much the same as the difference between auto_ptr and shared_ptr.
Peter, are you suggesting that people should only ever use shared_ptr
and *never* auto_ptr?


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