Lately, I was working on a code and found following code:
CComBSTR userName;
SUCCEED(getUserName(userName));
if(userName == NULL) ...
The last line alerts me, since I'm comparing an object against NULL
which is not intuitive. But after a glance on MSDN, it is perfectly supported:
bool operator ==( const CComBSTR& bstrSrc ) const throw( );
bool operator ==( LPCOLESTR pszSrc ) const;
bool operator ==( LPCSTR pszSrc ) const;
bool operator ==( int nNull ) const throw( );
So my question is, why would API design of CComBSTR
allow such a comparison? Just to be more tolerant to errors?