diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 583a6f45d400f..e49d62a379637 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -152,16 +152,16 @@ class PROTOBUF_EXPORT Any final : public ::google::protobuf::Message PROTOBUF_NONNULL value_field); template < typename T, - class = typename std::enable_if::value>::type> + class = std::enable_if_t>> bool PackFrom(const T& message) { return ::google::protobuf::internal::InternalPackFrom( message, mutable_type_url(), _internal_mutable_value()); } template < typename T, - class = typename std::enable_if::value>::type> + class = std::enable_if_t>> bool PackFrom(const T& message, ::absl::string_view type_url_prefix) { return ::google::protobuf::internal::InternalPackFrom( @@ -170,8 +170,8 @@ class PROTOBUF_EXPORT Any final : public ::google::protobuf::Message } template < typename T, - class = typename std::enable_if::value>::type> + class = std::enable_if_t>> bool UnpackTo(T* PROTOBUF_NONNULL message) const { return ::google::protobuf::internal::InternalUnpackTo( _internal_type_url(), _internal_value(), message); diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 036a781003eeb..7f79d4cf21571 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -320,9 +320,9 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) template PROTOBUF_NDEBUG_INLINE static T* PROTOBUF_NONNULL CreateArray(Arena* PROTOBUF_NULLABLE arena, size_t num_elements) { - static_assert(std::is_trivially_default_constructible::value, + static_assert(std::is_trivially_default_constructible_v, "CreateArray requires a trivially constructible type"); - static_assert(std::is_trivially_destructible::value, + static_assert(std::is_trivially_destructible_v, "CreateArray requires a trivially destructible type"); ABSL_CHECK_LE(num_elements, // Max rounded down to the 8 byte alignment. @@ -367,7 +367,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) // Collapsing all template instantiations to one for generic Message reduces // code size, using the virtual destructor instead. using TypeToUse = - std::conditional_t::value, + std::conditional_t, MessageLite, T>; if (object != nullptr) { impl_.AddCleanup(static_cast(object), @@ -404,7 +404,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) // `Arena*`. template using EnableIfArena = - typename std::enable_if::value, Arena*>::type; + std::enable_if_t, Arena*>; // Use go/ranked-overloads for dispatching. struct Rank0 {}; @@ -469,7 +469,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) typedef std::integral_constant< bool, sizeof(DestructorSkippable(static_cast(nullptr))) == sizeof(char) || - std::is_trivially_destructible::value> + std::is_trivially_destructible_v> is_destructor_skippable; template @@ -592,7 +592,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) template static constexpr auto GetConstructType() { - return std::is_base_of::value + return std::is_base_of_v ? decltype(ProbeConstructType(std::declval()...))::value : ConstructType::kUnknown; } @@ -635,7 +635,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) } } - template ::value> + template > PROTOBUF_NDEBUG_INLINE void* PROTOBUF_NONNULL AllocateInternal() { if (trivial) { return AllocateAligned(sizeof(T), alignof(T)); diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index e9dbc4bfaba5b..f62c8ab460ac6 100644 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -200,11 +200,11 @@ class PROTOBUF_EXPORT TaggedStringPtr { void* ptr_; }; -static_assert(std::is_trivially_default_constructible::value, +static_assert(std::is_trivially_default_constructible_v, "TaggedStringPtr must be trivially default-constructible"); -static_assert(std::is_trivially_destructible::value, +static_assert(std::is_trivially_destructible_v, "TaggedStringPtr must be trivially destructible"); -static_assert(std::is_standard_layout::value, +static_assert(std::is_standard_layout_v, "TaggedStringPtr must be standard layout"); // This class encapsulates a pointer to a std::string with or without arena diff --git a/src/google/protobuf/compiler/cpp/arena_ctor_visibility_test.cc b/src/google/protobuf/compiler/cpp/arena_ctor_visibility_test.cc index 82f4a984a0e0e..761ec538eb565 100644 --- a/src/google/protobuf/compiler/cpp/arena_ctor_visibility_test.cc +++ b/src/google/protobuf/compiler/cpp/arena_ctor_visibility_test.cc @@ -18,22 +18,22 @@ using proto2_unittest::TestAllTypes; TEST(MessageConstructorTest, RegularCtor) { using T = proto2_unittest::TestAllTypes; - EXPECT_TRUE((std::is_constructible::value)); + EXPECT_TRUE((std::is_constructible_v)); } TEST(MessageConstructorTest, RegularCopyCtor) { using T = proto2_unittest::TestAllTypes; - EXPECT_TRUE((std::is_constructible::value)); + EXPECT_TRUE((std::is_constructible_v)); } TEST(MessageConstructorTest, ArenaCtor) { using T = proto2_unittest::TestAllTypes; - EXPECT_FALSE((std::is_constructible::value)); + EXPECT_FALSE((std::is_constructible_v)); } TEST(MessageConstructorTest, ArenaCopyCtor) { using T = proto2_unittest::TestAllTypes; - EXPECT_FALSE((std::is_constructible::value)); + EXPECT_FALSE((std::is_constructible_v)); } } // namespace diff --git a/src/google/protobuf/compiler/cpp/enum.cc b/src/google/protobuf/compiler/cpp/enum.cc index 2d5f7c33180eb..b277927984f0e 100644 --- a/src/google/protobuf/compiler/cpp/enum.cc +++ b/src/google/protobuf/compiler/cpp/enum.cc @@ -221,8 +221,8 @@ void EnumGenerator::GenerateDefinition(io::Printer* p) { // directly. Because this includes $Enum$, it must be a callback. auto write_assert = [&] { p->Emit(R"cc( - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to $Enum$_Name()."); )cc"); }; diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h index 7cfe12c26c81f..6f16627a3fc89 100644 --- a/src/google/protobuf/compiler/cpp/helpers.h +++ b/src/google/protobuf/compiler/cpp/helpers.h @@ -1015,8 +1015,8 @@ class PROTOC_EXPORT Formatter { // Convenience overloads to accept different types as arguments. static std::string ToString(absl::string_view s) { return std::string(s); } - template ::value>::type> + template >> static std::string ToString(I x) { return absl::StrCat(x); } diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc index 99bcd6c683d6b..77ea531448cc9 100644 --- a/src/google/protobuf/compiler/cpp/message.cc +++ b/src/google/protobuf/compiler/cpp/message.cc @@ -1681,8 +1681,8 @@ void MessageGenerator::GenerateImplDefinition(io::Printer* p) { using InternalArenaConstructable_ = void; using DestructorSkippable_ = void; }; - static_assert(::std::is_trivially_copy_constructible::value); - static_assert(::std::is_trivially_destructible::value); + static_assert(::std::is_trivially_copy_constructible_v); + static_assert(::std::is_trivially_destructible_v); Split* $nonnull$ _split_; )cc"); }}, @@ -1820,16 +1820,16 @@ void MessageGenerator::GenerateAnyMethodDefinition(io::Printer* p) { $nonnull$ value_field); template < typename T, - class = typename std::enable_if::value>::type> + class = typename std::enable_if_t>> bool PackFrom(const T& message) { return $pbi$::InternalPackFrom( message, mutable_type_url(), _internal_mutable_value()); } template < typename T, - class = typename std::enable_if::value>::type> + class = typename std::enable_if_t>> bool PackFrom(const T& message, ::absl::string_view type_url_prefix) { return $pbi$::InternalPackFrom( @@ -1838,8 +1838,8 @@ void MessageGenerator::GenerateAnyMethodDefinition(io::Printer* p) { } template < typename T, - class = typename std::enable_if::value>::type> + class = typename std::enable_if_t>> bool UnpackTo(T* $nonnull$ message) const { return $pbi$::InternalUnpackTo( _internal_type_url(), _internal_value(), message); diff --git a/src/google/protobuf/compiler/java/java_features.pb.h b/src/google/protobuf/compiler/java/java_features.pb.h index 2583ce1ef14af..3e0640ca7895e 100644 --- a/src/google/protobuf/compiler/java/java_features.pb.h +++ b/src/google/protobuf/compiler/java/java_features.pb.h @@ -100,8 +100,8 @@ inline constexpr int JavaFeatures_NestInFileClassFeature_NestInFileClass_NestInF PROTOC_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL JavaFeatures_NestInFileClassFeature_NestInFileClass_descriptor(); template const ::std::string& JavaFeatures_NestInFileClassFeature_NestInFileClass_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to NestInFileClass_Name()."); return JavaFeatures_NestInFileClassFeature_NestInFileClass_Name(static_cast(value)); } @@ -133,8 +133,8 @@ inline constexpr int JavaFeatures_Utf8Validation_Utf8Validation_ARRAYSIZE = 2 + PROTOC_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL JavaFeatures_Utf8Validation_descriptor(); template const ::std::string& JavaFeatures_Utf8Validation_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Utf8Validation_Name()."); return JavaFeatures_Utf8Validation_Name(static_cast(value)); } diff --git a/src/google/protobuf/compiler/parser.h b/src/google/protobuf/compiler/parser.h index b638fea2a6b72..0f45857546520 100644 --- a/src/google/protobuf/compiler/parser.h +++ b/src/google/protobuf/compiler/parser.h @@ -152,12 +152,12 @@ class PROTOBUF_EXPORT Parser final { public: template ()())>::value>> + typename = std::enable_if_t()())>>> ErrorMaker(F f) { static_assert(sizeof(F) <= sizeof(StorageT), ""); static_assert(alignof(F) <= alignof(StorageT), ""); - static_assert(std::is_trivially_destructible::value, ""); + static_assert(std::is_trivially_destructible_v, ""); ::new (static_cast(storage_)) F(f); func_ = [](const void* p) { return (*reinterpret_cast(p))(); }; } diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index fb4b8eac0b6d8..fea441be924ae 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -109,8 +109,8 @@ inline constexpr int CodeGeneratorResponse_Feature_Feature_ARRAYSIZE = 2 + 1; PROTOC_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL CodeGeneratorResponse_Feature_descriptor(); template const ::std::string& CodeGeneratorResponse_Feature_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Feature_Name()."); return CodeGeneratorResponse_Feature_Name(static_cast(value)); } diff --git a/src/google/protobuf/cpp_features.pb.h b/src/google/protobuf/cpp_features.pb.h index a61d564170a03..0e59f72019481 100644 --- a/src/google/protobuf/cpp_features.pb.h +++ b/src/google/protobuf/cpp_features.pb.h @@ -90,8 +90,8 @@ inline constexpr int CppFeatures_StringType_StringType_ARRAYSIZE = 3 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL CppFeatures_StringType_descriptor(); template const ::std::string& CppFeatures_StringType_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to StringType_Name()."); return CppFeatures_StringType_Name(static_cast(value)); } diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 193bda01695d6..5d444fe12daa8 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -198,13 +198,13 @@ template constexpr size_t EffectiveAlignof() { // `char` is special in that it gets aligned to 8. It is where we drop the // trivial structs. - return std::is_same::value ? 8 : alignof(T); + return std::is_same_v ? 8 : alignof(T); } template using AppendIfAlign = - typename std::conditional() == align, void (*)(T..., U), - void (*)(T...)>::type; + std::conditional_t() == align, void (*)(T..., U), + void (*)(T...)>; // Metafunction to sort types in descending order of alignment. // Useful for the flat allocator to ensure proper alignment of all elements @@ -250,7 +250,7 @@ constexpr int FindTypeIndex() { template constexpr int FindTypeIndex() { - return std::is_same::value ? 0 : FindTypeIndex() + 1; + return std::is_same_v ? 0 : FindTypeIndex() + 1; } // A type to value map, where the possible keys as specified in `Keys...`. @@ -313,7 +313,7 @@ class FlatAllocation { } template - using type = typename std::tuple_element>::type; + using type = std::tuple_element_t>; // Gets a tuple of the head pointers for the arrays TypeMap Pointers() const { @@ -327,8 +327,8 @@ class FlatAllocation { // Total number of bytes used by all arrays. int total_bytes() const { // Get the last end. - return ends_.template Get>::type>(); + return ends_.template Get>>(); } @@ -338,7 +338,7 @@ class FlatAllocation { // Avoid a negative value here to keep it compiling when type_index == 0 constexpr int prev_type_index = type_index == 0 ? 0 : type_index - 1; using PrevType = - typename std::tuple_element>::type; + std::tuple_element_t>; // Ensure the types are properly aligned. static_assert(EffectiveAlignof() >= EffectiveAlignof(), ""); return type_index == 0 ? RoundUpTo(sizeof(FlatAllocation)) @@ -371,7 +371,7 @@ class FlatAllocation { template bool Init() { // Skip for the `char` block. No need to zero initialize it. - if (std::is_same::value) return true; + if (std::is_same_v) return true; for (char *p = data() + BeginOffset(), *end = data() + EndOffset(); p != end; p += sizeof(U)) { ::new (p) U{}; @@ -381,7 +381,7 @@ class FlatAllocation { template bool Destroy() { - if (std::is_trivially_destructible::value) return true; + if (std::is_trivially_destructible_v) return true; for (U *it = Begin(), *end = End(); it != end; ++it) { it->~U(); } @@ -416,7 +416,7 @@ class FlatAllocatorImpl { void PlanArray(int array_size) { // We can't call PlanArray after FinalizePlanning has been called. ABSL_CHECK(!has_allocated()); - if (std::is_trivially_destructible::value) { + if (std::is_trivially_destructible_v) { // Trivial types are aligned to 8 bytes. static_assert(alignof(U) <= 8, ""); total_.template Get() += RoundUpTo<8>(array_size * sizeof(U)); @@ -424,16 +424,16 @@ class FlatAllocatorImpl { // Since we can't use `if constexpr`, just make the expression compile // when this path is not taken. using TypeToUse = - typename std::conditional::value, - char, U>::type; + std::conditional_t, + char, U>; total_.template Get() += array_size; } } template U* AllocateArray(int array_size) { - constexpr bool trivial = std::is_trivially_destructible::value; - using TypeToUse = typename std::conditional::type; + constexpr bool trivial = std::is_trivially_destructible_v; + using TypeToUse = std::conditional_t; // We can only allocate after FinalizePlanning has been called. ABSL_CHECK(has_allocated()); @@ -2282,7 +2282,7 @@ const FeatureSet* DescriptorPool::Tables::InternFeatureSet( template Type* DescriptorPool::Tables::Allocate() { - static_assert(std::is_trivially_destructible::value, ""); + static_assert(std::is_trivially_destructible_v, ""); static_assert(alignof(Type) <= 8, ""); return ::new (AllocateBytes(sizeof(Type))) Type{}; } @@ -2303,7 +2303,7 @@ internal::FlatAllocator::Allocation* DescriptorPool::Tables::CreateFlatAlloc( using FlatAlloc = internal::FlatAllocator::Allocation; int last_end = ends.template Get< - typename std::tuple_element>::type>(); + std::tuple_element_t>>(); size_t total_size = last_end + RoundUpTo(sizeof(FlatAlloc)); char* data = static_cast(internal::Allocate(total_size)); @@ -6026,7 +6026,7 @@ void DescriptorBuilder::PostProcessFieldFeatures( #define BUILD_ARRAY(INPUT, OUTPUT, NAME, METHOD, PARENT) \ OUTPUT->NAME##_count_ = INPUT.NAME##_size(); \ OUTPUT->NAME##s_ = alloc.AllocateArray< \ - typename std::remove_pointerNAME##s_)>::type>( \ + std::remove_pointer_tNAME##s_)>>( \ INPUT.NAME##_size()); \ for (int i = 0; i < INPUT.NAME##_size(); i++) { \ METHOD(INPUT.NAME(i), PARENT, OUTPUT->NAME##s_ + i, alloc); \ @@ -6614,11 +6614,11 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl( internal::VisitDescriptors( *result, proto, [&](const auto& descriptor, const auto& proto) { using OptionsT = - typename std::remove_const::type>::type; + std::remove_const_t>; using DescriptorT = - typename std::remove_const::type>::type; + std::remove_const_t>; ResolveFeatures( proto, const_cast(&descriptor), diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 703e29b7bcefd..5011fbd1c7f46 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -319,8 +319,8 @@ inline constexpr int ExtensionRangeOptions_VerificationState_VerificationState_A PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL ExtensionRangeOptions_VerificationState_descriptor(); template const ::std::string& ExtensionRangeOptions_VerificationState_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to VerificationState_Name()."); return ExtensionRangeOptions_VerificationState_Name(static_cast(value)); } @@ -367,8 +367,8 @@ inline constexpr int FieldDescriptorProto_Type_Type_ARRAYSIZE = 18 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FieldDescriptorProto_Type_descriptor(); template const ::std::string& FieldDescriptorProto_Type_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Type_Name()."); return FieldDescriptorProto_Type_Name(static_cast(value)); } @@ -400,8 +400,8 @@ inline constexpr int FieldDescriptorProto_Label_Label_ARRAYSIZE = 3 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FieldDescriptorProto_Label_descriptor(); template const ::std::string& FieldDescriptorProto_Label_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Label_Name()."); return FieldDescriptorProto_Label_Name(static_cast(value)); } @@ -433,8 +433,8 @@ inline constexpr int FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE = 3 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FileOptions_OptimizeMode_descriptor(); template const ::std::string& FileOptions_OptimizeMode_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to OptimizeMode_Name()."); return FileOptions_OptimizeMode_Name(static_cast(value)); } @@ -466,8 +466,8 @@ inline constexpr int FieldOptions_CType_CType_ARRAYSIZE = 2 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FieldOptions_CType_descriptor(); template const ::std::string& FieldOptions_CType_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to CType_Name()."); return FieldOptions_CType_Name(static_cast(value)); } @@ -499,8 +499,8 @@ inline constexpr int FieldOptions_JSType_JSType_ARRAYSIZE = 2 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FieldOptions_JSType_descriptor(); template const ::std::string& FieldOptions_JSType_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to JSType_Name()."); return FieldOptions_JSType_Name(static_cast(value)); } @@ -532,8 +532,8 @@ inline constexpr int FieldOptions_OptionRetention_OptionRetention_ARRAYSIZE = 2 PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FieldOptions_OptionRetention_descriptor(); template const ::std::string& FieldOptions_OptionRetention_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to OptionRetention_Name()."); return FieldOptions_OptionRetention_Name(static_cast(value)); } @@ -572,8 +572,8 @@ inline constexpr int FieldOptions_OptionTargetType_OptionTargetType_ARRAYSIZE = PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FieldOptions_OptionTargetType_descriptor(); template const ::std::string& FieldOptions_OptionTargetType_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to OptionTargetType_Name()."); return FieldOptions_OptionTargetType_Name(static_cast(value)); } @@ -605,8 +605,8 @@ inline constexpr int MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE = PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL MethodOptions_IdempotencyLevel_descriptor(); template const ::std::string& MethodOptions_IdempotencyLevel_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to IdempotencyLevel_Name()."); return MethodOptions_IdempotencyLevel_Name(static_cast(value)); } @@ -640,8 +640,8 @@ inline constexpr int FeatureSet_VisibilityFeature_DefaultSymbolVisibility_Defaul PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FeatureSet_VisibilityFeature_DefaultSymbolVisibility_descriptor(); template const ::std::string& FeatureSet_VisibilityFeature_DefaultSymbolVisibility_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to DefaultSymbolVisibility_Name()."); return FeatureSet_VisibilityFeature_DefaultSymbolVisibility_Name(static_cast(value)); } @@ -674,8 +674,8 @@ inline constexpr int FeatureSet_FieldPresence_FieldPresence_ARRAYSIZE = 3 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FeatureSet_FieldPresence_descriptor(); template const ::std::string& FeatureSet_FieldPresence_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to FieldPresence_Name()."); return FeatureSet_FieldPresence_Name(static_cast(value)); } @@ -707,8 +707,8 @@ inline constexpr int FeatureSet_EnumType_EnumType_ARRAYSIZE = 2 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FeatureSet_EnumType_descriptor(); template const ::std::string& FeatureSet_EnumType_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to EnumType_Name()."); return FeatureSet_EnumType_Name(static_cast(value)); } @@ -740,8 +740,8 @@ inline constexpr int FeatureSet_RepeatedFieldEncoding_RepeatedFieldEncoding_ARRA PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FeatureSet_RepeatedFieldEncoding_descriptor(); template const ::std::string& FeatureSet_RepeatedFieldEncoding_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to RepeatedFieldEncoding_Name()."); return FeatureSet_RepeatedFieldEncoding_Name(static_cast(value)); } @@ -773,8 +773,8 @@ inline constexpr int FeatureSet_Utf8Validation_Utf8Validation_ARRAYSIZE = 3 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FeatureSet_Utf8Validation_descriptor(); template const ::std::string& FeatureSet_Utf8Validation_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Utf8Validation_Name()."); return FeatureSet_Utf8Validation_Name(static_cast(value)); } @@ -806,8 +806,8 @@ inline constexpr int FeatureSet_MessageEncoding_MessageEncoding_ARRAYSIZE = 2 + PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FeatureSet_MessageEncoding_descriptor(); template const ::std::string& FeatureSet_MessageEncoding_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to MessageEncoding_Name()."); return FeatureSet_MessageEncoding_Name(static_cast(value)); } @@ -839,8 +839,8 @@ inline constexpr int FeatureSet_JsonFormat_JsonFormat_ARRAYSIZE = 2 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FeatureSet_JsonFormat_descriptor(); template const ::std::string& FeatureSet_JsonFormat_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to JsonFormat_Name()."); return FeatureSet_JsonFormat_Name(static_cast(value)); } @@ -872,8 +872,8 @@ inline constexpr int FeatureSet_EnforceNamingStyle_EnforceNamingStyle_ARRAYSIZE PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL FeatureSet_EnforceNamingStyle_descriptor(); template const ::std::string& FeatureSet_EnforceNamingStyle_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to EnforceNamingStyle_Name()."); return FeatureSet_EnforceNamingStyle_Name(static_cast(value)); } @@ -905,8 +905,8 @@ inline constexpr int GeneratedCodeInfo_Annotation_Semantic_Semantic_ARRAYSIZE = PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL GeneratedCodeInfo_Annotation_Semantic_descriptor(); template const ::std::string& GeneratedCodeInfo_Annotation_Semantic_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Semantic_Name()."); return GeneratedCodeInfo_Annotation_Semantic_Name(static_cast(value)); } @@ -946,8 +946,8 @@ inline bool Edition_IsValid(int value) { PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL Edition_descriptor(); template const ::std::string& Edition_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Edition_Name()."); return ::google::protobuf::internal::NameOfEnum(Edition_descriptor(), value); } @@ -974,8 +974,8 @@ inline constexpr int SymbolVisibility_ARRAYSIZE = 2 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL SymbolVisibility_descriptor(); template const ::std::string& SymbolVisibility_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to SymbolVisibility_Name()."); return SymbolVisibility_Name(static_cast(value)); } diff --git a/src/google/protobuf/descriptor_database.h b/src/google/protobuf/descriptor_database.h index 7a3b22313c5a2..fcca027ffb8e8 100644 --- a/src/google/protobuf/descriptor_database.h +++ b/src/google/protobuf/descriptor_database.h @@ -132,8 +132,8 @@ class PROTOBUF_EXPORT DescriptorDatabase { bool FindAllMessageNames(std::vector* PROTOBUF_NONNULL output); private: - static_assert(std::is_same::value || - std::is_same::value, + static_assert(std::is_same_v || + std::is_same_v, "StringViewArg must be either " "absl::string_view or const std::string&"); }; diff --git a/src/google/protobuf/descriptor_visitor_test.cc b/src/google/protobuf/descriptor_visitor_test.cc index 21246f269c237..b6acfece7ef67 100644 --- a/src/google/protobuf/descriptor_visitor_test.cc +++ b/src/google/protobuf/descriptor_visitor_test.cc @@ -96,7 +96,7 @@ TEST(VisitDescriptorsTest, AllTypesDeduceSelective) { // Only select on descriptors with a full_name method. [&](const auto& descriptor) -> std::enable_if_t< - !std::is_void::value> { + !std::is_void_v> { descriptors.push_back(descriptor.full_name()); }); // FileDescriptor doesn't have a full_name method. diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index 495cac8350a29..405e3223b055a 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -206,7 +206,7 @@ void ExtensionSet::DeleteFlatMap(const ExtensionSet::KeyValue* flat, uint16_t flat_capacity) { // Arena::CreateArray already requires a trivially destructible type, but // ensure this constraint is not violated in the future. - static_assert(std::is_trivially_destructible::value, + static_assert(std::is_trivially_destructible_v, "CreateArray requires a trivially destructible type"); // A const-cast is needed, but this is safe as we are about to deallocate the // array. diff --git a/src/google/protobuf/generated_message_tctable_decl.h b/src/google/protobuf/generated_message_tctable_decl.h index a71cb1cbfbd4a..adbc9c93c3497 100644 --- a/src/google/protobuf/generated_message_tctable_decl.h +++ b/src/google/protobuf/generated_message_tctable_decl.h @@ -561,7 +561,7 @@ struct TcParseTable<0, 0, 0, kNameTableSize, kFieldLookupSize> { std::array field_names; }; -static_assert(std::is_standard_layout>::value, +static_assert(std::is_standard_layout_v>, "TcParseTable must be standard layout."); static_assert(offsetof(TcParseTable<1>, fast_entries) == diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 19597d1510baa..6ab5b97d89b48 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -926,7 +926,7 @@ class PROTOBUF_EXPORT EpsCopyOutputStream { template PROTOBUF_ALWAYS_INLINE static uint8_t* UnsafeVarint(T value, uint8_t* ptr) { - static_assert(std::is_unsigned::value, + static_assert(std::is_unsigned_v, "Varint serialization must be unsigned"); while (ABSL_PREDICT_FALSE(value >= 0x80)) { *ptr = static_cast(value | 0x80); @@ -1067,15 +1067,15 @@ class PROTOBUF_EXPORT CodedOutputStream { public: // Creates a CodedOutputStream that writes to the given `stream`. // The provided stream must publicly derive from `ZeroCopyOutputStream`. - template ::value>::type> + template >> explicit CodedOutputStream(Stream* stream); // Creates a CodedOutputStream that writes to the given `stream`, and does // an 'eager initialization' of the internal state if `eager_init` is true. // The provided stream must publicly derive from `ZeroCopyOutputStream`. - template ::value>::type> + template >> CodedOutputStream(Stream* stream, bool eager_init); CodedOutputStream(const CodedOutputStream&) = delete; CodedOutputStream& operator=(const CodedOutputStream&) = delete; diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h index 6f6cdae090958..944839617400e 100644 --- a/src/google/protobuf/io/printer.h +++ b/src/google/protobuf/io/printer.h @@ -535,11 +535,11 @@ class PROTOBUF_EXPORT Printer { // Returns an RAII object that pops the lookup frame. template < typename Map = absl::flat_hash_map, - typename = std::enable_if_t::value>, + typename = std::enable_if_t>, // Prefer the more specific span impl if this could be turned into // a span. typename = std::enable_if_t< - !std::is_convertible>::value>> + !std::is_convertible_v>>> auto WithVars(Map&& vars); // Pushes a new variable lookup frame that stores `vars` by value. @@ -951,7 +951,7 @@ struct Printer::AnnotationRecord { template < typename String, - std::enable_if_t::value, + std::enable_if_t, int> = 0> AnnotationRecord( // NOLINT(google-explicit-constructor) const String& file_path, @@ -961,7 +961,7 @@ struct Printer::AnnotationRecord { template ::value, int> = 0> + std::enable_if_t, int> = 0> AnnotationRecord( // NOLINT(google-explicit-constructor) const Desc* desc, std::optional semantic = std::nullopt) diff --git a/src/google/protobuf/json/internal/unparser.cc b/src/google/protobuf/json/internal/unparser.cc index 36b2c0dd58272..a478f6ca2e868 100644 --- a/src/google/protobuf/json/internal/unparser.cc +++ b/src/google/protobuf/json/internal/unparser.cc @@ -100,7 +100,7 @@ bool RoundTripsThroughDouble(Int x) { // Thus, we have to go through ldexp. double min = 0; double max_plus_one = std::ldexp(1.0, sizeof(Int) * 8); - if (std::is_signed::value) { + if (std::is_signed_v) { max_plus_one /= 2; min = -max_plus_one; } diff --git a/src/google/protobuf/json/internal/writer.h b/src/google/protobuf/json/internal/writer.h index c1b66f441ed40..662b21dadc4c0 100644 --- a/src/google/protobuf/json/internal/writer.h +++ b/src/google/protobuf/json/internal/writer.h @@ -65,7 +65,7 @@ void EachInner(const Tuple& value, F f, std::index_sequence) { template void Each(const Tuple& value, F f) { EachInner(value, f, - std::make_index_sequence::value>()); + std::make_index_sequence>()); } // See JsonWriter::Write(). @@ -154,7 +154,7 @@ class JsonWriter { auto Write(Ts... args) -> // This bit of SFINAE avoids this function being called with one argument, // so the other overloads of Write() can be picked up instead. - typename std::enable_if::type { + std::enable_if_t { Each(std::make_tuple(args...), [this](auto x) { this->Write(x); }); } diff --git a/src/google/protobuf/lite_unittest.cc b/src/google/protobuf/lite_unittest.cc index ba9d33bf50d3e..80c459b206fb7 100644 --- a/src/google/protobuf/lite_unittest.cc +++ b/src/google/protobuf/lite_unittest.cc @@ -167,7 +167,7 @@ class LiteTest : public ::testing::Test {}; struct TypedTestName { template static std::string GetName(int /*i*/) { - return std::is_same::value ? "Cord" : "String"; + return std::is_same_v ? "Cord" : "String"; } }; diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 08dbfdf7f3e93..dcf45d6230662 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -107,8 +107,8 @@ struct KeyForBaseImpl { using type = T; }; template -struct KeyForBaseImpl::value && - std::is_signed::value>> { +struct KeyForBaseImpl && + std::is_signed_v>> { using type = std::make_unsigned_t; }; template @@ -119,7 +119,7 @@ using KeyForBase = typename KeyForBaseImpl::type; // only accept `key_type`. template struct TransparentSupport { - static_assert(std::is_scalar::value, + static_assert(std::is_scalar_v, "Should only be used for ints."); template @@ -138,10 +138,10 @@ template <> struct TransparentSupport { template static absl::string_view ImplicitConvert(T&& str) { - if constexpr (std::is_convertible::value) { + if constexpr (std::is_convertible_v) { absl::string_view res = str; return res; - } else if constexpr (std::is_convertible::value) { + } else if constexpr (std::is_convertible_v) { const std::string& ref = str; return ref; } else { @@ -224,13 +224,13 @@ class UntypedMapIterator { // These properties are depended upon by Rust FFI. static_assert( - std::is_trivially_default_constructible::value, + std::is_trivially_default_constructible_v, "UntypedMapIterator must be trivially default-constructible."); -static_assert(std::is_trivially_copyable::value, +static_assert(std::is_trivially_copyable_v, "UntypedMapIterator must be trivially copyable."); -static_assert(std::is_trivially_destructible::value, +static_assert(std::is_trivially_destructible_v, "UntypedMapIterator must be trivially destructible."); -static_assert(std::is_standard_layout::value, +static_assert(std::is_standard_layout_v, "UntypedMapIterator must be standard layout."); static_assert(offsetof(UntypedMapIterator, node_) == 0, "node_ must be the first field of UntypedMapIterator."); @@ -704,14 +704,14 @@ class MapFieldBaseForParse { }; // The value might be of different signedness, so use memcpy to extract it. -template ::value, int> = 0> +template , int> = 0> T ReadKey(const void* ptr) { T out; memcpy(&out, ptr, sizeof(T)); return out; } -template ::value, int> = 0> +template , int> = 0> const T& ReadKey(const void* ptr) { return *reinterpret_cast(ptr); } @@ -748,7 +748,7 @@ inline map_index_t Hash(uint64_t k, void* salt) { template class KeyMapBase : public UntypedMapBase { - static_assert(!std::is_signed::value || !std::is_integral::value, + static_assert(!std::is_signed_v || !std::is_integral_v, ""); using TS = TransparentSupport; @@ -1218,32 +1218,32 @@ class Map : private internal::KeyMapBase> { CopyFromImpl(arena, other); } #endif - static_assert(!std::is_const::value && - !std::is_const::value, + static_assert(!std::is_const_v && + !std::is_const_v, "We do not support const types."); - static_assert(!std::is_volatile::value && - !std::is_volatile::value, + static_assert(!std::is_volatile_v && + !std::is_volatile_v, "We do not support volatile types."); - static_assert(!std::is_pointer::value && - !std::is_pointer::value, + static_assert(!std::is_pointer_v && + !std::is_pointer_v, "We do not support pointer types."); - static_assert(!std::is_reference::value && - !std::is_reference::value, + static_assert(!std::is_reference_v && + !std::is_reference_v, "We do not support reference types."); static constexpr PROTOBUF_ALWAYS_INLINE void StaticValidityCheck() { static_assert(alignof(internal::NodeBase) >= alignof(mapped_type), "Alignment of mapped type is too high."); static_assert( - std::disjunction, + std::disjunction_v, internal::is_supported_string_type, - internal::is_internal_map_key_type>::value, + internal::is_internal_map_key_type>, "We only support integer, string, or designated internal key " "types."); - static_assert(std::disjunction< + static_assert(std::disjunction_v< internal::is_supported_scalar_type, is_proto_enum, internal::is_supported_message_type, - internal::is_internal_map_value_type>::value, + internal::is_internal_map_value_type>, "We only support scalar, Message, and designated internal " "mapped types."); // The Rust implementation that wraps C++ protos relies on the ability to @@ -1268,19 +1268,19 @@ class Map : private internal::KeyMapBase> { template struct SameAsElementReference - : std::is_same::type>::type, - typename std::remove_cv< - typename std::remove_reference

::type>::type> {}; + : std::is_same>, + std::remove_cv_t< + std::remove_reference_t

>> {}; template using RequiresInsertable = - typename std::enable_if::value || + std::enable_if_t || SameAsElementReference

::value, - int>::type; + int>; template using RequiresNotInit = - typename std::enable_if::value, int>::type; + std::enable_if_t, int>; template using key_arg = typename TS::template key_arg; @@ -1400,7 +1400,7 @@ class Map : private internal::KeyMapBase> { template < typename K = key_type, // Disable for integral types to reduce code bloat. - typename = typename std::enable_if::value>::type> + typename = std::enable_if_t>> T& operator[](key_arg&& key) ABSL_ATTRIBUTE_LIFETIME_BOUND { return try_emplace(std::forward>(key)).first->second; } @@ -1481,8 +1481,8 @@ class Map : private internal::KeyMapBase> { // case 1.2: "default" constructed + copy/move assignment auto p = TryEmplaceInternal(std::forward(k)); if (p.second) { - if constexpr (std::is_same::type...), - void(mapped_type)>::value) { + if constexpr (std::is_same_v...), + void(mapped_type)>) { // Avoid the temporary when the input is the right type. p.first->second = (std::forward(args), ...); } else { @@ -1513,7 +1513,7 @@ class Map : private internal::KeyMapBase> { // We try to construct `init_type` from `Args` with a fall back to // `value_type`. The latter is less desired as it unconditionally makes a // copy of `value_type::first`. - if constexpr (std::is_constructible::value) { + if constexpr (std::is_constructible_v) { return insert(init_type(std::forward(args)...)); } else { return insert(value_type(std::forward(args)...)); @@ -1623,9 +1623,9 @@ class Map : private internal::KeyMapBase> { template PROTOBUF_ALWAYS_INLINE Node* CreateNode(Arena* arena, K&& k, Args&&... args) { // If K is not key_type, make the conversion to key_type explicit. - using TypeToInit = typename std::conditional< - std::is_same::type, key_type>::value, K&&, - key_type>::type; + using TypeToInit = std::conditional_t< + std::is_same_v, key_type>, K&&, + key_type>; ABSL_DCHECK_EQ(arena, this->arena()); Node* node = static_cast(this->AllocNode(arena, sizeof(Node))); diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index 9d8c3c2004ea5..04a98932a42f9 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -89,8 +89,8 @@ class MapEntry : public Message { // We don't want to instantiate the template with every unique derived type. // The assertion is in the destructor because we need `Value` to be // complete to test it. - static_assert(!std::is_base_of::value || - std::is_same::value, + static_assert(!std::is_base_of_v || + std::is_same_v, ""); if (GetArena() != nullptr) return; diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc index 386925d0a5d6a..847172f4a0a88 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc @@ -297,8 +297,8 @@ TEST(MapTest, ErasingEnoughCausesDownwardRehashOnNextInsert) { // public API will still use size_t to avoid changing the API. Test that. TEST(MapTest, SizeTypeIsSizeT) { using M = Map; - EXPECT_TRUE((std::is_same::value)); - EXPECT_TRUE((std::is_same::value)); + EXPECT_TRUE((std::is_same_v)); + EXPECT_TRUE((std::is_same_v)); size_t x = 0; x = std::max(M().size(), x); (void)x; diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index e4dc3ed3d873c..b5ef183a1f9ac 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -38,7 +38,7 @@ class MapWireFieldTypeTraits {}; WireFormatLite::TYPE_MESSAGE, \ Type*, CType>; \ using MapEntryAccessorType = \ - std::conditional_t::value, int, Type>; \ + std::conditional_t, int, Type>; \ static const WireFormatLite::WireType kWireType = \ WireFormatLite::WIRETYPE_##WireFormatType; \ }; diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index f7980452e43ab..87945917bc84b 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -1478,7 +1478,7 @@ std::string Utf8Format(const MessageLite& message_lite); // message is of instance `T`. template const T* DynamicCastMessage(const MessageLite* from) { - static_assert(std::is_base_of::value, ""); + static_assert(std::is_base_of_v, ""); // We might avoid the call to T::GetClassData() altogether if T were to // expose the class data pointer. diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index a4896de00dad7..d244e424af60b 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -547,7 +547,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { using LazyEagerVerifyFnType = const char* (*)(const char* ptr, ParseContext* ctx); -using LazyEagerVerifyFnRef = std::remove_pointer::type&; +using LazyEagerVerifyFnRef = std::remove_pointer_t&; // ParseContext holds all data that is global to the entire parse. Most @@ -737,7 +737,7 @@ T UnalignedLoad(const char* p) { return res; } template ::value>> + typename = std::enable_if_t>> T UnalignedLoad(const Void* p) { return UnalignedLoad(reinterpret_cast(p)); } diff --git a/src/google/protobuf/port.h b/src/google/protobuf/port.h index 6d24ba08c70f0..00d4d085008a2 100644 --- a/src/google/protobuf/port.h +++ b/src/google/protobuf/port.h @@ -195,7 +195,7 @@ struct ArenaInitialized { template void AssertDownCast(From* from) { - static_assert(std::is_base_of::value, "illegal DownCast"); + static_assert(std::is_base_of_v, "illegal DownCast"); // Check that this function is not used to downcast message types. // For those we should use {Down,Dynamic}CastTo{Message,Generated}. diff --git a/src/google/protobuf/reflection.h b/src/google/protobuf/reflection.h index 46d3dec2b1a00..e8d1552420751 100644 --- a/src/google/protobuf/reflection.h +++ b/src/google/protobuf/reflection.h @@ -47,7 +47,7 @@ class MutableRepeatedFieldRef; // RepeatedFieldRef definition for non-message types. template class RepeatedFieldRef< - T, typename std::enable_if::value>::type> { + T, std::enable_if_t>> { typedef typename internal::RefTypeTraits::iterator IteratorType; typedef typename internal::RefTypeTraits::AccessorType AccessorType; @@ -84,7 +84,7 @@ class RepeatedFieldRef< // MutableRepeatedFieldRef definition for non-message types. template class MutableRepeatedFieldRef< - T, typename std::enable_if::value>::type> { + T, std::enable_if_t>> { typedef typename internal::RefTypeTraits::AccessorType AccessorType; public: @@ -136,7 +136,7 @@ class MutableRepeatedFieldRef< // RepeatedFieldRef definition for message types. template class RepeatedFieldRef< - T, typename std::enable_if::value>::type> { + T, std::enable_if_t>> { typedef typename internal::RefTypeTraits::iterator IteratorType; typedef typename internal::RefTypeTraits::AccessorType AccessorType; @@ -196,7 +196,7 @@ class RepeatedFieldRef< // MutableRepeatedFieldRef definition for message types. template class MutableRepeatedFieldRef< - T, typename std::enable_if::value>::type> { + T, std::enable_if_t>> { typedef typename internal::RefTypeTraits::AccessorType AccessorType; public: @@ -494,7 +494,7 @@ DEFINE_PRIMITIVE(BOOL, bool) template struct RefTypeTraits< - T, typename std::enable_if::is_primitive>::type> { + T, std::enable_if_t::is_primitive>> { typedef RepeatedFieldRefIterator iterator; typedef RepeatedFieldAccessor AccessorType; typedef T AccessorValueType; @@ -509,7 +509,7 @@ struct RefTypeTraits< template struct RefTypeTraits< - T, typename std::enable_if::value>::type> { + T, std::enable_if_t::value>> { typedef RepeatedFieldRefIterator iterator; typedef RepeatedFieldAccessor AccessorType; // We use int32_t for repeated enums in RepeatedFieldAccessor. @@ -525,7 +525,7 @@ struct RefTypeTraits< template struct RefTypeTraits< - T, typename std::enable_if::value>::type> { + T, std::enable_if_t>> { typedef RepeatedFieldRefIterator iterator; typedef RepeatedFieldAccessor AccessorType; typedef std::string AccessorValueType; @@ -551,7 +551,7 @@ struct MessageDescriptorGetter { template struct RefTypeTraits< - T, typename std::enable_if::value>::type> { + T, std::enable_if_t>> { typedef RepeatedFieldRefIterator iterator; typedef RepeatedFieldAccessor AccessorType; typedef Message AccessorValueType; diff --git a/src/google/protobuf/reflection_visit_field_info.h b/src/google/protobuf/reflection_visit_field_info.h index f12f6a3f8c7a0..2934e0c732ec9 100644 --- a/src/google/protobuf/reflection_visit_field_info.h +++ b/src/google/protobuf/reflection_visit_field_info.h @@ -57,10 +57,10 @@ class iterator_range { // Users who need to know the "size" of a non-random-access iterator_range // should pass the range to `absl::c_distance()` instead. template - typename std::enable_if::iterator_category>::value, - size_t>::type + It>::iterator_category>, + size_t> size() const { return std::distance(begin_iterator_, end_iterator_); } diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index a29ba62bfde85..20269cd3378ea 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -383,21 +383,21 @@ class ABSL_ATTRIBUTE_WARN_UNUSED PROTOBUF_DECLSPEC_EMPTY_BASES static_assert( alignof(Arena) >= alignof(Element), "We only support types that have an alignment smaller than Arena"); - static_assert(!std::is_const::value, + static_assert(!std::is_const_v, "We do not support const value types."); - static_assert(!std::is_volatile::value, + static_assert(!std::is_volatile_v, "We do not support volatile value types."); - static_assert(!std::is_pointer::value, + static_assert(!std::is_pointer_v, "We do not support pointer value types."); - static_assert(!std::is_reference::value, + static_assert(!std::is_reference_v, "We do not support reference value types."); static constexpr PROTOBUF_ALWAYS_INLINE void StaticValidityCheck() { static_assert( - std::disjunction, + std::disjunction_v, internal::is_supported_floating_point_type, std::is_same, std::is_same, - is_proto_enum>::value, + is_proto_enum>, "We only support non-string scalars in RepeatedField."); } @@ -423,8 +423,8 @@ class ABSL_ATTRIBUTE_WARN_UNUSED PROTOBUF_DECLSPEC_EMPTY_BASES #endif template ())>::value>::type> + typename = std::enable_if_t())>>> RepeatedField(Iter begin, Iter end); // Arena enabled constructors: for internal use only. @@ -750,7 +750,7 @@ class ABSL_ATTRIBUTE_WARN_UNUSED PROTOBUF_DECLSPEC_EMPTY_BASES // This function does nothing if `Element` is trivial. static void Destroy([[maybe_unused]] const Element* begin, [[maybe_unused]] const Element* end) { - if constexpr (!std::is_trivially_destructible::value) { + if constexpr (!std::is_trivially_destructible_v) { std::for_each(begin, end, [&](const Element& e) { e.~Element(); }); } } @@ -1347,9 +1347,9 @@ template template inline void RepeatedField::AddWithArena(Arena* arena, Iter begin, Iter end) { - if (std::is_base_of< + if (std::is_base_of_v< std::forward_iterator_tag, - typename std::iterator_traits::iterator_category>::value) { + typename std::iterator_traits::iterator_category>) { AddForwardIterator(arena, begin, end); } else { AddInputIterator(arena, begin, end); @@ -1674,7 +1674,7 @@ PROTOBUF_NOINLINE void RepeatedField::GrowNoAnnotate(Arena* arena, if (old_size > 0) { Element* pnew = static_cast(new_rep->elements()); Element* pold = elements(was_soo); - if constexpr (std::is_trivially_copyable::value || + if constexpr (std::is_trivially_copyable_v || absl::is_trivially_relocatable::value) { memcpy(static_cast(pnew), pold, old_size * sizeof(Element)); } else { @@ -1748,7 +1748,7 @@ template class RepeatedIterator { private: using traits = - std::iterator_traits::type*>; + std::iterator_traits*>; public: // Note: value_type is never cv-qualified. @@ -1764,8 +1764,8 @@ class RepeatedIterator { // Allows "upcasting" from RepeatedIterator to // RepeatedIterator. template ::value>::type* = nullptr> + std::enable_if_t>* = nullptr> constexpr RepeatedIterator( const RepeatedIterator& other) noexcept : it_(other.it_) {} diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index de91be042c3f3..f9f5cfb7f731c 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -697,7 +697,7 @@ TEST(RepeatedField, AddRange7) { int ints[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; absl::Span span(ints); auto p = span.begin(); - static_assert(std::is_convertible::value, ""); + static_assert(std::is_convertible_v, ""); RepeatedField me; me.Add(span.begin(), span.end()); diff --git a/src/google/protobuf/repeated_ptr_field.h b/src/google/protobuf/repeated_ptr_field.h index e67914eddcb0b..01deec57551fb 100644 --- a/src/google/protobuf/repeated_ptr_field.h +++ b/src/google/protobuf/repeated_ptr_field.h @@ -177,9 +177,9 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // We use the same TypeHandler for all Message types to deduplicate generated // code. template - using CommonHandler = typename std::conditional< - std::is_base_of>::value, - GenericTypeHandler, TypeHandler>::type; + using CommonHandler = std::conditional_t< + std::is_base_of_v>, + GenericTypeHandler, TypeHandler>; #ifdef PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD constexpr RepeatedPtrFieldBase() @@ -363,8 +363,8 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // Appends all message values from `from` to this instance. template void MergeFrom(const RepeatedPtrFieldBase& from, Arena* arena) { - static_assert(std::is_base_of::value, ""); - if constexpr (!std::is_base_of::value) { + static_assert(std::is_base_of_v, ""); + if constexpr (!std::is_base_of_v) { // For LITE objects we use the generic MergeFrom to save on binary size. return MergeFrom(from, arena); } @@ -1099,19 +1099,19 @@ class GenericTypeHandler { template class ABSL_ATTRIBUTE_WARN_UNUSED RepeatedPtrField final : private internal::RepeatedPtrFieldBase { - static_assert(!std::is_const::value, + static_assert(!std::is_const_v, "We do not support const value types."); - static_assert(!std::is_volatile::value, + static_assert(!std::is_volatile_v, "We do not support volatile value types."); - static_assert(!std::is_pointer::value, + static_assert(!std::is_pointer_v, "We do not support pointer value types."); - static_assert(!std::is_reference::value, + static_assert(!std::is_reference_v, "We do not support reference value types."); static constexpr PROTOBUF_ALWAYS_INLINE void StaticValidityCheck() { static_assert( - std::disjunction< + std::disjunction_v< internal::is_supported_string_type, - internal::is_supported_message_type>::value, + internal::is_supported_message_type>, "We only support string and Message types in RepeatedPtrField."); static_assert(alignof(Element) <= internal::ArenaAlignDefault::align, "Overaligned types are not supported"); @@ -1141,12 +1141,12 @@ class ABSL_ATTRIBUTE_WARN_UNUSED RepeatedPtrField final // Arena enabled constructors: for internal use only. #ifdef PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD - constexpr PROTOBUF_ALWAYS_INLINE RepeatedPtrField( - internal::InternalVisibility, internal::InternalMetadataOffset offset) + constexpr RepeatedPtrField(internal::InternalVisibility, + internal::InternalMetadataOffset offset) : RepeatedPtrField(offset) {} - PROTOBUF_ALWAYS_INLINE RepeatedPtrField( - internal::InternalVisibility, internal::InternalMetadataOffset offset, - const RepeatedPtrField& rhs) + RepeatedPtrField(internal::InternalVisibility, + internal::InternalMetadataOffset offset, + const RepeatedPtrField& rhs) : RepeatedPtrField(offset, rhs) {} #else @@ -1161,11 +1161,11 @@ class ABSL_ATTRIBUTE_WARN_UNUSED RepeatedPtrField final #endif // !PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD template ())>::value>::type> + typename = std::enable_if_t())>>> RepeatedPtrField(Iter begin, Iter end); - PROTOBUF_ALWAYS_INLINE RepeatedPtrField(const RepeatedPtrField& rhs) + RepeatedPtrField(const RepeatedPtrField& rhs) : RepeatedPtrField( #ifdef PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD internal::InternalMetadataOffset(), @@ -1178,7 +1178,7 @@ class ABSL_ATTRIBUTE_WARN_UNUSED RepeatedPtrField final ABSL_ATTRIBUTE_LIFETIME_BOUND; #ifdef PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD - PROTOBUF_ALWAYS_INLINE RepeatedPtrField(RepeatedPtrField&& rhs) noexcept + RepeatedPtrField(RepeatedPtrField&& rhs) noexcept : RepeatedPtrField(internal::InternalMetadataOffset(), std::move(rhs)) {} #else RepeatedPtrField(RepeatedPtrField&& rhs) noexcept @@ -1561,7 +1561,7 @@ template #ifdef PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD constexpr #endif - PROTOBUF_ALWAYS_INLINE RepeatedPtrField::RepeatedPtrField( + inline RepeatedPtrField::RepeatedPtrField( #ifdef PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD internal::InternalMetadataOffset offset #else @@ -1581,7 +1581,7 @@ constexpr } template -PROTOBUF_ALWAYS_INLINE RepeatedPtrField::RepeatedPtrField( +inline RepeatedPtrField::RepeatedPtrField( #ifdef PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD internal::InternalMetadataOffset offset, #else @@ -1601,8 +1601,7 @@ PROTOBUF_ALWAYS_INLINE RepeatedPtrField::RepeatedPtrField( template template -PROTOBUF_ALWAYS_INLINE RepeatedPtrField::RepeatedPtrField(Iter begin, - Iter end) { +inline RepeatedPtrField::RepeatedPtrField(Iter begin, Iter end) { StaticValidityCheck(); Add(begin, end); } @@ -1611,7 +1610,7 @@ template RepeatedPtrField::~RepeatedPtrField() { StaticValidityCheck(); if (!NeedsDestroy()) return; - if constexpr (std::is_base_of::value) { + if constexpr (std::is_base_of_v) { DestroyProtos(); } else { Destroy(); @@ -1749,9 +1748,9 @@ template template PROTOBUF_NDEBUG_INLINE void RepeatedPtrField::AddWithArena( Arena* arena, Iter begin, Iter end) { - if (std::is_base_of< + if (std::is_base_of_v< std::forward_iterator_tag, - typename std::iterator_traits::iterator_category>::value) { + typename std::iterator_traits::iterator_category>) { int reserve = static_cast(std::distance(begin, end)); ReserveWithArena(arena, size() + reserve); } @@ -1930,9 +1929,9 @@ inline size_t RepeatedPtrField::SpaceUsedExcludingSelfLong() const { // `google::protobuf::Message` has a virtual method `SpaceUsedLong`, hence we can // instantiate just one function for all protobuf messages. // Note: std::is_base_of requires that `Element` is a concrete class. - using H = typename std::conditional::value, + using H = std::conditional_t, internal::GenericTypeHandler, - TypeHandler>::type; + TypeHandler>; return RepeatedPtrFieldBase::SpaceUsedExcludingSelfLong(); } @@ -2079,7 +2078,7 @@ class RepeatedPtrIterator { public: using iterator = RepeatedPtrIterator; using iterator_category = std::random_access_iterator_tag; - using value_type = typename std::remove_const::type; + using value_type = std::remove_const_t; using difference_type = std::ptrdiff_t; using pointer = Element*; using reference = Element&; @@ -2090,8 +2089,8 @@ class RepeatedPtrIterator { // Allows "upcasting" from RepeatedPtrIterator to // RepeatedPtrIterator. template ::value>::type* = nullptr> + std::enable_if_t>* = nullptr> RepeatedPtrIterator(const RepeatedPtrIterator& other) : it_(other.it_) {} @@ -2199,7 +2198,7 @@ template class RepeatedPtrOverPtrsIterator { private: using traits = - std::iterator_traits::type*>; + std::iterator_traits*>; public: using value_type = typename traits::value_type; @@ -2218,9 +2217,9 @@ class RepeatedPtrOverPtrsIterator { // RepeatedPtrOverPtrsIterator. template < typename OtherElement, typename OtherVoidPtr, - typename std::enable_if< - std::is_convertible::value && - std::is_convertible::value>::type* = nullptr> + std::enable_if_t< + std::is_convertible_v && + std::is_convertible_v>* = nullptr> RepeatedPtrOverPtrsIterator( const RepeatedPtrOverPtrsIterator& other) : it_(other.it_) {} diff --git a/src/google/protobuf/repeated_ptr_field_unittest.cc b/src/google/protobuf/repeated_ptr_field_unittest.cc index 5c2707b4bbc78..9b120a2c5b987 100644 --- a/src/google/protobuf/repeated_ptr_field_unittest.cc +++ b/src/google/protobuf/repeated_ptr_field_unittest.cc @@ -62,20 +62,20 @@ enum RefMode { kConcrete = 0, kAbstract = 1 }; TEST(RepeatedPtrOverPtrsIteratorTest, Traits) { using It = RepeatedPtrField::pointer_iterator; - static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, + static_assert(std::is_same_v, ""); + static_assert(std::is_same_v, ""); + static_assert(std::is_same_v, ""); + static_assert(std::is_same_v, ""); + static_assert(std::is_same_v, ""); #if PROTOBUF_CPLUSPLUS_MIN(202002L) static_assert( - std::is_same::value, + std::is_same_v, ""); #else - static_assert(std::is_same::value, + static_assert(std::is_same_v, ""); #endif } @@ -96,22 +96,22 @@ TEST(RepeatedPtrOverPtrsIteratorTest, ToAddress) { TEST(ConstRepeatedPtrOverPtrsIterator, Traits) { using It = RepeatedPtrField::const_pointer_iterator; - static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, + static_assert(std::is_same_v, ""); + static_assert(std::is_same_v, ""); - static_assert(std::is_same::value, + static_assert(std::is_same_v, ""); - static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, + static_assert(std::is_same_v, ""); + static_assert(std::is_same_v, ""); #if PROTOBUF_CPLUSPLUS_MIN(202002L) static_assert( - std::is_same::value, + std::is_same_v, ""); #else - static_assert(std::is_same::value, + static_assert(std::is_same_v, ""); #endif } diff --git a/src/google/protobuf/string_view_test.cc b/src/google/protobuf/string_view_test.cc index e8986c0b35bb6..4a241b8c3dafa 100644 --- a/src/google/protobuf/string_view_test.cc +++ b/src/google/protobuf/string_view_test.cc @@ -38,7 +38,7 @@ TEST(StringViewFieldTest, SingularViewGetter) { auto singular_string = message.singular_string(); static_assert( - std::is_same::value, + std::is_same_v, "unexpected type"); EXPECT_THAT(singular_string, StrEq("0123456789")); @@ -47,7 +47,7 @@ TEST(StringViewFieldTest, SingularViewGetter) { auto singular_bytes = message.singular_bytes(); static_assert( - std::is_same::value, + std::is_same_v, "unexpected type"); EXPECT_THAT(singular_bytes, StrEq("012345678901234567890123456789")); } @@ -138,7 +138,7 @@ TEST(StringViewFieldTest, RepeatedViewGetter) { auto repeated_string_0 = message.repeated_string(0); static_assert( - std::is_same::value, + std::is_same_v, "unexpected type"); EXPECT_THAT(repeated_string_0, StrEq("foo")); EXPECT_THAT(message.repeated_string(), ElementsAre("foo", "bar", "baz")); @@ -147,7 +147,7 @@ TEST(StringViewFieldTest, RepeatedViewGetter) { auto repeated_bytes_2 = message.repeated_bytes(2); static_assert( - std::is_same::value, + std::is_same_v, "unexpected type"); EXPECT_THAT(repeated_bytes_2, StrEq("222")); EXPECT_THAT(message.repeated_bytes(), diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 5196ee385f9ea..5e81f9176df80 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -105,8 +105,8 @@ inline constexpr int NullValue_ARRAYSIZE = 0 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL NullValue_descriptor(); template const ::std::string& NullValue_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to NullValue_Name()."); return NullValue_Name(static_cast(value)); } diff --git a/src/google/protobuf/stubs/callback.h b/src/google/protobuf/stubs/callback.h index ed75a3c3f0c2a..6f400fcf45d77 100644 --- a/src/google/protobuf/stubs/callback.h +++ b/src/google/protobuf/stubs/callback.h @@ -346,7 +346,7 @@ class FunctionResultCallback_1_1 : public ResultCallback1 { template struct InternalConstRef { - typedef typename std::remove_reference::type base_type; + typedef std::remove_reference_tbase_type; typedef const base_type& type; }; @@ -402,12 +402,12 @@ class MethodResultCallback_6_2 : public ResultCallback2 { T* object_; MethodType method_; bool self_deleting_; - typename std::remove_reference::type p1_; - typename std::remove_reference::type p2_; - typename std::remove_reference::type p3_; - typename std::remove_reference::type p4_; - typename std::remove_reference::type p5_; - typename std::remove_reference::type p6_; + std::remove_reference_tp1_; + std::remove_reference_tp2_; + std::remove_reference_tp3_; + std::remove_reference_tp4_; + std::remove_reference_tp5_; + std::remove_reference_tp6_; }; } // namespace internal diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 0d76cd953fe05..3d2ffce13f055 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -135,8 +135,8 @@ inline constexpr int Field_Kind_Kind_ARRAYSIZE = 18 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL Field_Kind_descriptor(); template const ::std::string& Field_Kind_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Kind_Name()."); return Field_Kind_Name(static_cast(value)); } @@ -173,8 +173,8 @@ inline constexpr int Field_Cardinality_Cardinality_ARRAYSIZE = 3 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL Field_Cardinality_descriptor(); template const ::std::string& Field_Cardinality_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Cardinality_Name()."); return Field_Cardinality_Name(static_cast(value)); } @@ -210,8 +210,8 @@ inline constexpr int Syntax_ARRAYSIZE = 2 + 1; PROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* PROTOBUF_NONNULL Syntax_descriptor(); template const ::std::string& Syntax_Name(T value) { - static_assert(::std::is_same::value || - ::std::is_integral::value, + static_assert(::std::is_same_v || + ::std::is_integral_v, "Incorrect type passed to Syntax_Name()."); return Syntax_Name(static_cast(value)); } diff --git a/src/google/protobuf/unknown_field_set.h b/src/google/protobuf/unknown_field_set.h index 43ac3e6afc4af..530f1c0a35fab 100644 --- a/src/google/protobuf/unknown_field_set.h +++ b/src/google/protobuf/unknown_field_set.h @@ -274,17 +274,17 @@ class PROTOBUF_EXPORT UnknownFieldSet { template ::value, int> = 0> + std::is_base_of_v, int> = 0> bool InternalMergeFromMessage(const MessageType& message) { MergeFrom(message.GetReflection()->GetUnknownFields(message)); return true; } template ::value && - !std::is_base_of::value, - int>::type = 0> + std::enable_if_t< + std::is_base_of_v && + !std::is_base_of_v, + int> = 0> bool InternalMergeFromMessage(const MessageType& message) { const auto& unknown_fields = message.unknown_fields(); io::ArrayInputStream array_stream(unknown_fields.data(), diff --git a/src/google/protobuf/varint_shuffle.h b/src/google/protobuf/varint_shuffle.h index e6c82787a3396..e05934d4f236f 100644 --- a/src/google/protobuf/varint_shuffle.h +++ b/src/google/protobuf/varint_shuffle.h @@ -52,8 +52,8 @@ template PROTOBUF_ALWAYS_INLINE const char* ShiftMixParseVarint(const char* p, int64_t& res1) { using Signed = std::make_signed_t; - constexpr bool kIs64BitVarint = std::is_same::value; - constexpr bool kIs32BitVarint = std::is_same::value; + constexpr bool kIs64BitVarint = std::is_same_v; + constexpr bool kIs32BitVarint = std::is_same_v; static_assert(kIs64BitVarint || kIs32BitVarint, ""); // The algorithm relies on sign extension for each byte to set all high bits diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index add6d5933a41c..420dad971c1d4 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -604,11 +604,11 @@ static size_t VarintSize(const T* data, const int n) { static_assert(sizeof(T) == 4, "This routine only works for 32 bit integers"); // is_unsigned => !ZigZag static_assert( - (std::is_unsigned::value ^ ZigZag) || std::is_signed::value, + (std::is_unsigned_v ^ ZigZag) || std::is_signed_v, "Cannot ZigZag encode unsigned types"); // is_unsigned => !SignExtended static_assert( - (std::is_unsigned::value ^ SignExtended) || std::is_signed::value, + (std::is_unsigned_v ^ SignExtended) || std::is_signed_v, "Cannot SignExtended unsigned types"); static_assert(!(SignExtended && ZigZag), "Cannot SignExtended and ZigZag on the same type"); @@ -662,7 +662,7 @@ template static size_t VarintSize64(const T* data, const int n) { static_assert(sizeof(T) == 8, "This routine only works for 64 bit integers"); // is_unsigned => !ZigZag - static_assert(!ZigZag || !std::is_unsigned::value, + static_assert(!ZigZag || !std::is_unsigned_v, "Cannot ZigZag encode unsigned types"); int vectorN = n & -32; uint64_t sum = vectorN; diff --git a/upb/mem/arena_test.cc b/upb/mem/arena_test.cc index c56f052742836..dd2702aa56fb0 100644 --- a/upb/mem/arena_test.cc +++ b/upb/mem/arena_test.cc @@ -458,16 +458,16 @@ class Environment { std::pair, std::shared_ptr> GetArenaPairWithOffset(absl::BitGen& gen, size_t offset) { - size_t index = RandomIndex(gen, 0, std::tuple_size::value - 1); + size_t index = RandomIndex(gen, 0, std::tuple_size_v - 1); size_t a_index = index % 2 == 0 ? index : index + 1; std::shared_ptr a = IndexedNonNullArena(a_index); std::shared_ptr b = IndexedNonNullArena( - (a_index + offset) % std::tuple_size::value); + (a_index + offset) % std::tuple_size_v); return {a, b}; } size_t RandomIndex(absl::BitGen& gen, size_t min_index = 0, - size_t max_index = std::tuple_size::value) { + size_t max_index = std::tuple_size_v) { return absl::Uniform(gen, min_index, max_index); }