The std::clamp is a simple C++17 algorithm that clamps a given value between the minimum and maximum thresholds.
If the value is outside the thresholds, the violated threshold is returned instead.
Compiler Explorer link: https://compiler-explorer.com/z/vWM16jjrG