== Quote from KennyTM~ ([email protected])'s article > On Mar 30, 11 03:15, dsimcha wrote: > > == Quote from bearophile ([email protected])'s article > >> The operator overloading done with opCmp is too much coarse even if you > >> want to > > implement sets with operators like<=< > >= == for subset, etc. > > > > Can you please give an example of where<=,>, etc. are useful for > > representing > > set operations? My naive opinion (i.e. without understanding your use > > case) is > > that using comparison operators to represent anything besides partial or > > total > > ordering is a severe abuse of operator overloading. (Their use to represent > > ordering of corresponding elements of a vector or matrix is a borderline > > case.) > If 'a <= b' means 'a' is a subset of 'b', then (Set, <=) does form a > partial order. > That said, the current opCmp design is capable of comparing sets and any > partial orders if the return type can be relaxed to 'float': > if (a == b) return 0; > else if (a is subset of b) return -1; > else if (b is subset of a) return 1; > else /* unordered */ return NaN;
Technically you're right, but I question whether thinking of this as an ordering is ever useful in practice.
