3 ms·
"I think that guarantees that std::set works for IEEE floating point values, and that NaNs are at the end of the set. " No, this is, by definition, not a stric
by DannyBee 10y ago
"I think that guarantees that std::set works for IEEE floating point values, and that NaNs are at the end of the set.
"
No, this is, by definition, not a strict weak order because it's not transitive. It also doesn't have transitivity of equivalence.
It's at best partial ordering.
"strict weak" order is, by the way, such an incredibly stupid name it's hard to know where to begin (it's what they call it in math, but it doesn't make it any more sensible)
It's much easier to understand in terms of the invariants.
Partial orders:
f(x, x) must be false.
f(x, y) implies !f(y, x)
f(x, y) and f(y, z) imply f(x, z).
Strict weak ordering:
All of the above plus
Define equivalence as f(x, y) and f(y, x) being both false.
Then if x equivalent to y, and y equivalent to z, then x must be equivalent to z.
IE
for all x, y, z:
if f(x, y) and f(y, x) are both false, and f(y, z) and f(z,y) are both false, then f(x,z) and f(z, x) must both be false.
It's strict because it's not reflexive, and it's weak because b < a && a < b does not imply a == b. It just implies they are "equivalent", and as mentioned, you get a total ordering on the equivalence classes.