title: using C++ template programming to extract the field types of an arbitrary structure
body: <p>If I define a struct with arbitrary data types like:</p>
  
  <pre><code>struct custom_type {
      int a;
      float b;
      char c; 
      float *d; // etc...
  };
  </code></pre>
  
  <p>Is there a common pattern using template programming (C++) to extract the field types of this struct and map them to some type-specific code handler at compile time ?</p>
  
  <p>Some context: I'm creating an api that allows for clients to define their own arbitrary custom types, and still allow those to integrate with the underlying system I have for managing and introspecting these types, doing automated memory management and other housekeeping.</p>
  
  <p>The "wrapping" template or other mechanism will allow this integration <em>without the underlying system knowing anything about the header file that defines the custom type.</em> From the client's point of view, the code accesses the struct in the normal way, but the template allows generic handling of each field in the struct.  </p>
  
  <p>Thanks.</p>