The problem is not so much that it doesn't work in debug, as it is that it appears to work in release - the code is equally broken in both, but the debug version of the library has some extra error-checking code.
The error message is a bit cryptic, but what it's trying to say is that you're attempting to increment an iterator that can't be incremented.
This happens because test[6].erase(test_iter);
invalidates test_iter
, and using it after that is undefined.
erase
returns an iterator to the element following the erased element, and you can use this iterator instead of incrementing:
for (test_iter = test[6].begin(); test_iter != test[6].end(); /* empty */)
{
std::cout << *test_iter << std::endl;
test_iter = test[6].erase(test_iter);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…