Replace std::mins/max with clamp function (#2062)