Using shared_ptr in C interfaces?

The problem with shared_ptr, as you'll have figured out already, is that you can't modify the reference count except by constructing or destroying instances. So no, there's no way to get this to work except by keeping a shared_ptr to every constructed Object around until its reference count drops to zero, but doing that right entails redoing much of the reference counting, so you gain very little.

Perhaps boost::intrusive_ptr is a better option.

Tags:

C++

C

Shared Ptr