4 ms·
It just makes more sense. Similar to how a<=b is equivalent to (a<b)&&(a==b). Coming up with an entirely fresh meaning for <=> involving spaceships and a congl
by idea1434 9y ago
It just makes more sense. Similar to how a<=b is equivalent to (a<b)&&(a==b).
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 <=>.
- slavik81 9y agoThis operator already exists in Ruby, Perl and a couple other languages. 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.
- verall 9y ago(a<=b) is equivalent to ((a<b)||(a==b)) ((a<b)&&(a==b)) is equivalent to (false)