Hello i'm curently coding a fonction that erase element from a vector of pointer(to class object), but i cant quite make it work.
I get this error error: no matching function for call to ‘std::vector<biblio::Reference*>::erase(biblio::Reference*&)’
std::vector<Reference*> m_vReferences; //Reference is a class for ( auto iter : m_vReferences) //Loop for on every pointer to a class object { if (iter->reqId () == p_id) //Check if the id of the class object is the id we want { m_vReferences.erase (iter); //Erase the pointer in the vector of pointer } else { throw EmptyReferenceException (iter->reqFormatedReference ()); //An exception } }
std::erase_if(from C++20 on).for ( auto iter : m_vReferences)is an example of bad naming.itervariable is not an iterator, it is an object of typeBiblio::Reference*.