【发布时间】:2013-06-25 12:31:29
【问题描述】:
我收到以下调试错误:
Debug Assertion Failed!
Program: Path\To\vc\include\xtree
Line: 237
Expression: map/set iterator not dereferencable
这些代码行:
for(std::map<int,IO::ctcolor>::iterator it = IO::colorTable.begin(); it != IO::colorTable.end();) {
//left out some code here, but even without it doesn't work
cout << "dummy"; //gets printed multiple times while iterating, so the map is not empty
++it;
}
for 循环遍历IO::colorTable 的所有元素,但在到达末尾时不会停止,我可以在循环内将数据打印到控制台时看到这一点。
编辑:我刚刚注意到错误发生在我错误地尝试访问it的for循环之后的行中
【问题讨论】:
-
你是通过调试器运行的吗?
-
我注意到您在循环末尾放置了一个
++it。您确定您的真实代码中的 for(;;) 语句的增量部分也没有增加吗? -
@Huytard 视觉工作室 2012
-
@dhavenith 是的,我确定是因为我从 Visual Studio 复制并粘贴了代码