Vector iterator not dereferencable!
I got the error in the direction of this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
for(auto vo = vList.begin(); vo != vList.end(); vo++)
{
sdelcoord = ((*vo)); lastString = *sdelcoord.rbegin();
int num, longnum;
std::string sod;
sod = sdelcoord;
sod.erase(0, sod.size()-2);
num = atoi(sod.c_str());
sod = sdelcoord;
sod.erase(0, sod.size()-3);
longnum = atoi(sod.c_str());
if(num > 9 && num < 100)
lastString = static_cast<std::ostringstream*>( &(std::ostringstream() << num) )->str();
else if(longnum > 99 && longnum < 1000)
lastString = static_cast<std::ostringstream*>( &(std::ostringstream() << longnum) )->str();
std::cout << lastString.c_str() << " " << ash << " " << std::endl;
sash = static_cast<std::ostringstream*>( &(std::ostringstream() << ash) )->str();
if(lastString == sash && pause == false)
{
delete (*co);
(*co) = nullptr;
co = mList.erase(co);
std::cout << (*vo) << std::endl;
vo = vList.erase(vo); std::cout << "brick deleted?" << std::endl; // I think the Problem is here
std::cout << "Here: " << (*vo) << "<-- Should be previous" << std::endl;
pause = true;
}
lastString.clear();
sash.clear();
std::cout << "last workpoint" << std::endl; // Here is the last output I can do
}
pause = false;
}
|
Does someone know, what I did wrong?
This is a loop from a vector "vList", but this loop is in a other loop from <list> "mList"
Last edited on
vo is the value, not an iterator
Topic archived. No new replies allowed.