How is end() implemented in STL containers?

后端 未结 6 2381
小蘑菇
小蘑菇 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 12:44

    C++03 Section 23.1/7 says

    begin() returns an iterator referring to the first element in the container.

    end() returns an iterator which is the past-the-end value for the container.

    If the container is empty, then begin() == end();

提交回复
热议问题