Boost logo

Boost :

From: Gavin Collings (gcollings_at_[hidden])
Date: 2000-01-28 12:16:58


> I think I discovered a new approach for smart pointers (tell me if
> this has been done). Instead of maintaining the reference count as
> an integer created on the heap, the smart ptr objects internally
> maintain a double-linked list in which they are members.
>

I have this implemented as a template with minor differences: -

- I set the "unique" pointer values to point to self to avoid null
tests
  
- I think there's a bug in your swap function - you need to adjust the
back pointer in other objects to reflect that this now collaborates
with a different set of smart pointers.

- I have the list pointers as mutable to reflect the fact that they may
be changed by other objects.

I've done timing tests which agree with yours, I also tried to
characterize the speed advantage against set size and found that
there's a cross over at about 25-50 members -i.e. the current
implementation becomes more efficient when greater than that number
share a single pointer.

There is also an additional benefit of better exception guarantees.
I'm all for it.

Gavin


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