Skip to content

Commit 58f02be

Browse files
Automated Code Change
PiperOrigin-RevId: 939608120
1 parent 9e9dbae commit 58f02be

5 files changed

Lines changed: 30 additions & 37 deletions

File tree

src/google/protobuf/parse_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
670670

671671
using LazyEagerVerifyFnType = const char* (*)(const char* ptr,
672672
ParseContext* ctx);
673-
using LazyEagerVerifyFnRef = std::remove_pointer<LazyEagerVerifyFnType>::type&;
673+
using LazyEagerVerifyFnRef = std::remove_pointer_t<LazyEagerVerifyFnType>&;
674674

675675
// ParseContext holds all data that is global to the entire parse. Most
676676
// importantly it contains the input stream, but also recursion depth and also

src/google/protobuf/port.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ struct ArenaInitialized {
198198

199199
template <typename To, typename From>
200200
void AssertDownCast(From* from) {
201-
static_assert(std::is_base_of<From, To>::value, "illegal DownCast");
201+
static_assert(std::is_base_of_v<From, To>, "illegal DownCast");
202202

203203
// Check that this function is not used to downcast message types.
204204
// For those we should use {Down,Dynamic}CastTo{Message,Generated}.

src/google/protobuf/reflection.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ class MutableRepeatedFieldRef;
5858

5959
// RepeatedFieldRef definition for non-message types.
6060
template <typename T>
61-
class RepeatedFieldRef<
62-
T, typename std::enable_if<!std::is_base_of<Message, T>::value>::type> {
61+
class RepeatedFieldRef<T, std::enable_if_t<!std::is_base_of_v<Message, T>>> {
6362
typedef typename internal::RefTypeTraits<T>::iterator IteratorType;
6463
typedef typename internal::RefTypeTraits<T>::AccessorType AccessorType;
6564

@@ -106,7 +105,7 @@ class RepeatedFieldRef<
106105
// MutableRepeatedFieldRef definition for non-message types.
107106
template <typename T>
108107
class MutableRepeatedFieldRef<
109-
T, typename std::enable_if<!std::is_base_of<Message, T>::value>::type> {
108+
T, std::enable_if_t<!std::is_base_of_v<Message, T>>> {
110109
typedef typename internal::RefTypeTraits<T>::AccessorType AccessorType;
111110

112111
public:
@@ -169,8 +168,7 @@ class MutableRepeatedFieldRef<
169168

170169
// RepeatedFieldRef definition for message types.
171170
template <typename T>
172-
class RepeatedFieldRef<
173-
T, typename std::enable_if<std::is_base_of<Message, T>::value>::type> {
171+
class RepeatedFieldRef<T, std::enable_if_t<std::is_base_of_v<Message, T>>> {
174172
typedef typename internal::RefTypeTraits<T>::iterator IteratorType;
175173
typedef typename internal::RefTypeTraits<T>::AccessorType AccessorType;
176174

@@ -234,8 +232,8 @@ class RepeatedFieldRef<
234232

235233
// MutableRepeatedFieldRef definition for message types.
236234
template <typename T>
237-
class MutableRepeatedFieldRef<
238-
T, typename std::enable_if<std::is_base_of<Message, T>::value>::type> {
235+
class MutableRepeatedFieldRef<T,
236+
std::enable_if_t<std::is_base_of_v<Message, T>>> {
239237
typedef typename internal::RefTypeTraits<T>::AccessorType AccessorType;
240238

241239
public:
@@ -551,8 +549,7 @@ DEFINE_PRIMITIVE(BOOL, bool)
551549
#undef DEFINE_PRIMITIVE
552550

553551
template <typename T>
554-
struct RefTypeTraits<
555-
T, typename std::enable_if<PrimitiveTraits<T>::is_primitive>::type> {
552+
struct RefTypeTraits<T, std::enable_if_t<PrimitiveTraits<T>::is_primitive>> {
556553
typedef RepeatedFieldRefIterator<T> iterator;
557554
typedef RepeatedFieldAccessor AccessorType;
558555
typedef T AccessorValueType;
@@ -582,8 +579,7 @@ struct RefTypeTraits<
582579
};
583580

584581
template <typename T>
585-
struct RefTypeTraits<
586-
T, typename std::enable_if<std::is_same<std::string, T>::value>::type> {
582+
struct RefTypeTraits<T, std::enable_if_t<std::is_same_v<std::string, T>>> {
587583
typedef RepeatedFieldRefIterator<T> iterator;
588584
typedef RepeatedFieldAccessor AccessorType;
589585
typedef std::string AccessorValueType;
@@ -608,8 +604,7 @@ struct MessageDescriptorGetter<Message> {
608604
};
609605

610606
template <typename T>
611-
struct RefTypeTraits<
612-
T, typename std::enable_if<std::is_base_of<Message, T>::value>::type> {
607+
struct RefTypeTraits<T, std::enable_if_t<std::is_base_of_v<Message, T>>> {
613608
typedef RepeatedFieldRefIterator<T> iterator;
614609
typedef RepeatedFieldAccessor AccessorType;
615610
typedef Message AccessorValueType;

src/google/protobuf/reflection_visit_field_info.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ class iterator_range {
5757
// Users who need to know the "size" of a non-random-access iterator_range
5858
// should pass the range to `absl::c_distance()` instead.
5959
template <class It = IteratorT>
60-
typename std::enable_if<std::is_base_of<std::random_access_iterator_tag,
61-
typename std::iterator_traits<
62-
It>::iterator_category>::value,
63-
size_t>::type
60+
std::enable_if_t<
61+
std::is_base_of_v<std::random_access_iterator_tag,
62+
typename std::iterator_traits<It>::iterator_category>,
63+
size_t>
6464
size() const {
6565
return std::distance(begin_iterator_, end_iterator_);
6666
}

src/google/protobuf/repeated_field.h

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,21 @@ class ABSL_ATTRIBUTE_WARN_UNUSED PROTOBUF_DECLSPEC_EMPTY_BASES
301301
static_assert(
302302
alignof(Arena) >= alignof(Element),
303303
"We only support types that have an alignment smaller than Arena");
304-
static_assert(!std::is_const<Element>::value,
304+
static_assert(!std::is_const_v<Element>,
305305
"We do not support const value types.");
306-
static_assert(!std::is_volatile<Element>::value,
306+
static_assert(!std::is_volatile_v<Element>,
307307
"We do not support volatile value types.");
308-
static_assert(!std::is_pointer<Element>::value,
308+
static_assert(!std::is_pointer_v<Element>,
309309
"We do not support pointer value types.");
310-
static_assert(!std::is_reference<Element>::value,
310+
static_assert(!std::is_reference_v<Element>,
311311
"We do not support reference value types.");
312312
static constexpr PROTOBUF_ALWAYS_INLINE void StaticValidityCheck() {
313313
static_assert(
314-
std::disjunction<internal::is_supported_integral_type<Element>,
315-
internal::is_supported_floating_point_type<Element>,
316-
std::is_same<absl::Cord, Element>,
317-
std::is_same<UnknownField, Element>,
318-
is_proto_enum<Element>>::value,
314+
std::disjunction_v<internal::is_supported_integral_type<Element>,
315+
internal::is_supported_floating_point_type<Element>,
316+
std::is_same<absl::Cord, Element>,
317+
std::is_same<UnknownField, Element>,
318+
is_proto_enum<Element>>,
319319
"We only support non-string scalars in RepeatedField.");
320320
}
321321

@@ -337,9 +337,8 @@ class ABSL_ATTRIBUTE_WARN_UNUSED PROTOBUF_DECLSPEC_EMPTY_BASES
337337
: RepeatedField(internal::InternalMetadataOffset(), /*arena=*/nullptr,
338338
rhs) {}
339339

340-
template <typename Iter,
341-
typename = typename std::enable_if<std::is_constructible<
342-
Element, decltype(*std::declval<Iter>())>::value>::type>
340+
template <typename Iter, typename = std::enable_if_t<std::is_constructible_v<
341+
Element, decltype(*std::declval<Iter>())>>>
343342
RepeatedField(Iter begin, Iter end);
344343

345344
// Arena enabled constructors: for internal use only.
@@ -649,7 +648,7 @@ class ABSL_ATTRIBUTE_WARN_UNUSED PROTOBUF_DECLSPEC_EMPTY_BASES
649648
// This function does nothing if `Element` is trivial.
650649
static void Destroy([[maybe_unused]] const Element* begin,
651650
[[maybe_unused]] const Element* end) {
652-
if constexpr (!std::is_trivially_destructible<Element>::value) {
651+
if constexpr (!std::is_trivially_destructible_v<Element>) {
653652
std::for_each(begin, end, [&](const Element& e) { e.~Element(); });
654653
}
655654
}
@@ -1192,9 +1191,9 @@ template <typename Element>
11921191
template <typename ArenaProvider, typename Iter>
11931192
inline void RepeatedField<Element>::AddWithArena(ArenaProvider arena_provider,
11941193
Iter begin, Iter end) {
1195-
if (std::is_base_of<
1194+
if (std::is_base_of_v<
11961195
std::forward_iterator_tag,
1197-
typename std::iterator_traits<Iter>::iterator_category>::value) {
1196+
typename std::iterator_traits<Iter>::iterator_category>) {
11981197
AddForwardIterator(arena_provider, begin, end);
11991198
} else {
12001199
AddInputIterator(arena_provider, begin, end);
@@ -1589,7 +1588,7 @@ PROTOBUF_NOINLINE void RepeatedField<Element>::GrowNoAnnotate(
15891588
if (old_size > 0) {
15901589
Element* pnew = new_rep->elements<Element>();
15911590
Element* pold = elements(was_soo);
1592-
if constexpr (std::is_trivially_copyable<Element>::value ||
1591+
if constexpr (std::is_trivially_copyable_v<Element> ||
15931592
absl::is_trivially_relocatable<Element>::value) {
15941593
memcpy(static_cast<void*>(pnew), pold, old_size * sizeof(Element));
15951594
} else {
@@ -1657,8 +1656,7 @@ namespace internal {
16571656
template <typename Element>
16581657
class RepeatedIterator {
16591658
private:
1660-
using traits =
1661-
std::iterator_traits<typename std::remove_const<Element>::type*>;
1659+
using traits = std::iterator_traits<std::remove_const_t<Element>*>;
16621660

16631661
public:
16641662
// Note: value_type is never cv-qualified.

0 commit comments

Comments
 (0)