I have successfully used _com_ptr_t with the ID3D11Device and IDXGISwapChain but when applying the same reasoning to the RenderTargetView and DepthStencilView, the function m_spD3DImmediateContext->OMSetRenderTargets(...) sets the m_spRenderTargetView smart COM pointer to null! Then, subsequent draw calls fail on ClearRenderTargetView and ClearDepthStencilView.
Is it because I am passing the smart pointer incorrectly?
HR(m_spD3DDevice->CreateRenderTargetView(pBackBuffer, 0, &m_spRenderTargetView));
...
HR(m_spD3DDevice->CreateTexture2D(&stDepthStencilDesc, 0, &m_spDepthStencilBuffer));
...
m_spD3DImmediateContext->OMSetRenderTargets(1, &m_spRenderTargetView, m_spDepthStencilView);
assert(m_spRenderTargetView); // <=== FAIL
I think the smart pointer overloads the operator& so that it returns an Interface** (see Extractors in _com_ptr_t class).