Empty std::vector begin != end
Empty std::vector begin != end
我想知道是否有人经历过空向量,但开始和结束迭代不一样?
感谢
这应该是不可能的。该标准在【集装箱要求概述】/6 中进行了说明
begin()
返回一个迭代器,该迭代器引用容器中的第一个元素。end()
返回一个迭代器是容器的过期结束值。如果容器是空的,则begin() == end();
因此,如果contianer.empty() == true
,则container.begin()
必须等于container.end()
相关文章:
- 如何使用vector.begin()和vector.end()遍历矩阵?
- 在不使用vector.end()的情况下迭代std::vector
- 在实现 std::vector 时,我必须拥有 end() 的"end"指针吗?
- C# 等效于 C++ std::<int>vector.end()
- vector.back()和vector.end()有什么区别
- 标准::复制失败,"cannot seek vector iterator after end"
- 为什么我允许我为std :: vector设置end()
- Segfault from Vector.end()?
- 使用end()--迭代到std::vector的最后一个元素
- Empty std::vector begin != end
- 如何为std::vector设置有效的.begin()和.end()而不使用.resize()
- 查找语句中的"!=vector.end()"是什么意思?
- C++ vector.end() 给出超出范围的结果 - 请告知
- 如何使用 vector.begin() 将向量的向量打印到 vector.end()
- 使用 std::vector 作为 std::map 的键在未找到和使用 reserve() 时不会返回 end()
- C ++擦除std::vector.end(),同时循环遍历所有迭代器
- 将 vector's end() 传递给 std::vector::erase 有效吗?
- 为什么允许擦除vector.end()
- begin() 和 end() 函数不应该是模板类 Vector 的成员函数吗?
- std::find返回vec.end(),而不管值是否在vector中