gpt4 book ai didi

c++ - 映射/设置迭代器在 std::map 中不可递增

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:59:03 25 4
gpt4 key购买 nike

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));
}
}

最佳答案

从显示的代码来看,迭代器不可能突然变得不可增加。必须有一些其他代码导致错误。

关于c++ - 映射/设置迭代器在 std::map 中不可递增,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12762207/

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