Articles contenant le tag boost library
boost goodie to clamp numbers
Posté par Olivier dans Trucs & Astuces le 10 juin 2015
How do you clamp a number in a given range in C++ ? Classical way to do it is: double clamped = std::min(maxValue, std::max(minValue, value)) But why repeat this magic formula when boost has clamp() for you ? From now on, do: #include double clamped = boost::algorithm::clamp(value, minValue, maxValue)