Remove <algorithm> header from the common path

It was only used for std::max<double> within Approx, so we now have
::Catch::Detail::max(double, double) that is used instead.
This commit is contained in:
Martin Hořeňovský 2017-08-17 15:34:00 +02:00
parent f99f511155
commit 597fca3c89
2 changed files with 10 additions and 2 deletions

View File

@ -13,6 +13,13 @@
namespace Catch { namespace Catch {
namespace Detail { namespace Detail {
double max(double lhs, double rhs) {
if (lhs < rhs) {
return rhs;
}
return lhs;
}
Approx::Approx ( double value ) Approx::Approx ( double value )
: m_epsilon( std::numeric_limits<float>::epsilon()*100 ), : m_epsilon( std::numeric_limits<float>::epsilon()*100 ),
m_margin( 0.0 ), m_margin( 0.0 ),

View File

@ -10,7 +10,6 @@
#include "catch_tostring.h" #include "catch_tostring.h"
#include <algorithm>
#include <cmath> #include <cmath>
#include <type_traits> #include <type_traits>
@ -18,6 +17,8 @@
namespace Catch { namespace Catch {
namespace Detail { namespace Detail {
double max(double lhs, double rhs);
class Approx { class Approx {
public: public:
explicit Approx ( double value ); explicit Approx ( double value );
@ -42,7 +43,7 @@ namespace Detail {
friend bool operator == ( const T& lhs, Approx const& rhs ) { friend bool operator == ( const T& lhs, Approx const& rhs ) {
// Thanks to Richard Harris for his help refining this formula // Thanks to Richard Harris for his help refining this formula
auto lhs_v = static_cast<double>(lhs); auto lhs_v = static_cast<double>(lhs);
bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (std::max)(std::fabs(lhs_v), std::fabs(rhs.m_value))); bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (max)(std::fabs(lhs_v), std::fabs(rhs.m_value)));
if (relativeOK) { if (relativeOK) {
return true; return true;
} }