Compare helper functions for writing opCmps
Bill Baxter
dnewsgroup at billbaxter.com
Tue Aug 28 18:53:49 PDT 2007
Often an opCmp implementation will end up just being a comparison based
on a single member of elementary type.
Is there any function in Phobos for doing an opCmp style comparison of
the basic types? Something like
int compare(S,T)(S a, T b) {
if (a==b) return 0;
return (a<b)? -1 : 1;
}
It's simple but comes up enough that it seems like it would be useful to
have in the library. Kinda like min/max.... which aren't in Phobos either.
-bb
More information about the Digitalmars-d-learn
mailing list