title: How to implement C++ (in)equality operators for aggregate structs?
body: <p>Sometimes I have structs such as this --</p>
  
  <pre><code>struct aggregate1 {
    std::string name;
    std::vector&lt;ValueT&gt; options;
    size_t foobar;
    // ...
  };
  </code></pre>
  
  <p>-- where (in)equality is simply defined as (in)equality of all members: <code>lhs_name == rhs_name &amp;&amp; lhs_options == rhs_options &amp;&amp; lhs_foobar == rhs_foobar</code>.</p>
  
  <p>What's the "best" way to implement this? (Best as in: (Runtime-)Efficiency, Maintainability, Readability)</p>
  
  <ul>
  <li><code>operator==</code> in terms of <code>operator!=</code></li>
  <li><code>operator!=</code> in terms of <code>operator==</code></li>
  <li>Separate implementations for <code>==</code> and <code>!=</code></li>
  <li>As member or as free functions?</li>
  </ul>
  
  <p>Note that this question is only about the (in)equality ops, as comparison (<code>&lt;</code>, <code>&lt;=</code>, ...) doesn't make too much sense for such aggregates.</p>