Is this the way to append rows (matrix) to a matrix?
#include <vector>
#include <memory>
using std::vector;
int size = 4; // width;
int chunk = 2; // high
int main(int argc, char const *argv[]) {
vector<vector<int>> m(10, vector<int>(size));
auto func = []() {
vector<vector<int>> n(chunk, vector<int>(size));
return n;
};
int j = 0;
for(int i = 0; i < 5; i++) {
auto n = func();
for(auto &row : n) m[j++] = row; // append rows
}
}
I hoped it will be possible to just m.push_back(n)
.
Aucun commentaire:
Enregistrer un commentaire