binary '<' : no operator found which takes a left-hand operand of type
-
Wednesday, March 21, 2007 5:18 PM
I am getting the following error messages when i compile this code in visual studio 2005
struct
SymEntry{
inline SymEntry(ProgramCounter addr, const std::string& symbol): m_addr(addr), m_symbol(symbol)
{}
friend bool operator<(const SymEntry&, ProgramCounter); friend bool operator<(const SymEntry&, const SymEntry&);ProgramCounter m_addr;
std::string m_symbol;
};
typedef
std::vector<SymEntry> SymbolList;typedef
std::vector<SymEntry*> SymbolPtrList;inline
bool operator<(const SymEntry& left, ProgramCounter addr){
return left.m_addr < addr;}
inline
bool operator<(const SymEntry& left, const SymEntry& right){
return left.m_addr < right.m_addr;}
c:\program files\microsoft visual studio 8\vc\include\xutility(267) : error C2678: binary '<' : no operator found which takes a left-hand operand of type 'const ProgramCounter' (or there is no acceptable conversion)
c:\look\dev\make\toolslib\symbolmap_int.h(15): could be 'bool operator <(const SymEntry &,ProgramCounter)' [found using argument-dependent lookup]
c:\look\dev\make\toolslib\symbolmap_int.h(16): or 'bool operator <(const SymEntry &,const SymEntry &)' [found using argument-dependent lookup]
while trying to match the argument list '(const ProgramCounter, SymEntry)'
c:\program files\microsoft visual studio 8\vc\include\algorithm(2268) : see reference to function template instantiation 'bool std::_Debug_lt<SymEntry,_Ty>(_Ty1 &,const _Ty2 &,const wchar_t *,unsigned int)' being compiled
with
[
_Ty=ProgramCounter,
_Ty1=SymEntry,
_Ty2=ProgramCounter
]
===============================================================================================
c:\program files\microsoft visual studio 8\vc\include\algorithm(2280) : see reference to function template instantiation '_FwdIt std::_Lower_bound<std::_Vector_iterator<_Ty,_Alloc>,unsigned int,__w64 int>(_FwdIt,_FwdIt,const unsigned int &,_Diff *)' being compiled
with
[
_FwdIt=std::_Vector_iterator<SymEntry,std::allocator<SymEntry>>,
_Ty=SymEntry,
_Alloc=std::allocator<SymEntry>,
_Diff=__w64 int
]
c:\dev\make\toolslib\symbolmap.cpp(77) : see reference to function template instantiation '_FwdIt std::lower_bound<std::_Vector_iterator<_Ty,_Alloc>,ProgramCounter>(_FwdIt,_FwdIt,const unsigned int &)' being compiled
with
[
_FwdIt=std::_Vector_iterator<SymEntry,std::allocator<SymEntry>>,
_Ty=SymEntry,
_Alloc=std::allocator<SymEntry>
]
All Replies
-
Wednesday, March 21, 2007 5:23 PMAny help in this regard would he helpful.
-
Wednesday, March 21, 2007 5:46 PM
You didn't make an operator < that takes a ProgramCounter as a left-hand operand. You need an operator of the form
bool operator<( ProgramCounter addr, const SymEntry& right )
-
Wednesday, March 21, 2007 6:40 PM
It Reports the same error. This Code works in Vc++6.0 and doesnt in Visual Studio 5.0
c:\program files\microsoft visual studio 8\vc\include\xutility(265) : error C2678: binary '<' : no operator found which takes a left-hand operand of type 'SymEntry' (or there is no acceptable conversion)
c:\symbolmap_int.h(15): could be 'bool operator <(ProgramCounter,const SymEntry &)' [found using argument-dependent lookup]
c:\symbolmap_int.h(16): or 'bool operator <(const SymEntry &,const SymEntry &)' [found using argument-dependent lookup]
while trying to match the argument list '(SymEntry, const ProgramCounter)'
c:\program files\microsoft visual studio 8\vc\include\algorithm(2268) : see reference to function template instantiation 'bool std::_Debug_lt<SymEntry,_Ty>(_Ty1 &,const _Ty2 &,const wchar_t *,unsigned int)' being compiled
with
[
_Ty=ProgramCounter,
_Ty1=SymEntry,
_Ty2=ProgramCounter
]
c:\program files\microsoft visual studio 8\vc\include\algorithm(2280) : see reference to function template instantiation '_FwdIt std::_Lower_bound<std::_Vector_iterator<_Ty,_Alloc>,unsigned int,__w64 int>(_FwdIt,_FwdIt,const unsigned int &,_Diff *)' being compiled
with
[
_FwdIt=std::_Vector_iterator<SymEntry,std::allocator<SymEntry>>,
_Ty=SymEntry,
_Alloc=std::allocator<SymEntry>,
_Diff=__w64 int
]
c:\pam.look\dev\make\toolslib\symbolmap.cpp(77) : see reference to function template instantiation '_FwdIt std::lower_bound<std::_Vector_iterator<_Ty,_Alloc>,ProgramCounter>(_FwdIt,_FwdIt,const unsigned int &)' being compiled
with
[
_FwdIt=std::_Vector_iterator<SymEntry,std::allocator<SymEntry>>,
_Ty=SymEntry,
_Alloc=std::allocator<SymEntry>
] -
Wednesday, March 21, 2007 7:55 PMModerator
It looks like you need both variants:
bool operator<(ProgramCounter, const SymEntry&)
bool operator<(const SymEntry&, ProgramCounter) -
Wednesday, March 21, 2007 9:02 PMThanks Jonathan...It worked...

