映射/设置迭代器在 std::map 中不可递增
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));
}
}
迭代器不可能突然从显示的代码中变得不可递增。必须有一些其他代码导致错误。
相关文章:
- 为什么在 std::map 上移动无法将元素从一个映射移动到另一个映射
- 为什么映射插入和 map.find() 的单次迭代比插入和 map.find() 的两次单独迭代慢得多
- 类中的 C++ 全局映射,不要打印 map 元素
- 如何将不同的函数签名映射到同一个 std::map?
- 我尝试使用MAP容器来映射资源,现在RESOURCEFILE正在获取所有信息.为什么
- 当 map 是一个整数数组并且由 operator[] 创建时,它是否初始化其映射类型
- std::map 擦除 - 将迭代器传递给错误的映射
- 线程安全 std::map:锁定整个映射和单个值
- 如何在C++中迭代集合映射(std::map<std::set< char>, int >)?
- 这些会做什么(映射[x] [y] = 2;,map [x] [y] = 3;,以及map [x] [y] = 4;在下面
- 将 JNI -> jobject(基本上是 java 文件中的映射和/或映射的映射)转换为 std::map(c++)
- 为什么要对 map::find 应用不存在的键将返回一个C++中第一个值映射大小的迭代器
- 如何在std :: Map中找到std :: set中的映射中的最小/最大值
- 映射/设置迭代器在 std::map 中不可递增
- map/set迭代器不可递增,我无法从头开始重新启动映射
- 如何在 std::map 中使用 emplace(),其值为 std::set(从某物映射到集合)
- 如何使用boost::mutex作为std::map中的映射类型
- 值类型为std::map的C++std::映射
- 通过引用将 std::map 传递给不更新映射的类的构造函数
- 映射上的模板参数无效 std::map< std::string, Stock*> &Stock