Skip to content

Using minMaxOp for reductions is fragile

When reducing min/max values, the minMaxOp attempts to be extra smart and also allow reduction of two MinMax values as well:

template<class T>
struct minMaxOp
{
...
     MinMax<T> operator()(const MinMax<T>& x, const MinMax<T>& y) const
     {
         return MinMax<T>(x).add(y);  // Same as (x + y)
     }
};

However, this can sometime confuse the compiler. Better to use plusOp<MinMax<T>>() for binary reductions.