vector iterators incompatible when i have collision detection : <p>so i have DEBUG_ERROR("vector iterators incompatible"); whenever i have collision detection between blackHole &amp; planet. but when i have collision detection between anything else like asteroid &amp; planet or blackHole &amp; asteroid, then its work with no problem the code is basically the same but yet with this one i have crash</p>

<pre><code>//Blackhole&amp; Planet Collide
for (vector&lt;Entity*&gt;::iterator it = gameEntities.begin(); it &lt; gameEntities.end(); ++it) // This loop usses an iterator (google c++ iterator) to go through all game entites objects
{
    BlackHole* blackHole1 = dynamic_cast&lt;BlackHole*&gt; (*it); // As the iterator is of generic type Entity we need to convert it to a type we can use, Ball. Dynamic cast performs the conversion only if the entity is actually a Ball otherwise it gives back a null pointer
    if (blackHole1 != nullptr) // we check if the conversion was successful
    {
        for (vector&lt;Entity*&gt;::iterator it1 = gameEntities.begin(); it1 &lt; gameEntities.end(); ++it1) // and we iterate on the remaining elements in the container
        {
            if (it != it1)
            {
                Planet* planet = dynamic_cast&lt;Planet*&gt; (*it1); // we convert the remaining element
                if (planet != nullptr) // check if the conversion happended
                {
                    // collision detection: black hole &amp; planet
                    if (blackHolePlanetCollision(*blackHole1, *planet))
                    {
                        blackHole1-&gt;increaseMass(blackHole1-&gt;getRadius(), planet-&gt;getRadius());
                        delete *it1;
                        it1 = gameEntities.erase(it1);
                        //--it1;
</code></pre>

<p>any idea what is wrong with it? with any other collision this code works</p>
