Philipp Henkel wrote:
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?
The technically correct way to use QueryInterface is to pass it the address
of a void*:
void* pv = 0;
someObject->QueryInterface( IID_IVideo, &pv );
IVideo * pv2 = static_cast< IVideo* >( pv );
boost::intrusive_ptr<IVideo> video( pv2 );
pv2->Release();
The (void**) cast is too error-prone, even if you don't care about
technicalities.
This of course can be encapsulated in a function.
template