25 Algorithms library [algorithms]

25.9 Generalized numeric operations [numeric.ops]

25.9.15 Midpoint [numeric.ops.midpoint]

template<class T> constexpr T midpoint(T a, T b) noexcept;
Constraints: T is an arithmetic type other than bool.
Returns: Half the sum of a and b.
If T is an integer type and the sum is odd, the result is rounded towards a.
Remarks: No overflow occurs.
If T is a floating-point type, at most one inexact operation occurs.
template<class T> constexpr T* midpoint(T* a, T* b);
Constraints: T is a complete object type.
Expects: a and b point to, respectively, elements x[i] and x[j] of the same array object x.
An object that is not an array element is considered to belong to a single-element array for this purpose; see [expr.unary.op].
A pointer past the last element of an array x of n elements is considered to be equivalent to a pointer to a hypothetical element x[n] for this purpose; see [basic.compound].
end note
Returns: A pointer to , where the result of the division is truncated towards zero.