title: get the number of fields in a class
body: <p>Is there a way to get the number of fields of a class?</p>
  
  <pre><code>struct Base {
      char a;
      int b;
  };
  
  struct Derived : Base {
      std::string c;
  };
  
  static_assert(num_fields&lt;Base&gt;::value == 2);
  static_assert(num_fields&lt;Derived&gt;::value == 1);
  </code></pre>
  
  <p>I've found <a href="https://stackoverflow.com/questions/6844605">this question</a> but it is very dated - I am hoping something can be stitched together with C++14/17 (after all we now have something like <a href="https://github.com/apolukhin/magic_get" rel="noreferrer">magic_get</a> - perhaps some subset from it...?)</p>
  
  <p><strong>EDIT:</strong> - a compiler hook would also work even if it's only for MSVC or GCC or Clang - I use all 3.</p>