template<class T>
class cereal::DeferredData< T >
A wrapper around data that should be serialized after all non-deferred data.
This class is used to demarcate data that can only be safely serialized after any data not wrapped in this class.
Marks data for deferred serialization.
cereal performs a recursive depth-first traversal of data it serializes. When serializing smart pointers to large, nested, or cyclical data structures, it is possible to encounter a stack overflow from excessive recursion when following a chain of pointers.
Deferment can help in these situations if the data can be serialized separately from the pointers used to traverse the structure. For example, a graph structure can have its nodes serialized before its edges:
struct MyEdge
{
std::shared_ptr<MyNode> connection;
int some_value;
template<class Archive>
{
archive( cereal::defer( connection ),
some_value );
}
};
struct MyGraphStructure
{
std::vector<MyEdge> edges;
std::vector<MyNodes> nodes;
template<class Archive>
{
archive( edges, nodes );
archive.serializeDeferments();
}
};
void serialize(Archive &, std::less< T > &)
Saving for std::less.
Definition: functional.hpp:39