24 Ranges library [ranges]

24.6 Range factories [range.factories]

24.6.4 Iota view [range.iota]

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

namespace std::ranges { template<weakly_­incrementable W, semiregular Bound> requires weakly-equality-comparable-with<W, Bound> struct iota_view<W, Bound>::iterator { private: W value_ = W(); // exposition only public: using iterator_concept = see below; using iterator_category = input_iterator_tag; using value_type = W; using difference_type = IOTA-DIFF-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 equality_comparable<W>; friend constexpr bool operator<(const iterator& x, const iterator& y) requires totally_­ordered<W>; friend constexpr bool operator>(const iterator& x, const iterator& y) requires totally_­ordered<W>; friend constexpr bool operator<=(const iterator& x, const iterator& y) requires totally_­ordered<W>; friend constexpr bool operator>=(const iterator& x, const iterator& y) requires totally_­ordered<W>; friend constexpr auto operator<=>(const iterator& x, const iterator& y) requires totally_­ordered<W> && three_­way_­comparable<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_­concept is defined as follows:
  • If W models advanceable, then iterator_­concept is random_­access_­iterator_­tag.
  • Otherwise, if W models decrementable, then iterator_­concept is bidirectional_­iterator_­tag.
  • Otherwise, if W models incrementable, then iterator_­concept is forward_­iterator_­tag.
  • Otherwise, iterator_­concept is input_­iterator_­tag.
[Note 1:
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 2:
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: if constexpr (is-integer-like<W> && !is-signed-integer-like<W>) { if (n >= difference_type(0)) value_ += static_cast<W>(n); else value_ -= static_cast<W>(-n); } else { value_ += n; } return *this;
constexpr iterator& operator-=(difference_type n) requires advanceable<W>;
Effects: Equivalent to: if constexpr (is-integer-like<W> && !is-signed-integer-like<W>) { if (n >= difference_type(0)) value_ -= static_cast<W>(n); else value_ += static_cast<W>(-n); } else { value_ -= n; } return *this;
constexpr W operator[](difference_type n) const requires advanceable<W>;
Effects: Equivalent to: return W(value_­ + n);
friend constexpr bool operator==(const iterator& x, const iterator& y) requires equality_comparable<W>;
Effects: Equivalent to: return x.value_­ == y.value_­;
friend constexpr bool operator<(const iterator& x, const iterator& y) requires totally_­ordered<W>;
Effects: Equivalent to: return x.value_­ < y.value_­;
friend constexpr bool operator>(const iterator& x, const iterator& y) requires totally_­ordered<W>;
Effects: Equivalent to: return y < x;
friend constexpr bool operator<=(const iterator& x, const iterator& y) requires totally_­ordered<W>;
Effects: Equivalent to: return !(y < x);
friend constexpr bool operator>=(const iterator& x, const iterator& y) requires totally_­ordered<W>;
Effects: Equivalent to: return !(x < y);
friend constexpr auto operator<=>(const iterator& x, const iterator& y) requires totally_­ordered<W> && three_­way_­comparable<W>;
Effects: Equivalent to: return x.value_­ <=> y.value_­;
friend constexpr iterator operator+(iterator i, difference_type n) requires advanceable<W>;
Effects: Equivalent to: return i += 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: using D = difference_type; if constexpr (is-integer-like<W>) { if constexpr (is-signed-integer-like<W>) return D(D(x.value_) - D(y.value_)); else return (y.value_ > x.value_) ? D(-D(y.value_ - x.value_)) : D(x.value_ - y.value_); } else { return x.value_ - y.value_; }