[英]map/set iterator not incrementable in std::map
當it
是循環的最后一次迭代時,在該迭代結束時,將引發此錯誤。
std::map<std::string,std::shared_ptr<Entity>> entities;
typedef std::map<std::shared_ptr<Entity>,std::vector<std::pair<std::shared_ptr<Entity>,const MTV*>>> colmap;
std::map<std::string,std::shared_ptr<Entity>>::iterator it;
for(it = entities.begin();it!=entities.end();++it){
std::map<std::string,std::shared_ptr<Entity>>::iterator it2;
for(it2 = entities.begin();it2!=entities.end();++it2){
MTV* mtv = new MTV(1,sf::Vector2f(1,0));
collisions[it->second].push_back(std::make_pair(it2->second,mtv));
}
}
迭代器絕對不可能從顯示的代碼中突然變得不可增加。 之后必須有其他代碼才能導致錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.