shared ptr - Using shared_ptr for refcounting -
i have class objects extensively used using shared_pointers. however, want track usage of these objects , when refcount goes particular value want delete object. how can ? thinking of overriding shared_ptr's destructor can decrement refcount when every shared_ptr reference goes away. however, looks not possible. alternatives ?
you wouldn't want because if refcount greater 0 means there still pointers pointing object out there, intending access it.
if wanted that, you'd have make own shared_ptr class, i'd add functionality checking if pointer still valid since might disappear on people.
Comments
Post a Comment