Boost logo

Boost :

From: Thomas Matelich (sosedada_at_[hidden])
Date: 2000-10-19 16:55:18

While changes are being discussed, I've come up with another reason I would
like to make shared_ptr derivable (change private to protected). I have a
situation where I have a function whose parameter I just changed from a
pointer a shared_ptr, and it ends up getting called with [this] from within
an object. Since I can't create a shared_ptr with this I wrote a
dumb_shared_ptr like so (from memory):

template <class T>
class dumb_shared_ptr: public boost::shared_ptr<T>
   dumb_shared_ptr(T* p):
      *pn +=1; //make it never delete px

The cool thing was I could still pass this by value because my damage had
already been done. I understand that this is dangerous because of the
unknown lifetime of the object being passed in.

Anyway, I suppose I have closed my case by providing an example of why not
to allow derivation.

Greg Colvin wrote:

> Fine by me.
> ----- Original Message -----
> From: <scleary_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Thursday, October 19, 2000 10:07 AM
> Subject: RE: [boost] shared_ptr hierarchy question
> > > In that case, is there any objection to accepting the version of
> > > smart_ptr.hpp recently posted by Peter Dimov as the official version?
> >
> > No objection here.
> >
> > -Steve
> >
> >
> >
> >

Thomas O Matelich
Senior Software Designer
Zetec, Inc.

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