integer max, min?

downs default_357-line at yahoo.de
Tue Oct 2 09:55:42 PDT 2007


Nathan Reed wrote:
> (b) If you're talking about functions max(a,b) and min(a,b) that return
> the max and min of their arguments, see Downs' post, which is a bit
> overkill if you just want it on numeric types, but will (I think) do
> lexicographic comparison for string and array types.

Actually, it only works with numbers. Most of the complicated-looking
code just determines the type that can hold all possible results (that's
what the supertype stuff is for). That's also the reason it won't work
with strings and arrays - they don't define "+". Sorry. ^^
But yeah, it is a bit overkill. Gets handy when you want to min/max more
than two values of different types.
 --downs


More information about the Digitalmars-d-learn mailing list