我正在尝试映射::插入我定义的关键数据类型(miniVec2ui)..它在比较期间中断(比较时它有虚假数据)..它使用标准的 less 仿函数(我自己尝试过,但同样的问题) - 它正在传递 rhs.x = ??? 和 rhs.y = ??? 基本上。代码如下
miniVec2ui v233 = miniVec2ui(x,y);
m_pIdMap->insert(std::pair<miniVec2ui,uint>(v233,(uint)tmpPF.id));// std::pair<const miniVec2ui,uint>(v233, (uint)tmpPF.id) );
//////in other files I defined miniVec2ui,etc. (uint = unsigned int), tmpPF.id unimportant here, uint x; uint y;
typedef std::map<miniVec2ui,uint> eIdMap;
eIdMap *m_pIdMap;
m_pIdMap = new eIdMap;//new std::map<miniVec2ui, uint >;
struct miniVec2ui {
uint x;
uint y;
miniVec2ui(uint inx, uint iny):
x(inx)
,y(iny) { }
bool operator==(const miniVec2ui& rhs) const {
return ((x == rhs.x) && (y == rhs.y));
}
bool operator!=(const miniVec2ui& rhs) const {
return ( (x != rhs.x) || (y != rhs.y) );
}
bool operator< (const miniVec2ui& rhs) const {
return ((x < rhs.x) && (y < rhs.y));
}
bool operator> (const miniVec2ui& rhs) const {
return ((x > rhs.x) && (y > rhs.y));
}
};
具体来说 - 使用 __y 打破 _function_base.h 是 {x=???,y=???}... 这是反汇编:
...stuff...
#endif
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }
200439C0 55 push ebp
200439C1 8B EC mov ebp,esp
200439C3 81 EC CC 00 00 00 sub esp,0CCh
200439C9 53 push ebx
200439CA 56 push esi
200439CB 57 push edi
200439CC 51 push ecx
200439CD 8D BD 34 FF FF FF lea edi,[ebp-0CCh]
200439D3 B9 33 00 00 00 mov ecx,33h
200439D8 B8 CC CC CC CC mov eax,0CCCCCCCCh
200439DD F3 AB rep stos dword ptr es:[edi]
200439DF 59 pop ecx
200439E0 89 4D F8 mov dword ptr [ebp-8],ecx
200439E3 8B 45 0C mov eax,dword ptr [__y]
200439E6 50 push eax
200439E7 8B 4D 08 mov ecx,dword ptr [__x]
200439EA E8 67 84 F1 FF call miniVec2ui::operator< (1FF5BE56h)
200439EF 5F pop edi <--------------------- HERE ---------- <<