From Jason Turner

[alg.clamp]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpkfu7zk7o/{from.md → to.md} +21 -0
tmp/tmpkfu7zk7o/{from.md → to.md} RENAMED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Bounded value <a id="alg.clamp">[[alg.clamp]]</a>
2
+
3
+ ``` cpp
4
+ template<class T>
5
+ constexpr const T& clamp(const T& v, const T& lo, const T& hi);
6
+ template<class T, class Compare>
7
+ constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp);
8
+ ```
9
+
10
+ *Requires:* The value of `lo` shall be no greater than `hi`. For the
11
+ first form, type `T` shall be `LessThanComparable`
12
+ (Table  [[tab:lessthancomparable]]).
13
+
14
+ *Returns:* `lo` if `v` is less than `lo`, `hi` if `hi` is less than `v`,
15
+ otherwise `v`.
16
+
17
+ [*Note 1*: If NaN is avoided, `T` can be a floating-point
18
+ type. — *end note*]
19
+
20
+ *Complexity:* At most two comparisons.
21
+