Re: VC8 Compiler bizarreness
"Murrgon" wrote:
Well, I went through and modified all of the operators to be
const along with their parameters, including the global ones,
but that didn't change anything. I still get the same abiguity
error.
What is the version of your VC++? I tried folowing code with
VC++2008 and it works perfectly:
<code>
namespace GTL {
typedef bool TBool;
#define INL
//
===========================================================================
// TSmartPtr class
//
===========================================================================
template <class TYPE>
class TSmartPtr
{
// Member variables
========================================================
private:
TYPE* m_pRefCountObject; // Reference counting object
// <... snipped for brevity ...>
public:
// Boolean operators
=====================================================
TBool operator!()
{
return(NULL == m_pRefCountObject);
}
TBool operator==(const TSmartPtr& kObject)
{
return(m_pRefCountObject == kObject.m_pRefCountObject);
}
TBool operator==(TYPE* ptr)
{
return(m_pRefCountObject == ptr);
}
TBool operator!=(const TSmartPtr& kObject)
{
return(m_pRefCountObject != kObject.m_pRefCountObject);
}
// Uncomment "const" to eliminate the compilation error.
//
TBool operator!=(TYPE* ptr) /*const*/
{
return(m_pRefCountObject != ptr);
}
friend INL TBool operator==(TYPE* ptr, const TSmartPtr<TYPE>&
kObject)
{
return(kObject == ptr);
}
friend INL TBool operator!=(TYPE* ptr, const TSmartPtr<TYPE>&
kObject)
{
return(kObject != ptr);
}
};
} // namespace GTL
using namespace GTL;
class TTexture {};
typedef TSmartPtr<TTexture> TTexturePtr;
typedef std::vector<TTexturePtr> TTexturePtrArray;
int _tmain(int /*argc*/, _TCHAR* /*argv*/[])
{
TTexturePtrArray apTextures;
for (UINT i = 0; apTextures.size() > i; ++i)
{
if (NULL != apTextures[i])
{
// Do something
}
}
return 0;
}
</code>
HTH
Alex