Skip to content
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
13 changes: 12 additions & 1 deletion ortools/base/proto_enum_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,19 @@ namespace internal {
template <typename E>
class RepeatedEnumView {
public:
class Iterator : public std::iterator<std::input_iterator_tag, E> {
class Iterator
#if __cplusplus < 201703L
: public std::iterator<std::input_iterator_tag, E>
#endif
{
public:
using difference_type = ptrdiff_t;
using value_type = E;
#if __cplusplus >= 201703L
using iterator_category = std::input_iterator_tag;
using pointer = E*;
using reference = E&;
#endif
explicit Iterator(RepeatedField<int>::const_iterator ptr) : ptr_(ptr) {}
bool operator==(const Iterator& it) const { return ptr_ == it.ptr_; }
bool operator!=(const Iterator& it) const { return ptr_ != it.ptr_; }
Expand Down
7 changes: 6 additions & 1 deletion ortools/graph/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class BaseGraph {
template <typename Graph, typename ArcIterator, typename PropertyT,
PropertyT (Graph::*property)(typename Graph::ArcIndex) const>
class ArcPropertyIterator
#if __cplusplus < 202002L
#if __cplusplus < 201703L
: public std::iterator<std::input_iterator_tag, PropertyT>
#endif
{
Expand All @@ -324,6 +324,11 @@ class ArcPropertyIterator
// TODO(b/385094969): This should be `NodeIndex` for integers,
// `NodeIndex::value_type` for strong signed integer types.
using difference_type = std::ptrdiff_t;
#if __cplusplus >= 201703L
using iterator_category = std::input_iterator_tag;
using pointer = PropertyT*;
using reference = PropertyT&;
#endif

ArcPropertyIterator() = default;

Expand Down
14 changes: 12 additions & 2 deletions ortools/graph/iterators.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,18 @@ class IntegerRangeIterator
// TODO(b/385094969): In C++17, `std::iterator_traits<Iterator>` required
// explicitly specifying the iterator category. Remove this when backwards
// compatibility with C++17 is no longer needed.
#if __cplusplus < 202002L
#if __cplusplus < 201703L
: public std::iterator<std::input_iterator_tag, IntegerType>
#endif
{
public:
using difference_type = ptrdiff_t;
using value_type = IntegerType;
#if __cplusplus >= 201703L
using iterator_category = std::input_iterator_tag;
using pointer = IntegerType*;
using reference = IntegerType&;
#endif

IntegerRangeIterator() : index_{} {}

Expand Down Expand Up @@ -243,13 +248,18 @@ class IntegerRange : public BeginEndWrapper<IntegerRangeIterator<IntegerType>> {
// different iterators with the same index type and sentinel.
template <typename IndexT, const IndexT& sentinel, typename Tag>
class ChasingIterator
#if __cplusplus < 202002L
#if __cplusplus < 201703L
: public std::iterator<std::input_iterator_tag, IndexT>
#endif
{
public:
using difference_type = ptrdiff_t;
using value_type = IndexT;
#if __cplusplus >= 201703L
using iterator_category = std::input_iterator_tag;
using pointer = IndexT*;
using reference = IndexT&;
#endif

ChasingIterator() : index_(sentinel), next_(nullptr) {}

Expand Down