dimanche 23 juillet 2017

Vector iterators incompatible error for a vector holding iterators of another vector

With reference to this previous SO question , I corrected my mistake & changed the iterators to be of same "vector type" i.e.

I replaced the line

auto startIter = table.begin();

with

auto startIter = tabTypeIterVector[0];

in the for loop in AccessTableIteratorsVector() function. wrt below code, however, I'm still getting the "Debug assertion failed, vector iterators incompatible error, when this line is hit in for loop

itloop !=-endIter

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 =  tabTypeIterVector[0];
auto endIter = tabTypeIterVector[1];
   for(auto itloop=startIter; itloop !=-endIter;itloop++)
   {

   }
}

Aucun commentaire:

Enregistrer un commentaire