|
Boost Users : |
Subject: Re: [Boost-users] [smart_ptr] weak_ptr pointer semantics
From: Tim Musson (Tim.Musson_at_[hidden])
Date: 2011-11-10 19:30:25
Because it is not safe to have a pointer to something and not reference
count it. See the explanation at
http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/weak_ptr.htm for a
more detailed argument of the same. If you don't want safety in your
pointers, then use raw pointers. If you want safety, then you have to
accept the consequences...
-Tim
On 11/10/2011 7:20 PM, Szymon Gatner wrote:
> Hi,
>
> Why weak_ptr does not have (smart) pointer semantics? No * or -> or even get().
>
> I often need a pointer type that is a listener to shared_ptr<> (does not affect
> refcount) but is still usable as a regular pointer type. If providing
> * and -> operators
> is for some reason undesirable then just a get() member would be nice as it
> would allow to implement own wrapper with pointer semantics. get() would return
> raw pointer from shared counter (so is fast) and not shared_ptr<> as
> lock() does.
>
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