stl 地图以结构体为key时出现的有关问题

stl map以结构体为key时出现的问题
struct item{
 int xx;
 int yy;
 item(int x, int y) :xx(x), yy(y){}
 bool operator<(const  item& z)const
 {
 if (xx <= z.xx)return true;
 return false;
 }
 

 };
 void main(void)
 {
 map<item, int> mc;
 mc.insert(pair<item, int>(item(15, 5), 0));
//  mc.insert(pair<item, int>(item(15, 5), 0));
 mc.insert(pair<item, int>(item(14, 5), 0));
}

如上,对于结构体key定义了"<"的重载,在LINUX下编译运行时,重复插入(15, 5)和(15, 5)key没有问题
但是在VS下重复插入就会报运行时错误(注意key里面的比较逻辑是只比较key的首元素)
请问各位大大,这个是为什么
------解决思路----------------------
return xx < z.xx;
参见
http://bbs.****.net/topics/391831890

------解决思路----------------------
引用:
Quote: 引用:

错误内容是什么,贴出来瞧瞧

错误是个VS的警告框
说是 vc/include/xtree  line 1795
expression:invalid operator <


错误都有了,粘进去百度一下不就解决了.
我已经百度到了http://bbs.****.net/topics/390311481
问题就是vs它还反过来检查, 发现矛盾, 就报错
你operator<方法里面用了<=, 所以相同的比较结果为true, 反过来还是为true, vs绝对它被骗了, 就报错.

------解决思路----------------------
如果想插入重复的元素,请用multimap
------解决思路----------------------
排序过程中,当两个元素大小相等而被交换了顺序时,称为不稳定排序,即明显不需要交换的两个元素却被交换了,作了无用功。
两个平台的stl实现有所差异吧,win这边要求必须是稳定排序,所以会对两两元素间的大小关系双重判断,如果检查到a<b和b<a都成立,就会报错。

template<class _Pr, class _Ty1, class _Ty2> inline
bool _Debug_lt_pred(_Pr _Pred,
const _Ty1& _Left, _Ty2& _Right,
_Dbfile_t _File, _Dbline_t _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<", _File, _Line);
return (true);
}