Boost logo

Boost :

From: Miki Jovanovic (miki_at_[hidden])
Date: 2000-02-07 14:17:59

"greg colvin" <gcolvi-_at_[hidden]> wrote:
> I still think linked_ptr::release is a dangerous invitation
> to dangling pointers.

Me too. Before, whenever I needed some sort of object management (one
instance deciding when the held object shold be destroyed) I invariably
ended up with a rather complex manager involving each 'smart pointer'
registering interest in the held object, so when the object is
destroyed all interested parties had to be informed. But all of this is
way out of scope of this discussion.

I am curious, why does anyone need to destroy the object before all
references are restored?

If really you need this functionality, one of the earlier ideas for a
small smart pointer fits nicely here:

class smart_ptr {
    ptr_struct *ptr;

struct ptr_struct {
  T *pObject;
  int refCount;

But again, the problem release() is trying to solve is not in the
domain which inspired original smart_ptr. My view on programming is
'keep it simple', sometimes to the extreme. release() goes against that



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