diff options
| author | Martin Hořeňovský | 2017-04-25 11:11:26 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2017-04-25 11:11:26 +0200 |
| commit | 2fdd81a33f36685b0708680a2ea15e670d5db730 (patch) | |
| tree | e2e643d8df1b56e1864fc1e8d22758747204ef9e /include/internal | |
| parent | fc7f0a02b809a888172c3a937bb9caf2ba449f64 (diff) | |
| download | catch3-2fdd81a33f36685b0708680a2ea15e670d5db730.tar.gz | |
Removed C++98 backcompat from Approx
Now it always uses type traits to work with all types convertible to
double
Diffstat (limited to 'include/internal')
| -rw-r--r-- | include/internal/catch_approx.hpp | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/include/internal/catch_approx.hpp b/include/internal/catch_approx.hpp index fc681436..406c7ef1 100644 --- a/include/internal/catch_approx.hpp +++ b/include/internal/catch_approx.hpp @@ -13,9 +13,7 @@ #include <cmath> #include <limits> -#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) #include <type_traits> -#endif namespace Catch { namespace Detail { @@ -40,8 +38,6 @@ namespace Detail { return Approx( 0 ); } -#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) - template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> Approx operator()( T value ) { Approx approx( static_cast<double>(value) ); @@ -120,69 +116,6 @@ namespace Detail { return *this; } -#else - - Approx operator()( double value ) { - Approx approx( value ); - approx.epsilon( m_epsilon ); - approx.margin( m_margin ); - approx.scale( m_scale ); - return approx; - } - - - friend bool operator == ( double lhs, Approx const& rhs ) { - // Thanks to Richard Harris for his help refining this formula - bool relativeOK = std::fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( std::fabs(lhs), std::fabs(rhs.m_value) ) ); - if (relativeOK) { - return true; - } - return std::fabs(lhs - rhs.m_value) < rhs.m_margin; - } - - friend bool operator == ( Approx const& lhs, double rhs ) { - return operator==( rhs, lhs ); - } - - friend bool operator != ( double lhs, Approx const& rhs ) { - return !operator==( lhs, rhs ); - } - - friend bool operator != ( Approx const& lhs, double rhs ) { - return !operator==( rhs, lhs ); - } - - friend bool operator <= ( double lhs, Approx const& rhs ) { - return lhs < rhs.m_value || lhs == rhs; - } - - friend bool operator <= ( Approx const& lhs, double rhs ) { - return lhs.m_value < rhs || lhs == rhs; - } - - friend bool operator >= ( double lhs, Approx const& rhs ) { - return lhs > rhs.m_value || lhs == rhs; - } - - friend bool operator >= ( Approx const& lhs, double rhs ) { - return lhs.m_value > rhs || lhs == rhs; - } - - Approx& epsilon( double newEpsilon ) { - m_epsilon = newEpsilon; - return *this; - } - - Approx& margin( double newMargin ) { - m_margin = newMargin; - return *this; - } - - Approx& scale( double newScale ) { - m_scale = newScale; - return *this; - } -#endif std::string toString() const { std::ostringstream oss; |