min_val

Return the left value if the right value is greater than left, otherwise returns the right value. #include <sdlt/min_max_val.h>

Syntax

template<typename T>
T min_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. min_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::min_val in place of std::min.

Requires < operator be defined for the type T.

Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.