What is the fastest and most efficient way to copy contents of one vector to another? I am thinking of something where the vector sizes will be relatively large and copies will happen frequently. One assumption is that the vector sizes won't be changing between calls and the two vectors will be equal in size.
As such, is there a speed difference between the following? Is there a better way to do it?
vector<float> v1(100);
vector<float> v2(100);
// case 1
v2 = v1;
// case 2
v2.assign(v1.begin(), v1.end());
// case 3
for(int x = 0; x < v1.size(); x++)
v2[x] = v1[x];
// case 4
memcpy(&v2[0], &v1[0], v1.size()*sizeof(float));