How to assign 2D vectors

1
2
double arr[][] = {{1,2},{3,4},{5,6}}
std::vector< std::vector<double> > my_vector;


How can I use the vector "assign()" function to copy the values of array arr to my_vector?
You can't.

You'll have to loop and assign elements one at a time. Or do std::copy in a loop or something.

Also, obligatory link:

http://cplusplus.com/forum/articles/17108/
Oh no.. but we could do it for 1D arrays :(
1
2
int myints[] = {1776,7,4};
third.assign (myints,myints+3);   // assigning from array. 
Right... but 1D arrays are simpler.
Topic archived. No new replies allowed.