C
CFG
Is there a ready-to-use C++ smart pointer class working on top of COM
reference counting mechanism.
Did anyone manage to tailor one of the available smart pointer libs to
handle COM objects?
Probably I can use boost::shared_ptr<T> with custom deleter -
which calls obj->Release() instead of delete obj;
But this workaround is not safe and wasteful (we have two separate
reference counters around: first counter is an internal COM's one, and
second counter is shared_ptr's one)
I had a look at boost::intrusive_ptr<T>. Seems good candidate. Just need to
overload intrusive_ptr_add_ref and intrusive_ptr_release
The other issue with intrusive_ptr is that by default its constructor calls
AddRef which is undesirable.
So, can someone recommend good class to incapsulate COM reference counting?
Level of portability: Windows C++ compilers: Borland, Intel C++, MSVC >= 6.x
reference counting mechanism.
Did anyone manage to tailor one of the available smart pointer libs to
handle COM objects?
Probably I can use boost::shared_ptr<T> with custom deleter -
which calls obj->Release() instead of delete obj;
But this workaround is not safe and wasteful (we have two separate
reference counters around: first counter is an internal COM's one, and
second counter is shared_ptr's one)
I had a look at boost::intrusive_ptr<T>. Seems good candidate. Just need to
overload intrusive_ptr_add_ref and intrusive_ptr_release
The other issue with intrusive_ptr is that by default its constructor calls
AddRef which is undesirable.
So, can someone recommend good class to incapsulate COM reference counting?
Level of portability: Windows C++ compilers: Borland, Intel C++, MSVC >= 6.x