1#ifndef HALCHECK_LIB_NUMERIC_HPP
2#define HALCHECK_LIB_NUMERIC_HPP
11#include <halcheck/lib/type_traits.hpp>
16namespace halcheck {
namespace lib {
23template<typename T, HALCHECK_REQUIRE(std::is_integral<T>())>
26 return min <= max ? min + T(U(max - min) >> 1) : min - T(U(min - max) >> 1);
34template<typename T, HALCHECK_REQUIRE(std::is_floating_point<T>())>
40 return amin < hi && amax < hi ? (min + max) / 2
41 : amin < lo ? min + max / 2
42 : amax < lo ? min / 2 + max
54template<typename T, HALCHECK_REQUIRE(std::is_integral<T>())>
lib::make_unsigned_t< T > to_unsigned(T value)
Converts an integral value into its equivalent unsigned version.
Definition numeric.hpp:55
constexpr T midpoint(T min, T max) noexcept
An implementation of std::midpoint.
Definition numeric.hpp:24
typename std::make_unsigned< T >::type make_unsigned_t
An implementation of std::make_unsigned_t.
Definition type_traits.hpp:125