Say I have a class, something like the following;
class MyClass
{
public:
MyClass();
int a,b,c;
double x,y,z;
};
#define PageSize 1000000
MyClass Ar
I will notice that you admit there is an issue here. And you are aware of the potential drawbacks.
My question is one of maintenance. Do you feel confident that nobody will ever include a field in this class that would botch up your great optimization ? I don't, I'm an engineer not a prophet.
So instead of trying to improve the copy operation.... why not try to avoid it altogether ?
Would it be possible to change the data structure used for storage to stop moving elements around... or at least not that much.
For example, do you know of blist (the Python module). B+Tree can allow index access with performances quite similar to vectors (a bit slower, admittedly) for example, while minimizing the number of elements to shuffle around when inserting / removing.
Instead of going in the quick and dirty, perhaps should you focus on finding a better collection ?