Commit 940be3ae authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'issue/math_max_min' into 'master'

make max and min work with user-defined casts

See merge request amdis/amdis-core!35
parents f5779842 5406f1a8
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment