Is it okay to do the following? The following code is using the vector v again in the loop (next iteration) after moving it.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void test(vector<int>&& v) {
cout << v.size() << endl;
v.push_back(5);
}
void test2(vector<int>& v) {
for (int i = 0; i < 4; i++) {
test(move(v));
}
}
int main()
{
vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
v.push_back(4);
test2(v);
}