@@ -183,16 +183,9 @@ class LogMessage {
183183 LogMessage& operator <<(char (&buf)[SIZE]) ABSL_ATTRIBUTE_NOINLINE;
184184
185185 // Types that support `AbslStringify()` are serialized that way.
186- template <typename T,
187- typename std::enable_if<absl::HasAbslStringify<T>::value,
188- int >::type = 0 >
189- LogMessage& operator <<(const T& v) ABSL_ATTRIBUTE_NOINLINE;
190-
191186 // Types that don't support `AbslStringify()` but do support streaming into a
192187 // `std::ostream&` are serialized that way.
193- template <typename T,
194- typename std::enable_if<!absl::HasAbslStringify<T>::value,
195- int >::type = 0 >
188+ template <typename T>
196189 LogMessage& operator <<(const T& v) ABSL_ATTRIBUTE_NOINLINE;
197190
198191 // Note: We explicitly do not support `operator<<` for non-const references
@@ -308,21 +301,16 @@ class StringifySink final {
308301};
309302
310303// Note: the following is declared `ABSL_ATTRIBUTE_NOINLINE`
311- template <typename T,
312- typename std::enable_if<absl::HasAbslStringify<T>::value, int >::type>
304+ template <typename T>
313305LogMessage& LogMessage::operator <<(const T& v) {
314- StringifySink sink (*this );
315- // Replace with public API.
316- AbslStringify (sink, v);
317- return *this ;
318- }
319-
320- // Note: the following is declared `ABSL_ATTRIBUTE_NOINLINE`
321- template <typename T,
322- typename std::enable_if<!absl::HasAbslStringify<T>::value, int >::type>
323- LogMessage& LogMessage::operator <<(const T& v) {
324- OstreamView view (*data_);
325- view.stream () << log_internal::NullGuard<T>().Guard (v);
306+ if constexpr (absl::HasAbslStringify<T>::value) {
307+ StringifySink sink (*this );
308+ // Replace with public API.
309+ AbslStringify (sink, v);
310+ } else {
311+ OstreamView view (*data_);
312+ view.stream () << log_internal::NullGuard<T>().Guard (v);
313+ }
326314 return *this ;
327315}
328316
0 commit comments