#ifndef SPROUT_MATH_EQUAL_TO_HPP #define SPROUT_MATH_EQUAL_TO_HPP #include #include #include #include #include #include #include namespace sprout { namespace math { namespace detail { template inline SPROUT_CONSTEXPR T max3(T x, T y, T z) { return sprout::max(sprout::max(x, y), z); } template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR bool equal_to(FloatType x, FloatType y) { return x == y || sprout::abs(x - y) <= std::numeric_limits::epsilon() * sprout::math::detail::max3(std::abs(x), std::abs(y), FloatType(1.0)) ; } template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR bool equal_to(IntType x, IntType y) { return x == y; } } // namespace detail // // equal_to // template< typename T1, typename T2, typename sprout::enabler_if::value && std::is_arithmetic::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR bool equal_to(T1 x, T2 y) { typedef typename sprout::math::float_promote::type promoted; return sprout::math::detail::equal_to(x, y); } } // namespace math } // namespace sprout #endif // #ifndef SPROUT_MATH_EQUAL_TO_HPP