If you are using this style and when you erase()
items in vector, be careful dont perform ++iterator
.
Since the pointer to the item that you erase()
, it already release, so the pointer target will become unknown,
and causing undefined behaviour if the iteration keep going.
It is possible cause the vector iteration out-of-bound.
template <class T>
void Container<T>::removeValue(T *value, bool deletePointer)
{
for (iterator i = values.begin(); i != values.end(); ) {