template <typename T> bool approximately_equal(const T& lhs, const T& rhs, double epsilon, double scale)
{
}
template <> bool approximately_equal(double const& lhs, double const& rhs, double epsilon, double scale)
{
// Thanks to Richard Harris for his help refining this formula
return fabs(lhs - rhs) < epsilon * (scale + (std::max)(fabs(lhs), fabs(rhs)));
}
template <> bool approximately_equal(Point2D const& lhs, Point2D const& rhs, double epsilon, double scale)
{
return approximately_equal(lhs.x, rhs.x, epsilon, scale) && approximately_equal(lhs.y, rhs.y, epsilon, scale);
}
REQUIRE(p == Approx<Point2D>(q)); template <typename T> Approx<T> approx(T const& t)
{
return Approx<T>(t);
}REQUIRE(p == approx(q));