template<typename A, typename B>
bool is_unordered(const A& a, const B& b) {
return !(a<b||a==b||a>b);
}
edit: changed implementation to match name.Coming up with an entirely fresh meaning for <=> involving spaceships and a conglomerated comparative threesome just seems illogical to me, given the original meanings of the component symbols of <=>.
It's also incredibly useful, allowing six functions to be replaced by one. Or, rather, with zero, because in 99.9% of cases you will just be able to declare the signature with '= default;' and let the compiler generate the implementation. Then you have all relational operators available for that type. It makes defining new types much, much easier.
Plus, it provides a place to statically define what sort of ordering the type has, so further compile-time optimizations can be done.
In contrast, <=> as is_ordered is nearly useless. It would basically only be used for floats, where !(isnan(a)||isnan(b)) is both equivalent and IMO more clear.
((a<b)&&(a==b)) is equivalent to (false)
(a<b)||(a==b)||(a>b)
Double ampersand is logical AND, you want double bars for logical OR.And still, that's equivalent to !(std::is_nan()), unless you're suggesting using the operator on other non-floating-point types which have a similar problem...