2

このコードでエラーが発生するのはなぜですか: Vector iterators incompatible

このコードは、Rogue Wave ファイル tpordvec.h に遡ります。

    std::vector<T*> v;
    const T* a  // Where T is a template Class 
    for (std::vector<T*>::iterator p = v.begin(); p != v.end(); p++)
    {
        if (**p == *a)
        {
            T* temp = *p;
            if ( v.erase(p) == v.end()) //ASSERTION ERROR HERE
               return NULL;

            return temp;
        }
    }
4

1 に答える 1