-2

Although I've wrapped the try code around every part of my program I can't get the line that causes the runtime error (without any other details):

"terminate called after throwing an instance of 'std::out_of_range'
what():  vector::_M_range_check Aborted"

and I don't know what I am supposed to do. The error is caused by following piece of code, since it appears after addition of these lines:

.....
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);  
............

and later on:

map<int, int> userCountMap;

userCountMap.insert(make_pair(object->getId(),1)); ...
this->userCountMap[id]++; ...
this->userCountMap.clear(); ....
Cory Kramer
  • 114,268
  • 16
  • 167
  • 218
gauche_z
  • 1
  • 3

1 Answers1

2

std::out_of_range is thrown by std::vector::at if the index is out of range of valid values (that is, [0..size-1]).

Try wrapping the lines calling that function with try/catch blocks and see which one throws. Then, fire up your debugger and find out why the index is out of range.

jrok
  • 54,456
  • 9
  • 109
  • 141