I have a C ++ class defined as A a;which I would like to serialize. The easiest way to do this (when it works) is
write(fd, reinterpret_cast<uint8_t*>(&a), sizeof(a));
and read it using:
read(fd, reinterpret_cast<uint8_t*>(&a), sizeof(a));
I know that this will work if std::is_pod<A>::valuethese are true types, but what is the most relaxed set of type attributes Athat exibit should work for?
Just for completeness, this is to save between executable instances of the application, there is no need for the file to be read by another program or on another platform.
doron source
share