#ifndef RTG_GUARD_RTGLIB_FLOAT_EQUAL_HPP #define RTG_GUARD_RTGLIB_FLOAT_EQUAL_HPP #include #include #include #ifdef _MSC_VER #include #endif namespace rtg { template using common_type = typename std::common_type::type; struct float_equal_fn { template static bool apply(T x, T y) { return std::isfinite(x) and std::isfinite(y) and std::nextafter(x, std::numeric_limits::lowest()) <= y and std::nextafter(x, std::numeric_limits::max()) >= y; } template bool operator()(T x, U y) const { return float_equal_fn::apply>(x, y); } }; static constexpr float_equal_fn float_equal{}; } // namespace rtg #endif