Chapter 24. Object serialization

Index

Use cases
Supported objects
Serializing an object
Serializing enumerated values
Serializing a beginning/ending iterator range
Calculating the size of the serialized object
Convenience functions for serializing a single object
Deserializing an object
Maximum sequence sizes
Deserializing any one of several objects
Convenience functions for deserializing a single object
Serializing classes
Serialization of object references
Deserialization traits class
Serializing file descriptors

Serialization is the process of converting an object to a sequence of bytes, which can be saved to a file or a buffer, and subsequently recreating the object from the saved byte sequence.

Use cases

The format of serialized objects is not documented. It partially depends on the implementation-defined platform and the C++ ABI. As such, serialization is not really suitable for long term object persistance, since a platform change or a compiler change may result in incompatibility with previously-serialized objects. The intent of this serialization implementation is interprocess communication between version-compatible client and server processes.

Serialized byte sequences include a signature of the serialized object. Attempting to deserialize into an incompatible object results in a well-defined error path, a thrown exception.