Why does my delete function crash? I've used the same algorithm for other 2D vectors and it works perfectly fine..
I'm trying to remove an array of vectors from a 2D vector all of the std::string type.
//Ripped out of a massive class I wrote.
vector<vector<string>>& Delete(vector<string> StringArrayToDelete, bool CaseSensitive = true, bool All = false)
{
vector<vector<string>> Temp = S2DA; //S2DA is a vector<vector<string>>
//The below works perfectly fine..
if (!CaseSensitive)
{
for (unsigned short I = 0; I < StringArrayToDelete.size(); I++)
for (unsigned short J = 0; J < StringArrayToDelete[I].size(); J++)
StringArrayToDelete[I][J] = tolower(StringArrayToDelete[I][J]);
for (unsigned short I = 0; I < Temp.size(); I++)
for (unsigned short J = 0; J < Temp[I].size(); J++)
for (unsigned short K = 0; K < Temp[I][J].size(); K++)
Temp[I][J][K] = tolower(Temp[I][J][K]);
}
//problem is actually here..
for (unsigned I = 0; I < Temp.size(); I++)
{
if (Temp[I] == StringArrayToDelete)
{
S2DA.erase(S2DA.begin() + I);
if (!All)
break;
I = 0;
}
}
return *this;
}