title: c++ auto-comparator for structs
body: <p>There is many primitive structs (several hundreds), that are used to transfer data between two components (for example a player and a server). There are no methods in them, just raw data.
  The task is to write all requests and answers to be able to replay a player scenario without a server (we remember all question and all answers, that are pure functions).
  So the task is put this structs in map without comparator. Now we use memcmp, it allows not to think about changes in this structs and it is compact, but there are too many problems with padding and etc.</p>
  
  <p>Is it possible to get smth like getHashValue or any default comparator with metaprogramming in c++? 
  Conditions:
  1) I do not want to create a comparator for each struct.
  2) I want to have an error if a field was added or deleted if it breaks existing behavior and needs fix.
  3) I don't want to change header files with struct definitions.</p>
  
  <p>Example of a struct</p>
  
  <pre><code>struct A {
    int a;
    int b;
    c c;
  }
  
  bool operator&lt;(const A&amp; a1, const A&amp; a2)
  {
    if (a1.a != a2.a) return a1.a &lt; a2.a;
    if (a1.b != a2.b) return a1.b &lt; a2.b;
    if (a1.c != a2.c) return a1.c &lt; a2.c;
    return false;
  } 
  </code></pre>
  
  <p>I can consider other languages to implement this exact part (collect questions/answers), if it will not require to describe all this structs on that language again.</p>