Reflections on Serialization APIs in D
"Nordlöw"
per.nordlow at gmail.com
Sun Nov 17 10:24:38 PST 2013
In the road to develop a new kind of search engine that caches
types, statistics, etc about files and directories I'm currently
trying to implement persistent caching of my internal directory
tree using `msgpack-d`:
Why doesn't `msgpack-d` and, from what I can see also,
`std.serialization` (Orange) support implementing *both* packing
and unpacking through one common template (member) function
overload like **Boost.Serialization** does?. For example
containers can be handled using this concise and elegant syntax
in C++11:
friend class boost::serialization::access;
template<class Ar> void serialize(Ar& ar, const uint
version) {
for (const auto& e : *this) { ar & e; }
}
This halves the code size aswell as removes the risk of making
the `pack` and `unpack` go out of sync.
More information about the Digitalmars-d-learn
mailing list