$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-04-03 16:41:54
Dave wrote:
> Hello all,
>
> I'm using shared_ptr<foo> and would like to be notified, via a
> callback, when the use count for a foo object becomes > N. I wish to
> receive notification for no shared_ptr types other than those
> instantiated with foo. Is this possible?
No, I don't believe that it is. Even if it were possible it probably
wouldn't do what you want; in the case where the use count is exactly N you
would receive spurious notifications as shared_ptr<foo> temporaries are
created (and then destroyed.) But this may not be a problem for your
particular use case.
You can do it with intrusive_ptr, though; it gives you control of the
reference count via intrusive_ptr_add_ref and intrusive_ptr_release.