diff --git a/dune/stuff/common/float_cmp_internal.hh b/dune/stuff/common/float_cmp_internal.hh index 2c0872b742264082a5e67eab7c1a2c10927bdede..51389a2145a50cb4f9171deaae26035c6d68dc49 100644 --- a/dune/stuff/common/float_cmp_internal.hh +++ b/dune/stuff/common/float_cmp_internal.hh @@ -115,10 +115,8 @@ typename std::enable_if<std::is_arithmetic<T>::value, bool>::type cmp_gt(const T template <class T> bool cmp_gt(const std::complex<T>& xx, const std::complex<T>& yy) { - T x = std::abs(xx); - T y = std::abs(yy); - static_assert(std::is_arithmetic<T>::value, ""); - return std::greater<double>()(x, y); + using namespace std; + return cmp_gt({real(xx), real(yy)}, {imag(xx), imag(yy)}); } template <class XType, class YType> @@ -147,7 +145,8 @@ typename std::enable_if<std::is_arithmetic<T>::value, bool>::type cmp_lt(const T template <class T> bool cmp_lt(const std::complex<T>& xx, const std::complex<T>& yy) { - return std::less<T>()(std::abs(xx), std::abs(yy)); + using namespace std; + return cmp_lt({real(xx), real(yy)}, {imag(xx), imag(yy)}); } template <class XType, class YType> diff --git a/dune/stuff/test/common_float_cmp.cc b/dune/stuff/test/common_float_cmp.cc index 4c5ec13e8eda5ea6dd4091a0b546a1fd477a3dc3..bf90d0020fd524e249b3af91b4e0a6335229c9a3 100644 --- a/dune/stuff/test/common_float_cmp.cc +++ b/dune/stuff/test/common_float_cmp.cc @@ -436,7 +436,7 @@ struct FloatCmpVector : public FloatCmpBase }; // struct FloatCmpVector -typedef testing::Types<double, std::complex<double> +typedef testing::Types<double, std::complex<double>, float, // , long double // <- this requires a patch in dune/common/float_cmp.cc // (bc. of std::max and 1e-6) > ScalarTypes;