tmp/tmp06e2mynv/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Midpoint <a id="numeric.ops.midpoint">[[numeric.ops.midpoint]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
template<class T>
|
| 5 |
+
constexpr T midpoint(T a, T b) noexcept;
|
| 6 |
+
```
|
| 7 |
+
|
| 8 |
+
*Constraints:* `T` is an arithmetic type other than `bool`.
|
| 9 |
+
|
| 10 |
+
*Returns:* Half the sum of `a` and `b`. If `T` is an integer type and
|
| 11 |
+
the sum is odd, the result is rounded towards `a`.
|
| 12 |
+
|
| 13 |
+
*Remarks:* No overflow occurs. If `T` is a floating-point type, at most
|
| 14 |
+
one inexact operation occurs.
|
| 15 |
+
|
| 16 |
+
``` cpp
|
| 17 |
+
template<class T>
|
| 18 |
+
constexpr T* midpoint(T* a, T* b);
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
*Constraints:* `T` is an object type.
|
| 22 |
+
|
| 23 |
+
*Mandates:* `T` is a complete type.
|
| 24 |
+
|
| 25 |
+
*Preconditions:* `a` and `b` point to, respectively, elements i and j of
|
| 26 |
+
the same array object `x`.
|
| 27 |
+
|
| 28 |
+
[*Note 1*: As specified in [[basic.compound]], an object that is not an
|
| 29 |
+
array element is considered to belong to a single-element array for this
|
| 30 |
+
purpose and a pointer past the last element of an array of n elements is
|
| 31 |
+
considered to be equivalent to a pointer to a hypothetical array element
|
| 32 |
+
n for this purpose. — *end note*]
|
| 33 |
+
|
| 34 |
+
*Returns:* A pointer to array element $i+\frac{j-i}{2}$ of `x`, where
|
| 35 |
+
the result of the division is truncated towards zero.
|
| 36 |
+
|