Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-03-19 07:01:51

From: "Raoul Gough" <raoulgough_at_[hidden]>
> I have recently been working on a magazine article about a smart weak
> pointer implementation, without being aware of the work being done by
> Dimov for the boost weak_ptr. Now there's not much to be gained trying to
> publish the article, ...

Why not?

> So compared to the boost strong pointer/weak pointer combination, I see
> benefits:
> 1. The target objects can be allocated and managed in any way (static,
> automatic, heap, etc...) because its destructor always does the right

Note that boost::shared_ptr supports custom allocations, too.

> 2. It does not impact code which uses shared_ptr but not weak_ptr
> As I understand it, the new boost:weak_ptr requires all boost::shared_ptr
> objects to maintain two reference counts, even if the user code does not
> the weak pointer facilities.

Yes, you are right. Depending on the situation this might have an impact on
performance, especially in single threaded programs. You can use
libs/smart_ptr/shared_ptr_timing_test.cpp to compare the new version against
the "traditional" smart_ptr.hpp implementation.

Boost list run by bdawes at, gregod at, cpdaniel at, john at