I would suggest offering the serialize_as_binary utility in your Person class.
template<typename T> void serialize_as_bin(const T &t, ostream& os) { const unsigned char *p = reinterpret_cast<const unsigned char *>(&t); for(size_t s = 0; s < sizeof t; ++s, ++p) serialize_as_bin(*p, os); } template<> void serialize_as_bin(const unsigned char &t, ostream& os) {
Live example is shown here.
source share