3 ms·
If you had some way to apply templates to each element of a structure in sequence, you could use template metaprogramming to do marshalling. Suppose you could w
by Animats 11y ago
If you had some way to apply templates to each element of a structure in sequence, you could use template metaprogramming to do marshalling. Suppose you could write
struct pnt {
float x;
float y;
bool valid;
};
pnt p;
and then have
auto s = serialize(p);
expand into
auto s = serialize_field("x", p.x, serialize_field("y", p.y,
serialize_field("valid", p.valid)))
then serialization could be implemented by defining serialize_field for each
type.