在vc2010多线程环境下使用std标准模板库容器 list 时, 如果是DEBUG版本, 迭代器存在BUG
#if _ITERATOR_DEBUG_LEVEL == 2
void _Orphan_ptr(_Myt& _Cont, _Nodeptr _Ptr) const
{ // orphan iterators with specified node pointers
_Lockit _Lock(_LOCK_DEBUG);
const_iterator **_Pnext = (const_iterator **)_Cont._Getpfirst();
if (_Pnext != 0)
while (*_Pnext != 0)
if ((*_Pnext)->_Ptr == this->_Myhead
|| _Ptr != 0 && (*_Pnext)->_Ptr != _Ptr)
_Pnext = (const_iterator **)(*_Pnext)->_Getpnext();
else
{ // orphan the iterator
(*_Pnext)->_Clrcont();
*_Pnext = *(const_iterator **)(*_Pnext)->_Getpnext();
}
}
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
解决办法,跟踪_ITERATOR_DEBUG_LEVEL 宏定义,打开yvals.h文件,将157行的
#define _HAS_ITERATOR_DEBUGGING 1 改为 #define _HAS_ITERATOR_DEBUGGING 0