clamp

clamp#

stdgpu: stdgpu::clamp
stdgpu Latest
Efficient STL-like Data Structures on the GPU

◆ clamp()

template<class T >
STDGPU_HOST_DEVICE const T & stdgpu::clamp ( const T &  v,
const T &  lower,
const T &  upper 
)

Clamps a value to the given range.

Template Parameters
TThe type of the values
Parameters
[in]vA value
[in]lowerThe lower bound
[in]upperThe upper bound
Returns
lower if v < lower, upper if upper < v, v otherwise
Precondition
!(upper < lower)