I’m doing some COM programming and my compiler is gcc. That means CComPtr is not available for me. How can I easily implement a replacement by using Boost? The semantics I need are:
-
Call
AddRefwhen copied -
Call
Releasewhen destructed -
Extra: be able to tell if the object it points to is still valid (not sure if this is possible)
I think it might be possible to use shared_ptr with a custom deleter, but I’m not very familiar with those features (I also don’t know how to make it call AddRef and Release). I know I can hand-craft this class, but I’m pretty sure that this functionality is available in Boost in a generalized form.
Check out the HILO project, it rolls it’s own CComPtr implementation.