View source code
Display the source code in std/algorithm/comparison.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.algorithm.comparison.max
Iterates the passed arguments and return the maximum value.
Prototype
MaxType!T max(T...)( T args ) if (T.length >= 2);
Parameters
Name | Description |
---|---|
args | The values to select the maximum from. At least two arguments must be passed. |
Returns
The maximum of the passed-in args
. The type of the returned value is
the type among
the passed arguments that is able to store the largest value.
Example
int a = 5; short b = 6; double c = 2; auto d = max(a, b); assert(is(typeof(d) == int)); assert(d == 6); auto e = min(a, b, c); assert(is(typeof(e) == double)); assert(e == 2);