【发布时间】:2017-12-29 02:31:29
【问题描述】:
参考这个previous SO question,我纠正了我的错误并将迭代器更改为相同的“向量类型”,即
我换了行
auto startIter = table.begin();
与
auto startIter = tabTypeIterVector[0];
在 AccessTableIteratorsVector() 函数的 for 循环中。 但是,在下面的代码中,我仍然收到“调试断言失败,向量迭代器不兼容错误, 当此行在 for 循环中被命中时
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++)
{
}
}
【问题讨论】:
-
为什么你要存储一个迭代器向量?应该解决的实际问题是什么?
-
……你为什么不简单地存储索引,它不会变得无效。
标签: c++ c++11 vector iterator incompatibletypeerror