Daily bit(e) of C++ | std::strong_ordering, std::weak_ordering, std::partial_ordering
Daily bit(e) of C++ ♻️46, The types of ordering produced by the three-way comparison operator.
The C++20 spaceship operator provides a three-way comparison, the result of which is then wrapped in an ordering type.
The standard provides three ordering types because different types can only support some orderings.
std::strong_ordering for which equality implies that the values are indistinguishable (i.e. if a == b, then f(a) == f(b)).
std::weak_ordering allows equal, distinguishable values, but doesn't permit uncomparable values.
std::partial_ordering which allows uncomparable values (i.e. a < b, a > b and a == b all return false).