Friendlier error messages from data unit classes.

By explicitly checking that the template argument is arithmetic, we
avoid exposing internal implementation details in the error message.

Bug: webrtc:9709
Change-Id: Ib1c4b46076af36fe0c4aead968487bb441d03b9a
Reviewed-on: https://webrtc-review.googlesource.com/c/112422
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25853}
diff --git a/api/units/data_rate.h b/api/units/data_rate.h
index 7119284..8a3836d 100644
--- a/api/units/data_rate.h
+++ b/api/units/data_rate.h
@@ -52,10 +52,12 @@
   }
   template <typename T>
   static constexpr DataRate bps(T bits_per_second) {
+    static_assert(std::is_arithmetic<T>::value, "");
     return FromValue(bits_per_second);
   }
   template <typename T>
   static constexpr DataRate kbps(T kilobits_per_sec) {
+    static_assert(std::is_arithmetic<T>::value, "");
     return FromFraction<1000>(kilobits_per_sec);
   }
   template <typename T = int64_t>
diff --git a/api/units/data_size.h b/api/units/data_size.h
index b4cbb65..90ef00d 100644
--- a/api/units/data_size.h
+++ b/api/units/data_size.h
@@ -31,14 +31,13 @@
     return FromStaticValue<bytes>();
   }
 
-  template <
-      typename T,
-      typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr>
+  template <typename T>
   static DataSize bytes(T bytes) {
+    static_assert(std::is_arithmetic<T>::value, "");
     return FromValue(bytes);
   }
   template <typename T = int64_t>
-  typename std::enable_if<std::is_arithmetic<T>::value, T>::type bytes() const {
+  T bytes() const {
     return ToValue<T>();
   }
 
diff --git a/api/units/time_delta.h b/api/units/time_delta.h
index 6458369..e5172f4 100644
--- a/api/units/time_delta.h
+++ b/api/units/time_delta.h
@@ -46,14 +46,17 @@
   }
   template <typename T>
   static TimeDelta seconds(T seconds) {
+    static_assert(std::is_arithmetic<T>::value, "");
     return FromFraction<1000000>(seconds);
   }
   template <typename T>
   static TimeDelta ms(T milliseconds) {
+    static_assert(std::is_arithmetic<T>::value, "");
     return FromFraction<1000>(milliseconds);
   }
   template <typename T>
   static TimeDelta us(T microseconds) {
+    static_assert(std::is_arithmetic<T>::value, "");
     return FromValue(microseconds);
   }
   template <typename T = int64_t>
diff --git a/api/units/timestamp.h b/api/units/timestamp.h
index a6e450f..370a091 100644
--- a/api/units/timestamp.h
+++ b/api/units/timestamp.h
@@ -45,14 +45,17 @@
 
   template <typename T>
   static Timestamp seconds(T seconds) {
+    static_assert(std::is_arithmetic<T>::value, "");
     return FromFraction<1000000>(seconds);
   }
   template <typename T>
   static Timestamp ms(T milliseconds) {
+    static_assert(std::is_arithmetic<T>::value, "");
     return FromFraction<1000>(milliseconds);
   }
   template <typename T>
   static Timestamp us(T microseconds) {
+    static_assert(std::is_arithmetic<T>::value, "");
     return FromValue(microseconds);
   }
   template <typename T = int64_t>