folly::midpoint

midpoint overloads

Synopses

Declared in <folly/Math.h>

Compute the midpoint of two floating-point values, avoiding overflow.

template<class _Fp>
constexpr
_Fp
midpoint(
    _Fp __a,
    _Fp __b) noexcept
requires std::is_floating_point<_Fp>::value;
» more...

Compute the midpoint between two pointers into the same array.

template<class _TPtr>
constexpr
_TPtr
midpoint(
    _TPtr __a,
    _TPtr __b) noexcept
requires std::is_pointer<_TPtr>::value &&
        std::is_object<std::remove_pointer_t<_TPtr>>::value &&
        !std::is_void<std::remove_pointer_t<_TPtr>>::value &&
        (sizeof(std::remove_pointer_t<_TPtr>) > 0);
» more...

Compute the midpoint of two integers without overflow.

template<class _Tp>
constexpr
_Tp
midpoint(
    _Tp __a,
    _Tp __b) noexcept
requires std::is_integral<_Tp>::value && !std::is_same<bool, _Tp>::value &&
        !std::is_null_pointer<_Tp>::value;
» more...

Return Value

  • The value halfway between __a and __b.
  • A pointer halfway between __a and __b, rounded toward __a.

Parameters

NameDescription
__aThe first value.
__bThe second value.