Generic structural recursion

Ali Çehreli acehreli at yahoo.com
Thu Jan 27 22:21:49 UTC 2022


On 1/26/22 10:41, John Colvin wrote:

 > You could define a template that introspects a struct type and gives you
 > a tuple of getters

I've done something similar for ROS where data is a bunch of bytes but 
with a well-defined structure. The difference there is array elements 
are inline with their length encoded first.

So I introspected a FieldSkipper for each struct member which actually 
consisted of the FieldSkippers of the previous members (array skippers 
being smart and recursive to skip over the elements as well).

Then I had a FieldGetter that would use the corresponding FieldSkipper 
to find the right bytes. Fun stuff... :)

Ali



More information about the Digitalmars-d mailing list