Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using std::iterator (deprecated in C++17). #8741

Merged
merged 1 commit into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/google/protobuf/reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,18 @@ class PROTOBUF_EXPORT RepeatedFieldAccessor {

// Implement (Mutable)RepeatedFieldRef::iterator
template <typename T>
class RepeatedFieldRefIterator
: public std::iterator<std::forward_iterator_tag, T> {
class RepeatedFieldRefIterator {
typedef typename RefTypeTraits<T>::AccessorValueType AccessorValueType;
typedef typename RefTypeTraits<T>::IteratorValueType IteratorValueType;
typedef typename RefTypeTraits<T>::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)
Expand Down
36 changes: 28 additions & 8 deletions src/google/protobuf/repeated_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -2740,9 +2740,14 @@ RepeatedPtrField<Element>::pointer_end() const {
namespace internal {
// A back inserter for RepeatedField objects.
template <typename T>
class RepeatedFieldBackInsertIterator
: public std::iterator<std::output_iterator_tag, T> {
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<T>* const mutable_field)
: field_(mutable_field) {}
Expand All @@ -2762,9 +2767,14 @@ class RepeatedFieldBackInsertIterator

// A back inserter for RepeatedPtrField objects.
template <typename T>
class RepeatedPtrFieldBackInsertIterator
: public std::iterator<std::output_iterator_tag, T> {
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<T>* const mutable_field)
: field_(mutable_field) {}
RepeatedPtrFieldBackInsertIterator<T>& operator=(const T& value) {
Expand Down Expand Up @@ -2793,9 +2803,14 @@ class RepeatedPtrFieldBackInsertIterator
// A back inserter for RepeatedPtrFields that inserts by transferring ownership
// of a pointer.
template <typename T>
class AllocatedRepeatedPtrFieldBackInsertIterator
: public std::iterator<std::output_iterator_tag, T> {
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<T>* const mutable_field)
: field_(mutable_field) {}
Expand All @@ -2817,9 +2832,14 @@ class AllocatedRepeatedPtrFieldBackInsertIterator
// Almost identical to AllocatedRepeatedPtrFieldBackInsertIterator. This one
// uses the UnsafeArenaAddAllocated instead.
template <typename T>
class UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator
: public std::iterator<std::output_iterator_tag, T> {
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<T>* const mutable_field)
: field_(mutable_field) {}
Expand Down