Answers for "c++ clip values"

C++
0

c++ clip values

template <typename T>
T clip(const T& n, const T& lower, const T& upper) {
  return std::max(lower, std::min(n, upper));
}

// Credit: https://stackoverflow.com/questions/9323903/most-efficient-elegant-way-to-clip-a-number
Posted by: Guest on February-12-2021

Browse Popular Code Answers by Language