title: C++ spaceship-operator and user-defined types: comparing a subset of attributes only
body: <p>I have two classes. The first one composing the second one. Both classes have its own synthetized attribute that doesn't collaborate to either ordering or comparision. In addition, I want to use<code>std::ranges::sort</code> over a container of the second one, so I need to implement a strong-ordering. That's what I have:</p>
  <pre><code>struct basic
  {
      std::string synthetized; // string representation of the next field.
      unsigned value;
      unsigned property;
  
      friend bool operator&lt;(basic const&amp; a, basic const&amp; b)
      { return a.value &lt; b.value or (a.value == b.value and a.property &lt; b.property); }
  };
  
  struct composed
  {
     basic value;
     custom_type meta;
  
     friend bool operator&lt;(composed const&amp; a, composed const&amp; b)
     { return a.value &lt; b.value; }
  };
  
  int main()
  {
     std::vector&lt;composed&gt; container;
     // populating container
  
     // Compilation error here.
     std::ranges::sort(container);
  }
  </code></pre>
  <p>How should I appropiately efficiently overload <code>operator&lt;=&gt;</code>? Although what I need is to sort the vector and that's it (I could just go to traditional <code>std::sort</code>), I want to know how to give to both classes full relational capabilities (&lt;, &lt;=, ==, !=, etc) to both classes, but ignoring <code>synthetized</code> and <code>meta</code>, and without doing anything stupid performance-wise.</p>