VC8 Compiler bizarreness



class TTexture;
typedef TSmartPtr<TTexture> TTexturePtr;
typedef TArray<TTexturePtr> TTexturePtrArray;

TTexturePtrArray apTextures;

I am having the most bizarre compiler error. Code that has been working
for years all of a sudden, in one particular case, throws a compiler
error:

for (UINT i = 0; apTextures.Size() > i; ++i)
{
if (NULL != apTextures[i])
{
// Do something
}
}

error C2593: 'operator !=' is ambiguous

As this is dealing with templates, the compiler comes along and tells you
what types it thinks might fit. The weird part is, none of the suggested
types have anything to do with a TTexture. What? I don't know how the
compiler resolves the types, but something is messed up.

I can get around the problem by either typecasting NULL to a TTexture* or
reversing the order of the comparison (i.e. apTextures[i] != NULL), but I
shouldn't need to. This code is used in countless other instances and
all of them compile just fine.

Murrgon
.


Loading