【发布时间】:2013-11-05 09:20:29
【问题描述】:
所以当我遇到调试断言时,我正在编码。 现在我很感兴趣为什么这段代码不起作用:
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?复制还是参考? -
@ForEveR:这里的美妙之处在于,无论答案如何,这意味着两个版本都被严重破坏了......
-
调试断言说什么?它真的发生在 for 行还是循环中的某处?
-
@ForEveR:GetMeshes 返回我想使用的地图。 MeshMap GetMeshes() {return m_Meshes;} m_Meshes = Meshmap 类型。
标签: c++ debugging iterator stdmap assertion