24 Ranges library [ranges]

24.6 Range factories [range.factories]

24.6.3 Iota view [range.iota]

24.6.3.3 Class iota_­view​::​iterator [range.iota.iterator]

namespace std::ranges {
  template<class W, class Bound>
  struct iota_view<W, Bound>::iterator {
  private:
    W value_ = W();             // exposition only
  public:
    using iterator_category = see below;
    using value_type = W;
    using difference_type = iter_difference_t<W>;

    iterator() = default;
    constexpr explicit iterator(W value);

    constexpr W operator*() const noexcept(is_nothrow_copy_constructible_v<W>);

    constexpr iterator& operator++();
    constexpr void operator++(int);
    constexpr iterator operator++(int) requires Incrementable<W>;

    constexpr iterator& operator--() requires Decrementable<W>;
    constexpr iterator operator--(int) requires Decrementable<W>;

    constexpr iterator& operator+=(difference_type n)
      requires Advanceable<W>;
    constexpr iterator& operator-=(difference_type n)
      requires Advanceable<W>;
    constexpr W operator[](difference_type n) const
      requires Advanceable<W>;

    friend constexpr bool operator==(const iterator& x, const iterator& y)
      requires EqualityComparable<W>;
    friend constexpr bool operator!=(const iterator& x, const iterator& y)
      requires EqualityComparable<W>;

    friend constexpr bool operator<(const iterator& x, const iterator& y)
      requires StrictTotallyOrdered<W>;
    friend constexpr bool operator>(const iterator& x, const iterator& y)
      requires StrictTotallyOrdered<W>;
    friend constexpr bool operator<=(const iterator& x, const iterator& y)
      requires StrictTotallyOrdered<W>;
    friend constexpr bool operator>=(const iterator& x, const iterator& y)
      requires StrictTotallyOrdered<W>;

    friend constexpr iterator operator+(iterator i, difference_type n)
      requires Advanceable<W>;
    friend constexpr iterator operator+(difference_type n, iterator i)
      requires Advanceable<W>;

    friend constexpr iterator operator-(iterator i, difference_type n)
      requires Advanceable<W>;
    friend constexpr difference_type operator-(const iterator& x, const iterator& y)
      requires Advanceable<W>;
  };
}
iterator::iterator_­category is defined as follows:
  • If W models Advanceable, then iterator_­category is random_­access_­iterator_­tag.
  • Otherwise, if W models Decrementable, then iterator_­category is bidirectional_­iterator_­tag.
  • Otherwise, if W models Incrementable, then iterator_­category is forward_­iterator_­tag.
  • Otherwise, iterator_­category is input_­iterator_­tag.
[Note
:
Overloads for iter_­move and iter_­swap are omitted intentionally.
end note
]
constexpr explicit iterator(W value);
Effects: Initializes value_­ with value.
constexpr W operator*() const noexcept(is_nothrow_copy_constructible_v<W>);
Effects: Equivalent to: return value_­;
[Note
:
The noexcept clause is needed by the default iter_­move implementation.
end note
]
constexpr iterator& operator++();
Effects: Equivalent to:
++value_;
return *this;
constexpr void operator++(int);
Effects: Equivalent to ++*this.
constexpr iterator operator++(int) requires Incrementable<W>;
Effects: Equivalent to:
auto tmp = *this;
++*this;
return tmp;
constexpr iterator& operator--() requires Decrementable<W>;
Effects: Equivalent to:
--value_;
return *this;
constexpr iterator operator--(int) requires Decrementable<W>;
Effects: Equivalent to:
auto tmp = *this;
--*this;
return tmp;
constexpr iterator& operator+=(difference_type n) requires Advanceable<W>;
Effects: Equivalent to:
value_ += n;
return *this;
constexpr iterator& operator-=(difference_type n) requires Advanceable<W>;
Effects: Equivalent to:
value_ -= n;
return *this;
constexpr W operator[](difference_type n) const requires Advanceable<W>;
Effects: Equivalent to: return value_­ + n;
friend constexpr bool operator==(const iterator& x, const iterator& y) requires EqualityComparable<W>;
Effects: Equivalent to: return x.value_­ == y.value_­;
friend constexpr bool operator!=(const iterator& x, const iterator& y) requires EqualityComparable<W>;
Effects: Equivalent to: return !(x == y);
friend constexpr bool operator<(const iterator& x, const iterator& y) requires StrictTotallyOrdered<W>;
Effects: Equivalent to: return x.value_­ < y.value_­;
friend constexpr bool operator>(const iterator& x, const iterator& y) requires StrictTotallyOrdered<W>;
Effects: Equivalent to: return y < x;
friend constexpr bool operator<=(const iterator& x, const iterator& y) requires StrictTotallyOrdered<W>;
Effects: Equivalent to: return !(y < x);
friend constexpr bool operator>=(const iterator& x, const iterator& y) requires StrictTotallyOrdered<W>;
Effects: Equivalent to: return !(x < y);
friend constexpr iterator operator+(iterator i, difference_type n) requires Advanceable<W>;
Effects: Equivalent to: return iterator{i.value_­ + n};
friend constexpr iterator operator+(difference_type n, iterator i) requires Advanceable<W>;
Effects: Equivalent to: return i + n;
friend constexpr iterator operator-(iterator i, difference_type n) requires Advanceable<W>;
Effects: Equivalent to: return i + -n;
friend constexpr difference_type operator-(const iterator& x, const iterator& y) requires Advanceable<W>;
Effects: Equivalent to: return x.value_­ - y.value_­;