Question

So I was coding when I run into a Debug assertion. Now I am very interessted why this piece of code does not work:

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

and this piece of code does:

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

In the model class I have this:

typedef std::map<std::string, Mesh*> MeshMap;
Était-ce utile?

La solution

It looks like GetMeshes returns copy and you are trying to compare iterator of one container with iterator of another container. Such comparison is not valid in terms of checked iterators in MSVC. And, thanks to @Mike Seymour, this comparison is not valid according to the C++ standard.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top