Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/137.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ typedef映射,针对循环的调试断言,映射/设置不兼容_C++_Debugging_Iterator_Stdmap_Assertion - Fatal编程技术网

C++ typedef映射,针对循环的调试断言,映射/设置不兼容

C++ typedef映射,针对循环的调试断言,映射/设置不兼容,c++,debugging,iterator,stdmap,assertion,C++,Debugging,Iterator,Stdmap,Assertion,因此,当我遇到调试断言时,我正在编写代码。 现在我非常感兴趣的是为什么这段代码不起作用: for(Model::MeshMap::iterator it = obj1->GetMeshes().begin(); it != obj1->GetMeshes().end(); it++) 这段代码的作用是: Model::MeshMap obj1meshes = obj1->GetMeshes(); for(Model::MeshMap::iterator it = obj1me

因此,当我遇到调试断言时,我正在编写代码。 现在我非常感兴趣的是为什么这段代码不起作用:

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;
typedef std::map MeshMap;

它看起来像是
getmesh
返回copy,您试图将一个容器的
iterator
与另一个容器的
iterator
进行比较。就MSVC中的检查迭代器而言,这种比较是无效的。而且,由于@ Mike Seymour,这种比较是不符合C++标准的。< /P>什么返回<代码> GetMeshes < /代码>?复制,还是引用?@ForEveR:这里的美妙之处在于,无论答案是什么,这意味着两个版本都被严重破坏了……调试断言说了什么?它真的发生在for行还是循环中的某个地方?@ForEveR:getmesh返回我想要使用的地图。MESMAP GETMESSHER(){MeMeMesh;} MyMesh=类型MEMHMAP。更重要的是,这种比较是不符合C++标准的。AHA,因此创建网格映射的副本?这是通过使用参考来解决的。谢谢