
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Felipe Magno de Almeida Sent: Monday, March 20, 2006 8:53 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] enable_shared_from_this - or an alternative..
On 3/20/06, Nat Goodspeed
wrote: Indeed, for our purposes, we don't WANT smart pointers in the registry.
Couldnt be a weak_ptr ?
[Nat] It could. But AFAICT the big advantage of a weak_ptr over a dumb base* pointer is that a weak_ptr can detect when the referenced object has been deleted. Since our base-class destructor unregisters the object, deleting the registered pointer, that becomes a non-issue. So for this use case, I see no particular advantage to using weak_ptr rather than a dumb pointer. Indeed, for this use case, there appear to be a couple of advantages to using a dumb pointer. It's cheaper than a weak_ptr. But more importantly, it works regardless of whether the referenced object is allocated on the heap, on the stack or in static storage. That's useful to us, as we do have a number of tracked objects declared statically.