Merge pull request #2837 from inazarenko:duck_type_protos

PiperOrigin-RevId: 336087297
This commit is contained in:
Derek Mauro
2020-10-14 18:25:04 -04:00
3 changed files with 91 additions and 20 deletions

View File

@@ -235,8 +235,9 @@ struct ProtobufPrinter {
// DebugString() for better readability.
static const size_t kProtobufOneLinerMaxLength = 50;
template <typename T, typename = typename std::enable_if<
internal::IsAProtocolMessage<T>::value>::type>
template <typename T,
typename = typename std::enable_if<
internal::HasDebugStringAndShortDebugString<T>::value>::type>
static void PrintValue(const T& value, ::std::ostream* os) {
std::string pretty_str = value.ShortDebugString();
if (pretty_str.length() > kProtobufOneLinerMaxLength) {