View source code
Display the source code in std/algorithm/comparison.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
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.
Function std.algorithm.comparison.max
Iterates the passed arguments and returns the maximum value.
auto max(T...)
(
T args
)
if (T .length >= 2 && !is(CommonType!T == void));
T max(T, U)
(
T a,
U b
)
if (is(T == U) && is(typeof(a < b)));
Parameters
Name | Description |
---|---|
args | The values to select the maximum from. At least two arguments must
be passed, and they must be comparable with < . |
Returns
The maximum of the passed-in values. The type of the returned value is
the type among the passed arguments that is able to store the largest value.
If at least one of the arguments is NaN, the result is an unspecified value.
See maxElement
for examples on how to cope
with NaNs.
See Also
Example
int a = 5;
short b = 6;
double c = 2;
auto d = max(a, b);
assert(is(typeof(d) == int));
writeln(d); // 6
auto e = min(a, b, c);
assert(is(typeof(e) == double));
writeln(e); // 2
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.