Implement unambiguous comparisons for RepeatedPtrIterator in C++20 (#9139)

pull/9195/head
Kent Ross 3 years ago committed by GitHub
parent 7ccf4d8f67
commit d88c8d5d4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/google/protobuf/repeated_ptr_field.h

@ -1617,6 +1617,8 @@ class RepeatedPtrIterator {
using iterator = RepeatedPtrIterator<Element>; using iterator = RepeatedPtrIterator<Element>;
using iterator_category = std::random_access_iterator_tag; using iterator_category = std::random_access_iterator_tag;
using value_type = typename std::remove_const<Element>::type; using value_type = typename std::remove_const<Element>::type;
using const_iterator = RepeatedPtrIterator<const value_type>;
using nonconst_iterator = RepeatedPtrIterator<value_type>;
using difference_type = std::ptrdiff_t; using difference_type = std::ptrdiff_t;
using pointer = Element*; using pointer = Element*;
using reference = Element&; using reference = Element&;
@ -1652,14 +1654,20 @@ class RepeatedPtrIterator {
iterator operator--(int) { return iterator(it_--); } iterator operator--(int) { return iterator(it_--); }
// equality_comparable // equality_comparable
bool operator==(const iterator& x) const { return it_ == x.it_; } bool operator==(const nonconst_iterator& x) const { return it_ == x.it_; }
bool operator!=(const iterator& x) const { return it_ != x.it_; } bool operator==(const const_iterator& x) const { return it_ == x.it_; }
bool operator!=(const nonconst_iterator& x) const { return it_ != x.it_; }
bool operator!=(const const_iterator& x) const { return it_ != x.it_; }
// less_than_comparable // less_than_comparable
bool operator<(const iterator& x) const { return it_ < x.it_; } bool operator<(const nonconst_iterator& x) const { return it_ < x.it_; }
bool operator<=(const iterator& x) const { return it_ <= x.it_; } bool operator<(const const_iterator& x) const { return it_ < x.it_; }
bool operator>(const iterator& x) const { return it_ > x.it_; } bool operator<=(const nonconst_iterator& x) const { return it_ <= x.it_; }
bool operator>=(const iterator& x) const { return it_ >= x.it_; } bool operator<=(const const_iterator& x) const { return it_ <= x.it_; }
bool operator>(const nonconst_iterator& x) const { return it_ > x.it_; }
bool operator>(const const_iterator& x) const { return it_ > x.it_; }
bool operator>=(const nonconst_iterator& x) const { return it_ >= x.it_; }
bool operator>=(const const_iterator& x) const { return it_ >= x.it_; }
// addable, subtractable // addable, subtractable
iterator& operator+=(difference_type d) { iterator& operator+=(difference_type d) {

Loading…
Cancel
Save