for (int c = 0; c < vect_aux.size(); c++){
boost::algorithm::split(vect_aux, vect[c], boost::algorithm::is_any_of("+"));
/* instead of size_t i have to use int and instead o ++c I have to use c++. If like this all goes ok.*/
}
EV << "vect_aux: " << vect_aux[0] << '\n'; // it shows: 899 like i want.
vect_res[2] = vect_aux[0];// this equal is given me an error when running. is something wrong with this?
std::vector<std::string>::iterator it;
it = vect_res.begin();
EV << "vect_aux: " << vect_aux[0] << '\n';
vect_res.insert(it, vect_aux[0]); // it goes OK
vect_res.insert(it+1, vect_aux[1]); // do not work
// or
vect_res.insert(it, 1,vect_aux[1]); // do not work
Can someone advise me how can I put in position 1 of vector vect_res the content of vector vect_aux[1].
Thanks again.
Yes you here right inserting in a vector invalidate the iterator I got previously.
Is better like this:
1 2 3 4 5 6 7
vect_res.insert(vect_res.begin(), vect_aux[0]);
vect_res.insert(vect_res.begin(), 1, vect_aux[1]);
//int a; is a number in a for cycle:
vect_ress.insert(vect_res.begin(), a*2, vect_aux[1]);
vect_res.insert(vect_res.begin(), a*2+1, vect_aux[0]);