c++: only clamp upwards