Re: VC8 Compiler bizarreness
"Murrgon" wrote:
I think that the culprit is `GTL::TSmartPtr<TYPE>' template.
It does define operator!=(), but the classes it's suggesting as
the TYPE
don't.
The non relevant classes are te quirk of Koenig lookup that
compiler tries to perform. It founds a lot of other `operator !='
in different namespaces however fails to match the arguments. The
real error is with TSmartPtr. See comments inline.
[...]
TBool operator!=(TYPE* ptr)
{
return(m_pRefCountObject != ptr);
}
The above function must be const. Compilation fails because
compiler cannot find appropriate const `operator !=' function for
the statement "kObject != ptr".
friend INL TBool operator!=(TYPE* ptr, const
TSmartPtr<TYPE>& kObject)
{
return(kObject != ptr);
}
As you can see, global `operatpr !=' accepts kObject parameter as
constant reference. Compiler cannot call non-constant function on
this reference in return statement. So, the fix is:
TBool operator!=(const TYPE* ptr) const
{
return(m_pRefCountObject != ptr);
}
I added another `const' qualifier for `ptr' parameter, so the
operator is more generous about its input. Also, you should fix
other member functions and operators of `TSmartPtr' class, so if a
function does not change the object it have to be qualified as
const. Global operator should accept const values, too.
HTH
Alex