So I have the following function:
std::vector<std::vector<int>> solve(int t){
std::vector<std::vector<int>> result;
result.push_back(std::vector<int>(2*t,0));
//CODE TO fill up result[0]
return result;
}
And when I write the following code to get results:
std::vector<std::vector<int>> results(4);
for(int t = 0; t < 4; ++t){
std::vector<std::vector<int>> cols = solve(t);
if(cols.size() > 0){
for(std::vector<int> col: cols){
results[t].push_back(col);
}
}
}
I get the following error:
src/pricing.cpp:33:29: error: no matching function for call to ‘std::vector::push_back(std::vector&)’ results[t].push_back(col);
From what I understand the foreach is creating col
as a reference. What I don't understand is why push_back
being able to insert col
. Why is this happening and what's the best way to insert col
into results[t]
?
Aucun commentaire:
Enregistrer un commentaire