Selaa lähdekoodia

Merge pull request #7180 from stac47/fix_deprecated_is_pod

Fix std::is_pod deprecated in C++20
Adam Cozzette 4 vuotta sitten
vanhempi
commit
977dde9ee3

+ 1 - 1
src/google/protobuf/arena.h

@@ -335,7 +335,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
   template <typename T>
   template <typename T>
   PROTOBUF_ALWAYS_INLINE static T* CreateArray(Arena* arena,
   PROTOBUF_ALWAYS_INLINE static T* CreateArray(Arena* arena,
                                                size_t num_elements) {
                                                size_t num_elements) {
-    static_assert(std::is_pod<T>::value,
+    static_assert(std::is_standard_layout<T>::value && std::is_trivial<T>::value,
                   "CreateArray requires a trivially constructible type");
                   "CreateArray requires a trivially constructible type");
     static_assert(std::is_trivially_destructible<T>::value,
     static_assert(std::is_trivially_destructible<T>::value,
                   "CreateArray requires a trivially destructible type");
                   "CreateArray requires a trivially destructible type");

+ 12 - 6
src/google/protobuf/generated_message_table_driven.h

@@ -203,12 +203,18 @@ struct ParseTable {
 static_assert(sizeof(ParseTableField) <= 16, "ParseTableField is too large");
 static_assert(sizeof(ParseTableField) <= 16, "ParseTableField is too large");
 // The tables must be composed of POD components to ensure link-time
 // The tables must be composed of POD components to ensure link-time
 // initialization.
 // initialization.
-static_assert(std::is_pod<ParseTableField>::value, "");
-static_assert(std::is_pod<AuxiliaryParseTableField>::value, "");
-static_assert(std::is_pod<AuxiliaryParseTableField::enum_aux>::value, "");
-static_assert(std::is_pod<AuxiliaryParseTableField::message_aux>::value, "");
-static_assert(std::is_pod<AuxiliaryParseTableField::string_aux>::value, "");
-static_assert(std::is_pod<ParseTable>::value, "");
+static_assert(std::is_standard_layout<ParseTableField>::value, "");
+static_assert(std::is_trivial<ParseTableField>::value, "");
+static_assert(std::is_standard_layout<AuxiliaryParseTableField>::value, "");
+static_assert(std::is_trivial<AuxiliaryParseTableField>::value, "");
+static_assert(std::is_standard_layout<AuxiliaryParseTableField::enum_aux>::value, "");
+static_assert(std::is_trivial<AuxiliaryParseTableField::enum_aux>::value, "");
+static_assert(std::is_standard_layout<AuxiliaryParseTableField::message_aux>::value, "");
+static_assert(std::is_trivial<AuxiliaryParseTableField::message_aux>::value, "");
+static_assert(std::is_standard_layout<AuxiliaryParseTableField::string_aux>::value, "");
+static_assert(std::is_trivial<AuxiliaryParseTableField::string_aux>::value, "");
+static_assert(std::is_standard_layout<ParseTable>::value, "");
+static_assert(std::is_trivial<ParseTable>::value, "");
 
 
 // TODO(ckennelly): Consolidate these implementations into a single one, using
 // TODO(ckennelly): Consolidate these implementations into a single one, using
 // dynamic dispatch to the appropriate unknown field handler.
 // dynamic dispatch to the appropriate unknown field handler.

+ 3 - 3
src/google/protobuf/generated_message_table_driven_lite.h

@@ -87,7 +87,7 @@ inline ExtensionSet* GetExtensionSet(MessageLite* msg, int64 extension_offset) {
 
 
 template <typename Type>
 template <typename Type>
 inline Type* AddField(MessageLite* msg, int64 offset) {
 inline Type* AddField(MessageLite* msg, int64 offset) {
-  static_assert(std::is_pod<Type>::value,
+  static_assert(std::is_standard_layout<Type>::value && std::is_trivial<Type>::value,
                 "Do not assign");
                 "Do not assign");
 
 
   RepeatedField<Type>* repeated = Raw<RepeatedField<Type>>(msg, offset);
   RepeatedField<Type>* repeated = Raw<RepeatedField<Type>>(msg, offset);
@@ -104,7 +104,7 @@ inline std::string* AddField<std::string>(MessageLite* msg, int64 offset) {
 
 
 template <typename Type>
 template <typename Type>
 inline void AddField(MessageLite* msg, int64 offset, Type value) {
 inline void AddField(MessageLite* msg, int64 offset, Type value) {
-  static_assert(std::is_pod<Type>::value,
+  static_assert(std::is_standard_layout<Type>::value && std::is_trivial<Type>::value,
                 "Do not assign");
                 "Do not assign");
   *AddField<Type>(msg, offset) = value;
   *AddField<Type>(msg, offset) = value;
 }
 }
@@ -126,7 +126,7 @@ inline Type* MutableField(MessageLite* msg, uint32* has_bits,
 template <typename Type>
 template <typename Type>
 inline void SetField(MessageLite* msg, uint32* has_bits, uint32 has_bit_index,
 inline void SetField(MessageLite* msg, uint32* has_bits, uint32 has_bit_index,
                      int64 offset, Type value) {
                      int64 offset, Type value) {
-  static_assert(std::is_pod<Type>::value,
+  static_assert(std::is_standard_layout<Type>::value && std::is_trivial<Type>::value,
                 "Do not assign");
                 "Do not assign");
   *MutableField<Type>(msg, has_bits, has_bit_index, offset) = value;
   *MutableField<Type>(msg, has_bits, has_bit_index, offset) = value;
 }
 }

+ 1 - 1
src/google/protobuf/repeated_field.h

@@ -501,7 +501,7 @@ namespace internal {
 // effectively.
 // effectively.
 template <typename Element,
 template <typename Element,
           bool HasTrivialCopy =
           bool HasTrivialCopy =
-              std::is_pod<Element>::value>
+              std::is_standard_layout<Element>::value && std::is_trivial<Element>::value>
 struct ElementCopier {
 struct ElementCopier {
   void operator()(Element* to, const Element* from, int array_size);
   void operator()(Element* to, const Element* from, int array_size);
 };
 };