Comparing default-constructed iterators with operator==

前端 未结 4 918
清歌不尽
清歌不尽 2021-01-02 03:21

Does the C++ Standard say I should be able to compare two default-constructed STL iterators for equality? Are default-constructed iterators equality-comparable?

I w

4条回答
  •  耶瑟儿~
    2021-01-02 04:02

    I believe you should pass a range to the function.

    void fun(std::list::iterator beg, std::list::iterator end)
    {
        while(beg != end)
        {
            // do what you want here.
            beg++;
        }
    }
    

提交回复
热议问题