I have a map that is populated with an id, and an array of floats. I'd like to copy the floats (pair.second) into *temp_arr.
// Temp object
struct Temp
{
float t1, t2, t3;
float n1, n2, n3;
};
// A map that is populated.
std::map<int, Temp> temps;
// temps gets populated ...
int i = 0;
Temps *temp_arr = new Temp[9];
// currently, I do something like ...
for (auto& tmp : temps)
temp_arr[i++] = tmp.second;
I was trying to do this using std::copy and I think a lambda would be needed to get a map of tmp.seconds into the temp_arr, but so far, not yet.
Aucun commentaire:
Enregistrer un commentaire