尽管我已经在程序的每个部分都包含了 try 代码,但我无法获得导致运行时错误的行(没有任何其他详细信息):
"terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check Aborted"
我不知道我应该做什么。该错误是由以下代码引起的,因为它出现在添加这些行之后:
.....
map<int, StaticObject*>::iterator mapPos2;
vector<StaticObject*, boost::pool_allocator<StaticObject*> >::iterator vecPos;
map<int, int>::iterator mapPos = userCountMap.begin();
mapPos2 = this->_cachedObjects.find(this->_lruQueue.at(mapPos->first)->getId());
vecPos = find(this->_lruQueue.begin(),this->_lruQueue.end(), this->_lruQueue.at(mapPos->first));
size -= this->_lruQueue.at(mapPos->first)->getSize();
_availableSpace += this->_lruQueue.at(mapPos->first)->getSize();
delete (*mapPos2).second;
this->_cachedObjects.erase(mapPos2);
this->_lruQueue.erase(vecPos);
............
后来:
map<int, int> userCountMap;
userCountMap.insert(make_pair(object->getId(),1)); ...
this->userCountMap[id]++; ...
this->userCountMap.clear(); ....