I&#x27;m doing something similar in C++ for vertex attributes, integration with Lua et.al. First I define the struct:<p><pre><code>  INTROSPECTION_DEFINE_STRUCT(S,
    (int, anInt),
    (bool, aBool),
    (float, aFloat),
    (double, aDouble),
    (std::string, aString)
  );
</code></pre>
Then I create an instance of it:<p><pre><code>  S s{ 23, true, 37.5f, 42.25, &quot;String&quot; };
</code></pre>
And finally I can e.g. iterate over all fields and output their value using a generic lambda:<p><pre><code>  forEachField(s, [](auto v) {
    std::cout &lt;&lt; v;
  });
</code></pre>
There are also definitions for the field&#x27;s type, offset, name etc. generated by the macro, so it&#x27;s easy to create a binding for vertex attributes, map the struct to a table in Lua, serialize&#x2F;deserialize it and so on.<p>I&#x27;m really hoping C++ gets introspection soon. There are some proposals like <a href="https:&#x2F;&#x2F;isocpp.org&#x2F;files&#x2F;papers&#x2F;n3996.pdf" rel="nofollow">https:&#x2F;&#x2F;isocpp.org&#x2F;files&#x2F;papers&#x2F;n3996.pdf</a> and a working group at <a href="https:&#x2F;&#x2F;groups.google.com&#x2F;a&#x2F;isocpp.org&#x2F;forum&#x2F;#!forum&#x2F;reflection" rel="nofollow">https:&#x2F;&#x2F;groups.google.com&#x2F;a&#x2F;isocpp.org&#x2F;forum&#x2F;#!forum&#x2F;reflect...</a> but I&#x27;m not holding my breath for 2017.