Use a shared_ptr to a scoped_ptr to the resource (shared_ptr>). That way you get shared_ptr's reference counting, which will automatically destroy the resource if and only if it's still attached to the scoped_ptr. But you can detach the scoped_ptr when you're ready to hand off ownership.