出错时堆栈信息:
#0 0x001a03f0 in std::string::compare () from lib/libstdc++.so.6
#1 0x003c4b56 in std::operator< , std::allocator > (__lhs=@0x91a4228, __rhs=@0x96b1afc4)
at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/basic_string.h:2213
#2 0x003c4b74 in std::lessstd::string::operator() (this=0x91a4218, __x=@0x91a4228, __y=@0x96b1afc4)
at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_function.h:227
#3 0x017d4e25 in std::_Rb_tree, std::_Select1st >, std::lessstd::string, std::allocator > >::lower_bound (this=0x91a4218, __k=@0x96b1afc4)
at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_tree.h:1371
#4 0x017d4ea3 in std::map, std::allocator > >::lower_bound (this=0x91a4218, __x=@0x96b1afc4) at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_map.h:576
#5 0x017dbbf2 in std::map, std::allocator > >::operator at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_map.h:345
出错的语句:
pEntity->m_mapID[log.strID]=log;
我对stl不太了解,请问这个错误可能是什么什么原因?
感觉你把代码贴出来更容易找到错误。感觉使用STL时编译器给出的出错信息好多并没什么用
log.strID 这个字符串是不是一个合法的字符串
pEntity->m_mapID[log.strID]=log;这里面的变量类型你得贴出来啊,要不怎么知道问题在哪
看着像strID不对,上代码吧
pEntity->m_mapID[log.strID]=log;
确定好pEntity,pEntity->m_mapID,log.strID,log这几个变量都是合法的,也就是在内存中没有被释放。
pEntity->m_mapID[log.strID]=log;
这句,先判断 pEntity 是否为null, 在判断 pEntity->m_mapID 是否为null,在判断 log.strID是否合法, 在判断 pEntity->m_mapID是否已满,在判断
log 是否 合法