max_val
Return the right value if the right
value is greater than left, otherwise returns the left value.
#include
<sdlt/min_max_val.h>
Syntax
template<typename T> T max_val(const T left, const T right);
Arguments
- typename T
- The type of the left and right values
Description
C++ implementations of std::min and std::max create a conditional control
flow that returns references to its parameters, which may cause inefficient
vector code generation. max_val is a really simple template that returns by
value instead of reference, allowing more efficient vector code to be
generated. For most cases the algorithm didn't need a reference to the inputs
and a copy by value should suffice. It should inline, adding no overhead.
Inside of SIMD loops, we suggest using sdlt::max_val in place of std::max.
Requires < operator be defined for the type T.