
26 May
2007
26 May
'07
12:38 p.m.
Felipe Magno de Almeida wrote:
On 5/23/07, Peter Dimov <pdimov@mmltd.net> wrote:
[snip]
struct Base { virtual ~Base() {} };
struct Derived: Base { int i; };
Derived * pd = new Derived; Base * pb = pd; shared_ptr<void> pv( pb );
[snip]
or
pv->pointer() == pd && pv->type() == typeid(Derived);
Sorry if it is too obvious. But how can shared_ptr implement pv->pointer() == pd ?
It can use dynamic_cast<void*>( pb ) to obtain pd when *pb is polymorphic.