Now, lets answer the serialization:
First of all, some serialization libraries (there are many more though):
http://www.cuj.com/documents/s=7993/cujcexp1907reeves/
http://www.recursionsw.com/products/toolkits/whitepapers/STL%20in%20Action_A%20Universal%20
Streaming%20Service.pdf
For serialization purposes, the location of vptr is USELESS.
"the only option for portable and ISO-compliant code is to check the vptr's location in
order to ensure that its position isn't overwritten during deserialization"
Are you kidding me?
You're talking about dumping the entire object's content into a file as a stream of bytes
and writing it back as a default-constructed object.
Try doing that for a std::vector filled with, lets say 1000 elements.
Or for a pointer.
The above does NOT work even for most PODs (Plain Old Data).
So, this is broken even in C, but in C++ is a MAJOR flaw. What about OO-state?
What if you want to serialize a std::string? Your method will fail big-time.
Any non-trivial class will most-likely fail using the above.
Another problem is when you don't have a default constructor (of course, from all the
problems, this is the least of them).
Not to say that the location of the vptr still DOES NOT matter.
Even using your method, you should care about ALIGNMENT. So, you should do something like:
A a;
// no need for vptr at all
std::memcpy( &a.first_data_member, whatever_buffer, sizeof( a));
NOT
std::memcpy( &a, whatever_buffer, sizeof( a));
Since, for one: operator& might be overloaded, and secondly it's not necessary for this to
hold true:
(&a.first_data_member == &a)
Since such a code is incredibly error-prone, I will say that I wouldfire someone that used
such a serialization mechanism.