Re: [Boost-users] COM and boost::intrusive_ptr
________________________________________
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Philipp Henkel
Sent: Thursday, January 04, 2007 12:34 PM
To: boost-users@lists.boost.org
Subject: [Boost-users] COM and boost::intrusive_ptr
1. I need to access the address of the raw pointer (to use QueryInterface). Therefore I
implemented operator& for intrusive_ptr. Like in COM this pointer-pointer will only
be used for intialization purposes. My implementation relies on the intrusive_ptr's
memory layout and returns reinterpret_cast
CComPtr-like usage: boost::intrusive_ptr<IVideo> video; someObject->QueryInterface(IID_IVideo,(void**)&video);
Is there a better way? How do you bring intrusive_ptr and QueryInterface together?
[Nat] Sorry if this is naïve...
Wouldn't it work to do something like this?
IVideo* temp_video = NULL; someObject->QueryInterface(IID_IVideo, &temp_video); boost::intrusive_ptr<IVideo> video(temp_video);
As the construction of the intrusive_ptr increases the ref count you have
to call temp_video->Release(); afterwards. Anyway, in my opinion this obvious solution is too error-prone.
participants (2)
-
Nat Goodspeed
-
Philipp Henkel