I heard boost has a foreach loop
std::vector< std::vector<int> > v;
BOOST_FOREACH(std::vector<int> const &i, test) {
v.push_back(std::vector<int>(i.end() - 2, i.end()));
}
If you didn’t increase your arms, I would go with the usual loop. But I don’t think I would use nested first std::vector. If you have only two rows with two columns, it is best to use a vector boost::array<int, 2>.
source
share