boost::algorithm::clamp() in C++ library

The clamp() function in C++ boost library is found under the header ‘boost/algorithm/clamp.hpp’ contains two functions for “clamping” a value between a pair of boundary values.


const T& clamp ( const T& val, const T& lo, const T& hi )
const T& clamp ( const T& value, const T& low, const T& high, Pred p )

Parameters: The function accepts parameters as described below: