Vector Iterators Incompatible

后端 未结 10 980
别那么骄傲
别那么骄傲 2020-12-04 23:54

I have a class with a std::vector data member e.g.

class foo{
public:

const std::vector getVec(){return myVec;} //other stuff omitted

private:
s         


        
10条回答
  •  一整个雨季
    2020-12-05 00:49

    Another cause of the MSVC STL debug assertion "vector iterators incompatible" is operating on an invalidated iterator.

    I.e. v.erase(i), and then compare i != v.end() the erase invalidates i and so it cannot be used in a comparison.

提交回复
热议问题