How is end() implemented in STL containers?

后端 未结 6 2407
小蘑菇
小蘑菇 2021-02-19 12:32

So when we need to traverse a container from start to end we write something like

for (i = v->begin(); i != v->end(); i++)

assuming i

6条回答
  •  无人及你
    2021-02-19 13:02

    "end will always point to one past the last element in container" means that if you increment iterator that points to the last element it will be equal to the result of end(). Implementation can be different. In Visual C++ std::vector::end() returns implementation specific iterator that holds zero pointer.

提交回复
热议问题