gpt4 book ai didi

c++ - typedef 映射、for 循环调试断言、映射/设置不兼容

转载 作者:行者123 更新时间:2023-11-28 03:05:46 30 4
gpt4 key购买 nike

因此,当我遇到调试断言时,我正在编写代码。现在我很想知道为什么这段代码不起作用:

for(Model::MeshMap::iterator it = obj1->GetMeshes().begin(); it != obj1->GetMeshes().end(); it++)

这段代码可以:

Model::MeshMap obj1meshes = obj1->GetMeshes();
for(Model::MeshMap::iterator it = obj1meshes.begin(); it != obj1meshes.end(); it++)

在模型类中我有这个:

typedef std::map<std::string, Mesh*> MeshMap;

最佳答案

看起来 GetMeshes 返回拷贝,您正在尝试比较一个容器的 iterator 与另一个容器的 iterator。就 MSVC 中的已检查迭代器而言,此类比较无效。而且,感谢@Mike Seymour,根据 C++ 标准,这种比较是无效的。

关于c++ - typedef 映射、for 循环调试断言、映射/设置不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19785402/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com