65,211
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <assert.h>
#include <set>
using namespace std;
class compareInt
{
public:
bool operator()(const int &a,const int &b)
{
return 1;//如果是return a<b,就正确了,但这么写为啥不对。
}
};
int _tmain(int argc, _TCHAR* argv[])
{
set<int,compareInt> st1;
st1.insert(1);
st1.insert(-1);
return 0;
}
template<class _Pr, class _Ty1, class _Ty2> inline
bool __CLRCALL_OR_CDECL _Debug_lt_pred(_Pr _Pred, const _Ty1& _Left, const _Ty2& _Right,
const wchar_t *_Where, unsigned int _Line)
{ // test if _Pred(_Left, _Right) and _Pred is strict weak ordering
if (!_Pred(_Left, _Right))
return (false);
else if (_Pred(_Right, _Left))
_DEBUG_ERROR2("invalid operator<", _Where, _Line);
return (true);
}

//#include "stdafx.h"
#include <assert.h>
#include <set>
using namespace std;
class compareInt
{
public:
bool operator()(const int &a,const int &b)
{
return 1;//如果是return a<b,就正确了,但这么写为啥不对。
}
};
int main()
{
set<int,compareInt> st1;
st1.insert(1);
st1.insert(-1);
return 0;
}