Boost logo

Boost Users :

From: Philipp Henkel (threadpool_at_[hidden])
Date: 2007-01-04 14:53:37


>
>
> 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.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net