Boost logo

Boost :

From: David van Maren (djvanmaren_at_[hidden])
Date: 2001-08-20 13:27:22

I'm implementing a 'pimpl' system, and was very happy to find out that
boost provides a shared_ptr implementation.

In trying to fit it into my design, I found that because it uses a
'direct detached' implementation (i.e., a pointer to the use_count is
held by every shared_ptr), that it does not work well for me. I really
need an 'embedded attached' model for my needs.

This is only because I must be able to construct a new shared_ptr from
the address of the object it will point to, which shares the use_count
with all of the other existing shared_ptrs to that object.

I was thinking about using it, but in a way which gives the 'embedded
attached' model. I would have the pointed-to object hold a shared_ptr
to itself, but artificially decrement the use_count. This would cause
the object to be destructed when all *other* shared_ptrs go away,
which is exactly what I want.

Has anyone out there thought of using it in this way? Is there an
easier way to do this? Are there any issues with it (i.e., should I be


David Van Maren
Cytomation, Inc.

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