|
Boost : |
Subject: Re: [boost] [Block Pointer] Review Request
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2011-05-01 21:01:10
On Sun, May 1, 2011 at 10:44 AM, Phil Bouchard <philippe_at_[hidden]> wrote:
> Hi,
>
> I made the requested corrections to the Block Pointer, I've added automated
> tests and its corresponding Jamfile. The tests can be found here:
> https://svn.boost.org/svn/boost/sandbox/block_ptr/libs/smart_ptr/test/block_ptr_test1.cpp
> https://svn.boost.org/svn/boost/sandbox/block_ptr/libs/smart_ptr/test/block_ptr_test3.cpp
>
> Once again the documentation can be found here:
> https://svn.boost.org/svn/boost/sandbox/block_ptr/libs/smart_ptr/doc/tutorial.html
>
> Now I'm pretty sure I haven't forgotten anything and I am requesting a
> review.
If I understand correctly, the point of block_ptr is that it allows
for cyclic references, since if shared_ptr is used instead, the
objects that are part of a cycle will keep each other afloat.
In my mind, the point of using a smart pointer is that the pointer is
dereferenced, the pointee is guaranteed to be afloat. So, the
limitations of shared_ptr in terms of not supporting cyclic references
aren't arbitrary; they stem from this same guarantee. If object A
points object B, and object B points object A, destroying either of
them will leave a dangling pointer in the other. This is true
regardless of whether we're using raw pointers or smart pointers.
The way to deal with this situation using shared_ptr is to use
weak_ptr to break the cycles. I suppose block_ptr solves this problem
more elegantly, but how?
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk