Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-01-20 16:41:16


Larry Evans wrote:

>

[snip]

> So my question is, why should the AB type be hidden in the
> shared_ptr<B> instance, spB? Why not make it explicit, as done with
> prox_mi<B,AB> (see example code in the *prox.cpp in the prox_mi.zip).
> My first guess at the reason is that the user might not know the most
> derived class of the pB in the above code. For example, it could be
> AB or any other class having B as a superclass; hence, shared_ptr can
> be used in more situations. But in the above code, the user does know
> the most derived class. He knows it must be AB since the argument
> he's using to shared_ptr<B> is a shared_ptr<AB>. 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>?

OOPS. Asked too soon. The user could construct a shared_ptr<B> from another
shared_ptr<B> and not know the other was constructed from a shared_ptr<AB>.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk