Allow RTC_LOG and RTC_CHECK to accept types that implements absl stringify

Bug: None
Change-Id: If99eb0e3e285c13d81cd2bbb56163c2c2311d43a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/364201
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43119}
diff --git a/rtc_base/checks.h b/rtc_base/checks.h
index 99fee97..130b8b9 100644
--- a/rtc_base/checks.h
+++ b/rtc_base/checks.h
@@ -55,6 +55,8 @@
 #include <string>
 
 #include "absl/meta/type_traits.h"
+#include "absl/strings/has_absl_stringify.h"
+#include "absl/strings/str_cat.h"
 #include "absl/strings/string_view.h"
 #include "api/scoped_refptr.h"
 #include "rtc_base/numerics/safe_compare.h"
@@ -220,6 +222,12 @@
   return {ToLogString(x)};
 }
 
+template <typename T,
+          std::enable_if_t<absl::HasAbslStringify<T>::value>* = nullptr>
+ToStringVal MakeVal(const T& x) {
+  return {absl::StrCat(x)};
+}
+
 // Ephemeral type that represents the result of the logging << operator.
 template <typename... Ts>
 class LogStreamer;