October 17, 2021 [Issue 22414] New: clamp(a, b, c) should always return typeof(a) | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22414 Issue ID: 22414 Summary: clamp(a, b, c) should always return typeof(a) Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody@puremagic.com Reporter: andrei@erdani.com "I will now clamp this value between this limits" has the implied contract that you get the same type as that of the initial value. Using min and max in the implementation of clamp is specious; in min and max there is no "preferred" type so they use a fair method of choosing the type of the result. In contrast, clamp is about a value that occasionally is forced to a limit. -- |
Copyright © 1999-2021 by the D Language Foundation