Boost logo

Boost Users :

From: Nat Goodspeed (ngoodspeed_at_[hidden])
Date: 2006-03-21 09:17:47


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Felipe Magno de Almeida
> Sent: Monday, March 20, 2006 8:53 PM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] enable_shared_from_this - or an
alternative..
>
> On 3/20/06, Nat Goodspeed <ngoodspeed_at_[hidden]> 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net