Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-01-20 09:22:56

From: "David Abrahams" <david.abrahams_at_[hidden]>
> From: "Peter Dimov" <pdimov_at_[hidden]>
> > True, there is no way to detect the general case where a shared_ptr is
> being
> > constructed from a T * that actually points to something derived from T.
> Actually,
> typeid(*p) == typeid(T)
> Gets you about as far along as you could hope for (my current work uses
> /lots/ of RTTI so this jumped out at me ;-)). Not that you'd probably want
> to pay for typeid.

But unfortunately this fails (missed negative) for non-polymorphic T, and
fails (false positive) for polymorphic T with a virtual destructor. ;-)

Peter Dimov
Multi Media Ltd.

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