While trying out the new Tie-Interceptor three-way comparison operator <=>
I was wondering what would be an example such that
struct Foo {
/*
....
*/
auto operator<=>(const Foo &rhs) const = default;
};
would lead to a compiler error with
Foo Bar1;
Foo Bar2;
std::strong_ordering(Bar1 <=> Bar2);
but not with
Foo Bar1;
Foo Bar2;
std::weak_ordering(Bar1 <=> Bar2);
What would be an example for Foo
? In other words how would Foo
not imply substitutability?
I know that I could write my own implementation of the operator which returns std::weak_ordering ... less/greater/equivalent
but how to force the compiler to do so?
I've read Practical meaning of strong_ordering and weak_ordering among others so far.