Let's say I have n arrays (right now I have 4 but that might go up) and they're supposed to be of the same size, but since I'm fetching them from outside the code I want to be sure
std::vector<int> v0 = {1,2,3};
std::vector<Custom> v1 = {Custom("a"), Custom("b"), Custom("c")};
std::vector<double> v2 = {7.,8.,9.};
std::vector<QColor> v3 = {Qt::Black, Qt::White, Qt::Orange};
if(v0.size() == v1.size() && v1.size() == v2.size() && v2.size() == v3.size()) {
return true;
} else {
return false;
}
Is there any elegant way to make a function that would check for any mismatch in size ?
struct/classcontaining data members for all the data (of typesint,Custom,doubleetc.) and then have onestd::vectorholding this aggregate type.if (x) return true; else return false;can be written much more clearly asreturn x;.