1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| typedef std::vector<std::string> row_t
typedef std::vector<row_t> table_t;
typedef std::reference_wrapper<table_t> table_ref;
typedef std::reference_wrapper<table_t const> table_cref;
std::map<unsigned int, table_t> tables;
auto tabList = {0, 2, 3}; // vient de la ligne de commande, peut être n'importe quel conteneur
std::vector<table_cref> workingTables;
workingTables.reserve(tabList.size());
for(auto id: tabList) {
auto it = tables.find(id)
if(it != tables.end()) {
workingTables.emplace_back((*it).second);
}
}
// tester que les tables 0, 2 et 3 ont toutes exactement 12 lignes
bool result = std::all_of(workingTables.begin(), workingTables.end(), [](table_cref table) {
return table.size() == 12;
}); |
Partager