📅  最后修改于: 2022-03-11 14:44:53.799000             🧑  作者: Mango
template
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