On Friday, 8 November 2019 22:38:09 UTC+2,
robert...@yahoo.com wrote:
> I appear to be missing the point of the distinction between a
> three-way comparison with std::strong_ordering and weak_ordering. Or
> perhaps more to the point, the purpose of substitutability.
When we have multi collection of strong_ordering (or strong_equality)
values then we basically may use one value and count instead of group
of equal values since any value is substitutable for equal to it value.
With weak_ordering values we will need to have every value since the
values may have differences despite comparing equal.
> Is this an issue of hidden(?) state that prevents objects from being
> usable interchangeably? So if you had a rational_number class, and
> two instances had values of 1/3 and 2/6, weak ordering would apply (1)
> always, or (2) only if the numerator or denominator were visible?
The state of weakly equal values that makes those not substitutable
must be visible.
> Which also brings up the question of what the compiler is intended to
> do with that information, and why there's not a
> strong_partial_ordering.
That I don't know. Equal values being substitutable (strong equality)
and existence of non-comparable values (partial ordering) seem
logically to be orthogonal properties.
The partial ordering means possible problems of finding minimums,
maximums or sorting so it allows generic solutions to detect
and announce it compile time. I mean things like that floats are
not suitable for usage as keys for map.