diff --git a/src/amdis/common/Math.hpp b/src/amdis/common/Math.hpp index c01d0d9705ca6a3e5d2b1353fb3b5bd256549a70..efb2ceb3ba8e1444914ec8e32062a1a17b067333 100644 --- a/src/amdis/common/Math.hpp +++ b/src/amdis/common/Math.hpp @@ -43,7 +43,8 @@ namespace AMDiS template <class T0, class T1> constexpr auto min(T0 a, T1 b) { - return a < b ? a : b; + using T = std::conditional_t<(sizeof(T0)>sizeof(T1)),T0,T1>; + return a < b ? T(a) : T(b); } template <class T0> @@ -62,12 +63,14 @@ namespace AMDiS /// Implementation of the maximum of values \f$ max(a,b)\f$ of any type - /// supporting the `>` relation. + /// supporting the `<` relation. /// @{ + template <class T0, class T1> constexpr auto max(T0 a, T1 b) { - return a < b ? b : a; + using T = std::conditional_t<(sizeof(T0)>sizeof(T1)),T0,T1>; + return a < b ? T(b) : T(a); } template <class T0>