Commit 5406f1a8 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

make max and min work with user-defined casts

parent 73513f33
...@@ -43,7 +43,8 @@ namespace AMDiS ...@@ -43,7 +43,8 @@ namespace AMDiS
template <class T0, class T1> template <class T0, class T1>
constexpr auto min(T0 a, T1 b) 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> template <class T0>
...@@ -62,12 +63,14 @@ namespace AMDiS ...@@ -62,12 +63,14 @@ namespace AMDiS
/// Implementation of the maximum of values \f$ max(a,b)\f$ of any type /// 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> template <class T0, class T1>
constexpr auto max(T0 a, T1 b) 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> 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