Swapping 2D vectors

Hello everyone!

If we want to swap a 2 1d vectors we would write:
1
2
3
4
#include <vector>
vector <int> v1;
vector <int> v2;
v1.swap(v2);


Now, if we have 2 2d vectors, and want to swap the rows, what do we write?
Last edited on
1
2
3
vector<vector<int> > m1;
vector<vector<int> > m2;
m1.swap(m2);
1
2
3
4
5
vector<vector<int> > v; //2d vector
v[K]; //one row (a vector)
vector <int> &v1 = v[K];
vector <int> &v2 = v[L];
v1.swap(v2); //v[K].swap(v[L])  
Topic archived. No new replies allowed.