Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-01-21 08:15:02

From: "Larry Evans" <jcampbell3_at_[hidden]>
> Greg Colvin wrote:
> > From: "Larry Evans" <jcampbell3_at_[hidden]>
> > > ... Could someone
> > > describe a case where this is not so, i.e. the user does not know what
> > > the most derived class is when creating a shared_ptr<T>?
> >
> > When using a factory function that returns only a pointer to base?
> >
> If you mean using the shared_ptr(T*) CTOR, then this is similar
> to Maeder's example and, as pointed out in
> and the user is responsible for avoiding this.

I suppose Greg meant

shared_ptr<Base> createObject(std::string classId);

or something similar.

The main advantage of the 'enhanced' shared_ptr<> is that the author of
createObject() may change the function to return pointers with a custom
deallocator without changing the library interface.

Peter Dimov
Multi Media Ltd.

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