3 ms·
> Moreover, the compiler can “derive” implementations for regular data objects. When defaulting the spaceship operator, the same happens for C++ (by comparing
by claudius 7y ago
> Moreover, the compiler can “derive” implementations for regular data objects.
When defaulting the spaceship operator, the same happens for C++ (by comparing members). In this special case, the equality operator is also effectively defaulted, so as described in the article
struct A {
…
auto operator<=>(A const& rhs) const = default;
};
gives you automatic member-wise comparison "derived" by the compiler.
- moomin 7y agoNice, I missed that.