std::unordered_set<Vector2i> basicWalls = FindWalls(floorPositions, cardinal2D);
std::unordered_set<Vector2i> cornerWalls = FindWalls(floorPositions, Diagonal2D);
printf("basic walls size: %d, corner walls size: %dn", basicWalls.size(), cornerWalls.size());
cornerWalls.erase(basicWalls.begin(),basicWalls.end());//to delete duplicates
printf("basic walls size: %d, corner walls size: %dn", basicWalls.size(), cornerWalls.size());
Wall_World_positions.reserve(basicWalls.size() + cornerWalls.size());
Wall_CollisionBox.reserve(basicWalls.size() + cornerWalls.size());
LoadAppropriateWallTiles(basicWalls, floorPositions, cardinal2D);
unordered set ‘range-erase’ invalidates basicwalls’s iterator, not that of ‘cornerWalls’ whose elements are being erased.
cplusplus.com says ‘Only the iterators and references to the elements removed are invalidated.’
Am I missing something, shouldn’t it be the other way around? I am not trying to delete anything inside basicWalls.
when I comment out cornerWalls.erase, ‘LoadAppropriateWallTiles’ works as intented
error png