I'm making a small game and I'm atempting to use vector as a container to store all entites in the world. However I need a way to frequently insert and delete entites. I'm currently using this to delete entities:
std::swap(m_entities[index], m_entities.back());
m_entities.pop_back();
But I have no way of checking if an item exists so it crashes if I accidently try to remove item. Also the index is stored in the entity so the index will be invalid for the swapped entity right? Should I use an unordered_map instead?