Files
2025-10-25 03:02:53 +03:00

2.3 KiB
Raw Permalink Blame History

[numeric.ops.midpoint]

26 Algorithms library [algorithms]

26.10 Generalized numeric operations [numeric.ops]

26.10.16 Midpoint [numeric.ops.midpoint]

🔗

template<class T> constexpr T midpoint(T a, T b) noexcept;

1

#

Constraints: T is an arithmetic type other than bool.

2

#

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.

3

#

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);

4

#

Constraints: T is an object type.

5

#

Mandates: T is a complete type.

6

#

Preconditions: a and b point to, respectively, elements i and j of the same array object x.

[Note 1:

As specified in [basic.compound], an object that is not an array element is considered to belong to a single-element array for this purpose and a pointer past the last element of an array of n elements is considered to be equivalent to a pointer to a hypothetical array element n for this purpose.

— end note]

7

#

Returns: A pointer to array element i+j−i2 of x, where the result of the division is truncated towards zero.