From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-11-18 08:25:48
Matthew Wilson wrote:
> "David B. Held" <dheld_at_[hidden]> wrote in message
>> "Matthew Wilson" <stlsoft_at_[hidden]> wrote in message
>>> Not the general principle of having the reference-count
>>> external to the counted type, but the specific technique of
>>> having it a heap-allocated (integer) instance. That seems,
>>> to me anyway, the essence of the shared_ptr, and the bit
>>> that's conceptually beautiful (albeit potentially slightly
>> Just out of curiosity, how else do you implement an external
> In a shared-pool of counters. That's what the last (#5) of the
> ptr-types examined does.
> The one I've done is a very brain-dead thing, that just has 1024
> longs in an array. The (thread-safe) pool class simply allocates them
> in turn and maintains a count of the number allocated. Once it's
> 1024, all subsequent counters are allocated from the heap. Only when
> all counters are returned does the pool allocate from the array again.
You have simply implemented a different kind of heap, but the underlying
idea is the same.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk