I am trying to connect to existing codes - one being in c, the other one in cpp. The cpp code uses std::vector whereas the other one is based on arrays of double. I would like to pass arrays of double from the c code, perform operations on std::vector's in the cpp one and eventually reflect these operations on the array of double.
Is it possible to create a std::vector that matches the memory occupied by the array of double?
Based on what I have found on the website, I have tried several options, but they all involve the creation of a new vector and a copy of that vector onto the array of double... For instance:
void fcn(double* a, int sizeofa)
{
std::vector<double> vect_a;
vect_a.assign(a, a + sizeofa);
// operations on vect_a
for (int i=0;i<sizeofa;i++) { a[i] = vect_a[i]; }
}
Thank you much for your help!
Aucun commentaire:
Enregistrer un commentaire