Hi,
I have a vector that represent memory in my code. I would like to split it into two smaller vector, without
copying it. I want the split to be "in-place", so that modifications on the two smaller vectors would affect the
original one.
Exemple :
int N=10;
int i;
vector<inta = vector<int>(N,0);
for(i=0;i<N;i++)
a.push_back(i);
vector<int>::iterator mid = a.begin();
mid+=5;
vector<int& a1 = vector<int>(a.begin(),mid); // something like this
vector<int& a2 = vector<int>(mid,a.end()); // something like this
a1[0] = 10;
a2[0] = 22;
cout << "a ";
for(mid=a.begin();mid!=a.end();mid++)
cout << *mid << " ";
cout << "\na1 ";
for(mid=a1.begin();mid!=a1.end();mid++)
cout << *mid << " ";
cout << "\na2 ";
for(mid=a2.begin();mid!=a2.end();mid++)
cout << *mid << " ";
Would someone know a way to do this ?
many thanks in advance,
Alexandre.