|
Boost : |
From: Richard Damon (rdamon_at_[hidden])
Date: 2002-04-09 15:19:51
> -----Original Message-----
> From: boost-admin_at_[hidden] [mailto:boost-admin_at_[hidden]]On
> Behalf Of Eyal Farago
> Sent: Tuesday, April 09, 2002 1:42 PM
> To: boost_at_[hidden]
> Subject: RE: [boost] smart pointer puzzle
>
>
> 1. What do you mean by intrusive/non intrusive pointer?
An intrusive pointer is one that has support in the pointed object, normally
storage of the reference count. Since all the shared state can be stored in
the pointed object, the pointer needs to only hold a pointer to the object,
and thus can be safely created by a raw pointer to the object.
> 2. I believe that holding a pointer map whose key is as raw void*
> pointer won't solve the problem.
> Consider the case of multiple inheritance:
> class c : public a , public b {...};
>
> if cc is an instance of c, the following does not always compare equal:
>
> (c*)(&cc) , (a*)(&cc) , (b*)(&cc).
>
you can not compare a (c*) pointer to a (a*) pointer, they must be cast to a
common type. If the types are polymorphic (have a virtual function) then
dynamic_cast<void*>(c*)(&cc) == dynamic_cast<void*>(a*)(&cc) ==
dynamic_cast<void*>(b*)(&cc)
by the definition of dynamic_cast (5.2.7 paragraph 7).
> casting any of these result into a void and using it as a key to the map
> is dangerous since the same object might be registered twice...
>
> Eyal.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk