
JOAQUIN M. LOPEZ MUÑOZ: ...
https://svn.boost.org/trac/boost/browser/trunk/boost/flyweight/refcounted.hp...
* TrackingHelper::entry(h) returns the value to which the refcounted_handle h refers (which is implicitly convertible to a refcounted_value). Think of it as a dereference operator.
* TrackingHelper::erase(h,check_erase) deletes the value refered to by h iff check_erase(h) returns true. The execution of this routine happens in a locked context (including the call to check_erase and erasure itself).
* Though it may not be apparent, the execution of explicit refcounted_handle(const Handle&) also happens in a locked context (this is important to the implementation of the refcounting protocol).
Thanks. I think I see it now. Although... I may be missing something, but why doesn't the simple explicit refcounted_handle(const Handle& h_):h(h_) { TrackingHelper::entry(*this).add_ref(); } static bool check_erase(const refcounted_handle& x) { return TrackingHelper::entry(x).count() == 0; } work?