diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 710ce671c..acfdfb4df 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -295,7 +295,11 @@ using MessageTraits = decltype(MessageTraitsImpl::value); struct EnumTraitsImpl { struct Undefined; + // We use an incomplete type to cause a compiler error if something tries to + // instantiate `value` with a `T` that had no specialization. + // The `enable_if` is there to workaround some compilers/tools that complain + // on the declaration even with no instantiations. template - static Undefined value; + static std::enable_if_t value; }; template using EnumTraits = decltype(EnumTraitsImpl::value);