-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generalize min and max to non-numeric types #238
Comments
We could just remove the type declarations on the arguments to min and max. Then I propose we get rid of the definitions for Maybe we should also have a compiler intrinsic for min/max of two native type numbers, since that could be faster than calling libm fmax like we do now. |
Yes, that all seems reasonable. Also, if you apply min/max to an empty but typed container, then we can give the right min/max value for that type in some cases, but in general, it's ill-defined. |
I just started doing that; |
Yes, that seems correct — |
Oh dear, that's because my default constructors accept any arguments and assign them to the fields, which performs conversion. Thinking about this again, I'm not sure this is right. Maybe a default constructor should only accept arguments of the field types. |
I kind of always thought that was a bit suspect. It's nice sometimes, but it's also kind of dangerous. |
I can change it very easily if we want. |
Yeah, the only issue is that there's probably a bunch of places we'll want to insert manual convert calls then. But it's probably best to do this now rather than later. |
As far as the original purpose of this issue, we're ready to go. I made |
Since
<
is generic and applies not only to numeric types, in principle, min and max should also be, although then having negative and positive infinities as the zero-argument default is wrong.The text was updated successfully, but these errors were encountered: