Skip to content

Commit

Permalink
Merge pull request #3070 from burner/algo_cmp_clamp
Browse files Browse the repository at this point in the history
std.algo.cmp.clamp docu
  • Loading branch information
H. S. Teoh committed Mar 20, 2015
2 parents e0518c6 + fbf42b4 commit 25b769c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions std/algorithm/comparison.d
Expand Up @@ -484,10 +484,19 @@ unittest
)());
}

/**
Returns $(D val), if it is between $(D lower) and $(D upper).
Otherwise returns the nearest of the two. Equivalent to $(D max(lower,
min(upper,val))).
/** Clamps a value into the given bounds.
This functions is equivalent to $(D max(lower, min(upper,val))).
Params:
val = The value to _clamp.
lower = The _lower bound of the _clamp.
upper = The _upper bound of the _clamp.
Returns:
Returns $(D val), if it is between $(D lower) and $(D upper).
Otherwise returns the nearest of the two.
*/
auto clamp(T1, T2, T3)(T1 val, T2 lower, T3 upper)
in
Expand Down

0 comments on commit 25b769c

Please sign in to comment.