diff --git a/src/google/protobuf/reflection.h b/src/google/protobuf/reflection.h index af8eb00ef..bb41fbaeb 100644 --- a/src/google/protobuf/reflection.h +++ b/src/google/protobuf/reflection.h @@ -392,13 +392,18 @@ class PROTOBUF_EXPORT RepeatedFieldAccessor { // Implement (Mutable)RepeatedFieldRef::iterator template -class RepeatedFieldRefIterator - : public std::iterator { +class RepeatedFieldRefIterator { typedef typename RefTypeTraits::AccessorValueType AccessorValueType; typedef typename RefTypeTraits::IteratorValueType IteratorValueType; typedef typename RefTypeTraits::IteratorPointerType IteratorPointerType; public: + using iterator_category = std::forward_iterator_tag; + using value_type = T; + using pointer = T*; + using reference = T&; + using difference_type = std::ptrdiff_t; + // Constructor for non-message fields. RepeatedFieldRefIterator(const void* data, const RepeatedFieldAccessor* accessor, bool begin) diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 3e3f601d7..c8fe9333d 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -2740,9 +2740,14 @@ RepeatedPtrField::pointer_end() const { namespace internal { // A back inserter for RepeatedField objects. template -class RepeatedFieldBackInsertIterator - : public std::iterator { +class RepeatedFieldBackInsertIterator { public: + using iterator_category = std::output_iterator_tag; + using value_type = T; + using pointer = void; + using reference = void; + using difference_type = std::ptrdiff_t; + explicit RepeatedFieldBackInsertIterator( RepeatedField* const mutable_field) : field_(mutable_field) {} @@ -2762,9 +2767,14 @@ class RepeatedFieldBackInsertIterator // A back inserter for RepeatedPtrField objects. template -class RepeatedPtrFieldBackInsertIterator - : public std::iterator { +class RepeatedPtrFieldBackInsertIterator { public: + using iterator_category = std::output_iterator_tag; + using value_type = T; + using pointer = void; + using reference = void; + using difference_type = std::ptrdiff_t; + RepeatedPtrFieldBackInsertIterator(RepeatedPtrField* const mutable_field) : field_(mutable_field) {} RepeatedPtrFieldBackInsertIterator& operator=(const T& value) { @@ -2793,9 +2803,14 @@ class RepeatedPtrFieldBackInsertIterator // A back inserter for RepeatedPtrFields that inserts by transferring ownership // of a pointer. template -class AllocatedRepeatedPtrFieldBackInsertIterator - : public std::iterator { +class AllocatedRepeatedPtrFieldBackInsertIterator { public: + using iterator_category = std::output_iterator_tag; + using value_type = T; + using pointer = void; + using reference = void; + using difference_type = std::ptrdiff_t; + explicit AllocatedRepeatedPtrFieldBackInsertIterator( RepeatedPtrField* const mutable_field) : field_(mutable_field) {} @@ -2817,9 +2832,14 @@ class AllocatedRepeatedPtrFieldBackInsertIterator // Almost identical to AllocatedRepeatedPtrFieldBackInsertIterator. This one // uses the UnsafeArenaAddAllocated instead. template -class UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator - : public std::iterator { +class UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator { public: + using iterator_category = std::output_iterator_tag; + using value_type = T; + using pointer = void; + using reference = void; + using difference_type = std::ptrdiff_t; + explicit UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator( RepeatedPtrField* const mutable_field) : field_(mutable_field) {}