As other people have saidC++20 introduced default comparisons, aka the "spaceship" operator<=>, which allows you need to implement a comparison function yourselfrequest compiler-generated </<=/==/!=/>=/ and/or > operators with the obvious/naive(?) implementation...
auto operator<=>(const MyClass&) const = default;
There is a proposed way to ask the compiler to generate the obvious/naive...but you can customise that for more complicated situations (?discussed below) implementation: see. See here for the language proposal, which contains justifications and discussion. This answer remains relevant for C++17 and earlier, and for insight in to when you should customise the implementation of operator<=>....
It may seem a bit unhelpful of C++ not to have already Standardised this earlier, but often structs/classes have some data members to exclude from comparison (e.g. counters, cached results, container capacity, last operation success/error code, cursors), as well as decisions to make about myriad things including but not limited to: