|
Boost Users : |
Subject: Re: [Boost-users] [Smart Ptr] Why is weak_ptr a _ptr?
From: Peter Dimov (pdimov_at_[hidden])
Date: 2010-10-13 10:30:41
Szymon Gatner wrote:
> Is it just me or is it really the worse naming in whole boost library?
>
> It is nothing like any other smart pointer.
>
> No initialization / construction from raw pointer.
>
> No operator * or -> (the very least one would expect from _ptr class).
>
> No get().
The weak pointer concept originates from garbage-collected languages that
have pointers, such as some proposed extensions to C/C++. In such a
language, a weak_ptr can be constructed from a raw pointer, can have *, ->,
does have get() -- because the raw pointers are "strong", that is, they keep
an object from being destroyed because the garbage collector tracks all
pointers.
(See for example section 5.4 in
http://www.usenix.org/publications/library/proceedings/c++94/full_papers/ellis.a )
In our "ordinary" C++, the equivalent of such a garbage-collected raw
pointer is shared_ptr, which is why weak_ptr can only give you a shared_ptr
and not a raw pointer.
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