3 Apr
2006
3 Apr
'06
8:41 p.m.
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.