我创建了一个程序,它使用vector.h #include和迭代器等......但是当我运行程序时,在某些情况下(我仍在试图弄清楚那些会是什么)我得到一个断言将我引至 vector.h 的第 98 行时出错。我去了vector.h的第98行并得到了这个:
#if _HAS_ITERATOR_DEBUGGING
if (this->_Mycont == 0
|| _Myptr < ((_Myvec *)this->_Mycont)->_Myfirst
|| ((_Myvec *)this->_Mycont)->_Mylast <= _Myptr)
{
_DEBUG_ERROR("vector iterator not dereferencable");
_SCL_SECURE_OUT_OF_RANGE;
}
有人可以告诉我这意味着什么以及我的程序中是什么导致了这个断言吗?
注意:记录在案的第 98 行是开始于 "_DEBUG_ERROR("vect..."
注意:这是我认为触发错误的程序中的代码,不过我不完全确定。
代码:
for(aI = antiviral_data.begin(); aI < antiviral_data.end();)
{
for(vI = viral_data.begin(); vI < viral_data.end();)
{
if((*aI)->x == (*vI)->x && (*aI)->y == (*vI)->y)
{
vI = viral_data.erase(vI);
aI = antiviral_data.erase(aI);
}
else
{
vI++;
}
}
if((*aI)->x >= maxx || (*aI)->x < 0 || (*aI)->y >= maxy || (*aI)->y < 0)
{
aI = antiviral_data.erase(aI);
}
else
{
aI++;
}
}