andi_

I post this for a colleague of mine..

Dear all,

below you find an example of my current compiling probs. The problem occurs if I want to compile the debug-build, not the relase.

So I guess that this is a difference in the implementation of the lower_bound template.

This is my class std::lower_bound should search with. The operator< is defined here:

static struct ErrorMapItem

{

int iID;

const char* strError;

ErrorMapItem( int iID, const char* pcErrorString= 0 )

:iID(iID), strError(pcErrorString) {};

bool operator== ( const ErrorMapItem& rhs )

{

return ( iID == rhs.iID );

}

bool operator< (const ErrorMapItem& rhs)

{

return ( iID < rhs.iID );

}

} g_ErrorMap[] = {

ErrorMapItem( 1,"kleiner Fehler" ),

ErrorMapItem( 2,"grosser Fehler" )

};

const int g_iNumOfErrorsInMap= sizeof(g_ErrorMap)/sizeof(g_ErrorMap[0]);

[...]

Later on in my code I call the lower_bound function.

lower_bound( g_ErrorMap, pEnd, TargetError)

And finally this is my compile log:

ft Visual Studio 8\VC\include\xutility(267) : error C2678: binary '<' : no operator found which takes a left-hand operand of type 'const ErrorMapItem' (or there is no acceptable conversion)

.\tcpview.cpp(40): could be 'bool ErrorMapItem::operator <(const ErrorMapItem &)'

while trying to match the argument list '(const ErrorMapItem, ErrorMapItem)'

D:\Programme\Microsoft Visual Studio 8\VC\include\algorithm(2268) : see reference to function template instantiation 'bool std::_Debug_lt<ErrorMapItem,_Ty>(_Ty1 &,const _Ty2 &,const wchar_t *,unsigned int)' being compiled

with

[

_Ty=ErrorMapItem,

_Ty1=ErrorMapItem,

_Ty2=ErrorMapItem

]

D:\Programme\Microsoft Visual Studio 8\VC\include\algorithm(2280) : see reference to function template instantiation '_FwdIt std::_Lower_bound<ErrorMapItem*,_Ty,std::iterator_traits<_Iter>::difference_type>(_FwdIt,_FwdIt,const _Ty &,_Diff *)' being compiled

with

[

_FwdIt=ErrorMapItem *,

_Ty=ErrorMapItem,

_Iter=ErrorMapItem *,

_Diff=std::iterator_traits<ErrorMapItem *>::difference_type

]

.\tcpview.cpp(729) : see reference to function template instantiation '_FwdIt std::lower_bound<ErrorMapItem*,ErrorMapItem>(_FwdIt,_FwdIt,const _Ty &)' being compiled

with

[

_FwdIt=ErrorMapItem *,

_Ty=ErrorMapItem

]

Can someone confirm my guess

Thanx in advance,

thomas



Re: Visual C++ General STL library compiler problem debug <-> release version ?

Viorel.

I hope adding of "const" can help:

bool operator == ( const ErrorMapItem & rhs ) const

{

    . . .

}

 

bool operator < (const ErrorMapItem & rhs) const

{

    . . .

}

 





Re: Visual C++ General STL library compiler problem debug <-> release version ?

andi_

mui bien. :)

problem solved + many thanks!!