I have a legacy class whose lifetime is managed by reference counting (it derives from ACE_Event_Handler, to be precise).
I want to be able to manage it using std::shared_ptr in my code but still keep the old legacy reference counting (objects of the class need to be accessed by a third-party library that doesn't accept shared_ptr - ACE, to be precise).
An object must be deleted when the reference count drops to 0 and all of the shared_ptr instances managing it get destroyed.
I have only one idea: keep an instance of shared_ptr pointing to the object until the reference count drops to 0 and then reset it. Somehow, this feel dirty. Is there a better way?
boost::intrusive_ptrseems like a better fit thanstd::shared_ptr. If boost isn't an option, then rolling your owninstrusive_ptr-like class is probably your only option. - Miles Budnek