Add SafeClamp(), which accepts args of different types

Specifically, just like SafeMin() and SafeMax() it handles all
combinations of integer and all
combinations of floating-point arguments by picking a
result type that is guaranteed to be able to hold the result.

This CL also replaces a bunch of std::min + std:max call pairs with
calls to SafeClamp()---the ones that could easily be found by grep
because "min" and "max" were on the same line. :-)

BUG=webrtc:7459

Review-Url: https://codereview.webrtc.org/2808513003
Cr-Commit-Position: refs/heads/master@{#18542}
diff --git a/webrtc/modules/audio_processing/audio_processing_unittest.cc b/webrtc/modules/audio_processing/audio_processing_unittest.cc
index 4d97904..42cf418 100644
--- a/webrtc/modules/audio_processing/audio_processing_unittest.cc
+++ b/webrtc/modules/audio_processing/audio_processing_unittest.cc
@@ -680,15 +680,13 @@
   // limit them w.r.t. AEC delay estimation support.
   const size_t samples_per_ms =
       rtc::SafeMin<size_t>(16u, frame_->samples_per_channel_ / 10);
-  int expected_median = std::min(std::max(delay_ms - system_delay_ms,
-                                          delay_min), delay_max);
-  int expected_median_high = std::min(
-      std::max(expected_median + static_cast<int>(96 / samples_per_ms),
-               delay_min),
+  const int expected_median =
+      rtc::SafeClamp<int>(delay_ms - system_delay_ms, delay_min, delay_max);
+  const int expected_median_high = rtc::SafeClamp<int>(
+      expected_median + rtc::dchecked_cast<int>(96 / samples_per_ms), delay_min,
       delay_max);
-  int expected_median_low = std::min(
-      std::max(expected_median - static_cast<int>(96 / samples_per_ms),
-               delay_min),
+  const int expected_median_low = rtc::SafeClamp<int>(
+      expected_median - rtc::dchecked_cast<int>(96 / samples_per_ms), delay_min,
       delay_max);
   // Verify delay metrics.
   int median;