I have code -
for (auto i = _entities.begin(); i != _entities.end();) {
std::shared_ptr<Entity> entity = *i;
if (entity == nullptr || entity->is_dead()) {
i = _entities.erase(i);
continue;
}
entity->update(diff);
++i;
}
I get this error -
can't increment invalidated vector iterator
for the last line.
I don't know how it is causing the vector to be invalidated.