mercredi 19 juillet 2017

In C++, Debug assertion failed window pops up & I get vector iterators incompatible error runtime

I've seen some SO links wherein similiar error was seen & was suggessted to use const reference to teh vector as they were copying teh vector (pass by value) but in my scenario I'm using teh same vector (no pass by value). BUt seeing this issue. WRT below code, I'm seeing the error

Debug assertion failed window pops up & I get vector iterators incompatible error

in runtime when the line

itloop !=-endIter

is hit.

typedef vector<vector<string> tableDataType;
vector<tableDataType::Iterator> tabTypeIterVector;
tableDataType table;
FillRows(vector<string> vstr)
{
    table.push_back(vstr);
    if(some_condition_satisfied_for_this_row())
    {
        tableDataType::Iterator rowIT = table.end();
        tabTypeIterVector.push_back(rowIT);
    }
}


In another function:

AccessTableIteratorsVector()
{
auto startIter = table.begin();
auto endIter = tabTypeIterVector[0];
   for(auto itloop=startIter; itloop !=-endIter;itloop++)
   {

   }
}

Aucun commentaire:

Enregistrer un commentaire