|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-05-26 08:38:10
Felipe Magno de Almeida wrote:
> On 5/23/07, Peter Dimov <pdimov_at_[hidden]> 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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk