Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-06-18 06:33:52


Bruno Martínez wrote:
> Hi,
> I was wondering if it was possible to have two weak pointers that
> together own an object. That is, if one of the two is destroyed the
> other fails to construct a shared_ptr, but as long as both exist the
> object is not destroyed, even if no other weak/shared ptr exists.
> This would come handy
> for implementing association classes.

No, this is not possible. There is no "critical mass of weak pointers"
concept in the library. The straightforward way to do it would be to use two
shared_ptr instances and periodically do if(p.unique()) p.reset().


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk