Merge pull request #7180 from stac47/fix_deprecated_is_pod

Fix std::is_pod deprecated in C++20
pull/8087/head
Adam Cozzette 4 years ago committed by GitHub
commit 977dde9ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/google/protobuf/arena.h
  2. 18
      src/google/protobuf/generated_message_table_driven.h
  3. 6
      src/google/protobuf/generated_message_table_driven_lite.h
  4. 2
      src/google/protobuf/repeated_field.h

@ -335,7 +335,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
template <typename T>
PROTOBUF_ALWAYS_INLINE static T* CreateArray(Arena* arena,
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");
static_assert(std::is_trivially_destructible<T>::value,
"CreateArray requires a trivially destructible type");

@ -203,12 +203,18 @@ struct ParseTable {
static_assert(sizeof(ParseTableField) <= 16, "ParseTableField is too large");
// The tables must be composed of POD components to ensure link-time
// 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
// dynamic dispatch to the appropriate unknown field handler.

@ -87,7 +87,7 @@ inline ExtensionSet* GetExtensionSet(MessageLite* msg, int64 extension_offset) {
template <typename Type>
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");
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>
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");
*AddField<Type>(msg, offset) = value;
}
@ -126,7 +126,7 @@ inline Type* MutableField(MessageLite* msg, uint32* has_bits,
template <typename Type>
inline void SetField(MessageLite* msg, uint32* has_bits, uint32 has_bit_index,
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");
*MutableField<Type>(msg, has_bits, has_bit_index, offset) = value;
}

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

Loading…
Cancel
Save