I have a vector of vectors to establish a map of integers, and I would love to catch a vector out of range error whenever it is thrown, by doing the following:
vector< vector<int> > agrid(sizeX, vector<int>(sizeY));
try {
agrid[-1][-1] = 5; //throws an out-of-range
}
catch (const std::out_of_range& e) {
cout << "Out of Range error.";
}
However, my code doesn't seem to be catching the error at all. It still seems to want to run std::terminate. Does anyone know whats up with this?