Re: VC8 Compiler bizarreness
- From: Murrgon <murrgon@xxxxxxxxxxx>
- Date: Wed, 04 Jun 2008 16:42:53 -0400
Alex Blekhman wrote:
"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.
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.
Good suggestion though :)
Murrgon
.
- Follow-Ups:
- Re: VC8 Compiler bizarreness
- From: Alex Blekhman
- Re: VC8 Compiler bizarreness
- References:
- VC8 Compiler bizarreness
- From: Murrgon
- Re: VC8 Compiler bizarreness
- From: Bo Persson
- Re: VC8 Compiler bizarreness
- From: Murrgon
- Re: VC8 Compiler bizarreness
- From: Victor Bazarov
- Re: VC8 Compiler bizarreness
- From: Murrgon
- Re: VC8 Compiler bizarreness
- From: Alex Blekhman
- Re: VC8 Compiler bizarreness
- From: Murrgon
- Re: VC8 Compiler bizarreness
- From: Alex Blekhman
- VC8 Compiler bizarreness
- Prev by Date: Re: Classes
- Next by Date: Re: VC8 Compiler bizarreness
- Previous by thread: Re: VC8 Compiler bizarreness
- Next by thread: Re: VC8 Compiler bizarreness
- Index(es):
Relevant Pages
|