To check if a vector has all equal values i usually do this:
std::vector<bool> myVec(3);
if(std::adjacent_find(myVec.begin(), myVec.end(), std::not_equal_to<>()) == myVec.end()){
// do if every value is the same
}
How can i use it to check if a vector of vectors has all equal values? This would be the case:
std::vector<std::vector<bool>> my2DVec(3, std::vector<bool>(3));
Aucun commentaire:
Enregistrer un commentaire