[range.iota]

# 25 Ranges library [[ranges]](./#ranges)

## 25.6 Range factories [[range.factories]](range.factories#range.iota)

### 25.6.4 Iota view [range.iota]

#### [25.6.4.1](#overview) Overview [[range.iota.overview]](range.iota.overview)

[1](#overview-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2778)

iota_view generates a
sequence of elements by repeatedly incrementing an initial value[.](#overview-1.sentence-1)

[2](#overview-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2782)

The name views​::​iota denotes a
customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#overview-2.sentence-1)

Given subexpressions E and F, the expressionsviews​::​iota(E) and views​::​iota(E, F) are expression-equivalent toiota_view<decay_t<decltype((E))>>(E) and iota_view(E, F),
respectively[.](#overview-2.sentence-2)

[3](#overview-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2792)

[*Example [1](#overview-example-1)*: for (int i : views::iota(1, 10)) cout << i << ' '; // prints 1 2 3 4 5 6 7 8 9 â *end example*]

[4](#overview-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2800)

The name views​::​indices denotes a
customization point object ([[customization.point.object]](customization.point.object "16.3.3.3.5 Customization Point Object types"))[.](#overview-4.sentence-1)

Given subexpression E,
let T be remove_cvref_t<decltype((E))>[.](#overview-4.sentence-2)

views​::​indices(E) is expression-equivalent toviews​::​iota(T(0), E) if *is-integer-like*<T> is true,
and ill-formed otherwise[.](#overview-4.sentence-3)

#### [25.6.4.2](#view) Class template iota_view [[range.iota.view]](range.iota.view)

[ð](#lib:iota_view)

namespace std::ranges {template<class I>concept [*decrementable*](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]") = *see below*; // *exposition only*template<class I>concept [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]") = *see below*; // *exposition only*template<[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_­incrementable [iterator.concept.winc]") W, [semiregular](concepts.object#concept:semiregular "18.6 Object concepts [concepts.object]") Bound = unreachable_sentinel_t>requires [*weakly-equality-comparable-with*](concept.equalitycomparable#concept:weakly-equality-comparable-with "18.5.4 Concept equality_­comparable [concept.equalitycomparable]")<W, Bound> && [copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]")<W>class iota_view : public view_interface<iota_view<W, Bound>> {private:// [[range.iota.iterator]](#iterator "25.6.4.3 Class iota_­view​::​iterator"), class iota_view​::​*iterator*struct *iterator*; // *exposition only*// [[range.iota.sentinel]](#sentinel "25.6.4.4 Class iota_­view​::​sentinel"), class iota_view​::​*sentinel*struct *sentinel*; // *exposition only* W *value_* = W(); // *exposition only* Bound *bound_* = Bound(); // *exposition only*public: iota_view() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<W> = default; constexpr explicit iota_view(W value); constexpr explicit iota_view(type_identity_t<W> value, type_identity_t<Bound> bound); constexpr explicit iota_view(*iterator* first, *see below* last); constexpr *iterator* begin() const; constexpr auto end() const; constexpr *iterator* end() const requires [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<W, Bound>; constexpr bool empty() const; constexpr auto size() const requires *see below*; }; template<class W, class Bound>requires (!*is-integer-like*<W> || !*is-integer-like*<Bound> ||(*is-signed-integer-like*<W> == *is-signed-integer-like*<Bound>)) iota_view(W, Bound) -> iota_view<W, Bound>;}

[1](#view-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2856)

Let *IOTA-DIFF-T*(W) be defined as follows:

- [(1.1)](#view-1.1)

  If W is not an integral type, or
 if it is an integral type and sizeof(iter_difference_t<W>) is greater than sizeof(W),
 then *IOTA-DIFF-T*(W) denotes iter_difference_t<W>[.](#view-1.1.sentence-1)

- [(1.2)](#view-1.2)

  Otherwise, *IOTA-DIFF-T*(W) is a signed integer type of width greater than the width of W if such a type exists[.](#view-1.2.sentence-1)

- [(1.3)](#view-1.3)

  Otherwise, *IOTA-DIFF-T*(W) is an unspecified signed-integer-like type ([[iterator.concept.winc]](iterator.concept.winc "24.3.4.4 Concept weakly_­incrementable"))
 of width not less than the width of W[.](#view-1.3.sentence-1)
  [*Note [1](#view-note-1)*:
  It is unspecified
 whether this type satisfies [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_­incrementable [iterator.concept.winc]")[.](#view-1.3.sentence-2)
 â *end note*]

[2](#view-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2878)

The exposition-only [*decrementable*](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]") concept is equivalent to:

[ð](#concept:decrementable)

`template<class I>
  concept [decrementable](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]") =               // exposition only
    [incrementable](iterator.concept.inc#concept:incrementable "24.3.4.5 Concept incrementable [iterator.concept.inc]")<I> && requires(I i) {
      { --i } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<I&>;
      { i-- } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<I>;
    };
`

[3](#view-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2890)

When an object is in the domain of both pre- and post-decrement,
the object is said to be [*decrementable*](#def:decrementable)[.](#view-3.sentence-1)

[4](#view-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2894)

Let a and b be equal objects of type I[.](#view-4.sentence-1)

I models [*decrementable*](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]") only if

- [(4.1)](#view-4.1)

  If a and b are decrementable,
 then the following are all true:
  * [(4.1.1)](#view-4.1.1)

addressof(--a) == addressof(a)

  * [(4.1.2)](#view-4.1.2)

bool(a-- == b)

  * [(4.1.3)](#view-4.1.3)

bool(((void)a--, a) == --b)

  * [(4.1.4)](#view-4.1.4)

bool(++(--a) == b)[.](#view-4.1.sentence-1)

- [(4.2)](#view-4.2)

  If a and b are incrementable,
 then bool(--(++a) == b)[.](#view-4.2.sentence-1)

[5](#view-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2911)

The exposition-only [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]") concept is equivalent to:

[ð](#concept:advanceable)

`template<class I>
  concept [advanceable](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]") =                 // exposition only
    [decrementable](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]")<I> && [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<I> &&
    requires(I i, const I j, const IOTA-DIFF-T(I) n) {
      { i += n } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<I&>;
      { i -= n } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<I&>;
      I(j + n);
      I(n + j);
      I(j - n);
      { j - j } -> [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<IOTA-DIFF-T(I)>;
    };
`

Let D be *IOTA-DIFF-T*(I)[.](#view-sentence-1)

Let a and b be objects of type I such thatb is reachable from a after n applications of ++a,
for some value n of type D[.](#view-sentence-2)

I models [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]") only if

- (a += n) is equal to b[.](#view-sentence-1)

- addressof(a += n) is equal to addressof(a)[.](#view-sentence-1)

- I(a + n) is equal to (a += n)[.](#view-sentence-1)

- For any two positive values x and y of type D,
 if I(a + D(x + y)) is well-defined, then I(a + D(x + y)) is equal to I(I(a + x) + y)[.](#view-sentence-1)

- I(a + D(0)) is equal to a[.](#view-sentence-1)

- If I(a + D(n - 1)) is well-defined, then I(a + n) is equal to [](I c) { return ++c; }(I(a + D(n - 1)))[.](#view-sentence-1)

- (b += -n) is equal to a[.](#view-sentence-1)

- (b -= n) is equal to a[.](#view-sentence-1)

- addressof(b -= n) is equal to addressof(b)[.](#view-sentence-1)

- I(b - n) is equal to (b -= n)[.](#view-sentence-1)

- D(b - a) is equal to n[.](#view-sentence-1)

- D(a - b) is equal to D(-n)[.](#view-sentence-1)

- bool(a <= b) is true[.](#view-sentence-1)

[ð](#lib:iota_view,constructor)

`constexpr explicit iota_view(W value);
`

[6](#view-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2959)

*Preconditions*: Bound denotes unreachable_sentinel_t orBound() is reachable from value[.](#view-6.sentence-1)

When W and Bound model [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"),
then bool(value <= Bound()) is true[.](#view-6.sentence-2)

[7](#view-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2966)

*Effects*: Initializes *value_* with value[.](#view-7.sentence-1)

[ð](#lib:iota_view,constructor_)

`constexpr explicit iota_view(type_identity_t<W> value, type_identity_t<Bound> bound);
`

[8](#view-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2977)

*Preconditions*: Bound denotes unreachable_sentinel_t orbound is reachable from value[.](#view-8.sentence-1)

When W and Bound model [totally_ordered_with](concept.totallyordered#concept:totally_ordered_with "18.5.5 Concept totally_­ordered [concept.totallyordered]"),
then bool(value <= bound) is true[.](#view-8.sentence-2)

[9](#view-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2984)

*Effects*: Initializes *value_* with value and*bound_* with bound[.](#view-9.sentence-1)

[ð](#lib:iota_view,constructor__)

`constexpr explicit iota_view(iterator first, see below last);
`

[10](#view-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L2996)

*Effects*: Equivalent to:

- [(10.1)](#view-10.1)

  If [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<W, Bound> is true,iota_view(first.*value_*, last.*value_*)[.](#view-10.1.sentence-1)

- [(10.2)](#view-10.2)

  Otherwise, if Bound denotes unreachable_sentinel_t,iota_view(first.*value_*, last)[.](#view-10.2.sentence-1)

- [(10.3)](#view-10.3)

  Otherwise, iota_view(first.*value_*, last.*bound_*)[.](#view-10.3.sentence-1)

[11](#view-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3010)

*Remarks*: The type of last is:

- [(11.1)](#view-11.1)

  If [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<W, Bound> is true, *iterator*[.](#view-11.1.sentence-1)

- [(11.2)](#view-11.2)

  Otherwise, if Bound denotes unreachable_sentinel_t,Bound[.](#view-11.2.sentence-1)

- [(11.3)](#view-11.3)

  Otherwise, *sentinel*[.](#view-11.3.sentence-1)

[ð](#lib:begin,iota_view)

`constexpr iterator begin() const;
`

[12](#view-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3030)

*Effects*: Equivalent to: return *iterator*{*value_*};

[ð](#lib:end,iota_view)

`constexpr auto end() const;
`

[13](#view-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3041)

*Effects*: Equivalent to:if constexpr ([same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<Bound, unreachable_sentinel_t>)return unreachable_sentinel;elsereturn *sentinel*{*bound_*};

[ð](#lib:end,iota_view_)

`constexpr iterator end() const requires [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<W, Bound>;
`

[14](#view-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3058)

*Effects*: Equivalent to: return *iterator*{*bound_*};

[ð](#lib:empty,iota_view)

`constexpr bool empty() const;
`

[15](#view-15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3069)

*Effects*: Equivalent to: return *value_* == *bound_*;

[ð](#lib:size,iota_view)

`constexpr auto size() const requires see below;
`

[16](#view-16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3080)

*Effects*: Equivalent to:if constexpr (*is-integer-like*<W> && *is-integer-like*<Bound>)return (*value_* < 0)? ((*bound_* < 0)? *to-unsigned-like*(-*value_*) - *to-unsigned-like*(-*bound_*): *to-unsigned-like*(*bound_*) + *to-unsigned-like*(-*value_*)): *to-unsigned-like*(*bound_*) - *to-unsigned-like*(*value_*);elsereturn *to-unsigned-like*(*bound_* - *value_*);

[17](#view-17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3094)

*Remarks*: The expression in the [*requires-clause*](temp.pre#nt:requires-clause "13.1 Preamble [temp.pre]") is equivalent to:([same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<W, Bound> && [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>) || (*is-integer-like*<W> && *is-integer-like*<Bound>) ||[sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<Bound, W>

#### [25.6.4.3](#iterator) Class iota_view​::​*iterator* [[range.iota.iterator]](range.iota.iterator)

[ð](#lib:iota_view::iterator)

namespace std::ranges {template<[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_­incrementable [iterator.concept.winc]") W, [semiregular](concepts.object#concept:semiregular "18.6 Object concepts [concepts.object]") Bound>requires [*weakly-equality-comparable-with*](concept.equalitycomparable#concept:weakly-equality-comparable-with "18.5.4 Concept equality_­comparable [concept.equalitycomparable]")<W, Bound> && [copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]")<W>struct iota_view<W, Bound>::*iterator* {private: W *value_* = W(); // *exposition only*public:using iterator_concept = *see below*; using iterator_category = input_iterator_tag; // present only if W models [incrementable](iterator.concept.inc#concept:incrementable "24.3.4.5 Concept incrementable [iterator.concept.inc]") and// *IOTA-DIFF-T*(W) is an integral typeusing value_type = W; using difference_type = *IOTA-DIFF-T*(W); *iterator*() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<W> = 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](iterator.concept.inc#concept:incrementable "24.3.4.5 Concept incrementable [iterator.concept.inc]")<W>; constexpr *iterator*& operator--() requires [*decrementable*](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>; constexpr *iterator* operator--(int) requires [*decrementable*](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>; constexpr *iterator*& operator+=(difference_type n)requires [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>; constexpr *iterator*& operator-=(difference_type n)requires [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>; constexpr W operator[](difference_type n) constrequires [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>; friend constexpr bool operator==(const *iterator*& x, const *iterator*& y)requires [equality_comparable](concept.equalitycomparable#concept:equality_comparable "18.5.4 Concept equality_­comparable [concept.equalitycomparable]")<W>; friend constexpr bool operator<(const *iterator*& x, const *iterator*& y)requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W>; friend constexpr bool operator>(const *iterator*& x, const *iterator*& y)requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W>; friend constexpr bool operator<=(const *iterator*& x, const *iterator*& y)requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W>; friend constexpr bool operator>=(const *iterator*& x, const *iterator*& y)requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W>; friend constexpr auto operator<=>(const *iterator*& x, const *iterator*& y)requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W> && [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]")<W>; friend constexpr *iterator* operator+(*iterator* i, difference_type n)requires [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>; friend constexpr *iterator* operator+(difference_type n, *iterator* i)requires [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>; friend constexpr *iterator* operator-(*iterator* i, difference_type n)requires [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>; friend constexpr difference_type operator-(const *iterator*& x, const *iterator*& y)requires [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>; };}

[1](#iterator-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3167)

*iterator*​::​iterator_concept is defined as follows:

- [(1.1)](#iterator-1.1)

  If W models [*advanceable*](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]"), theniterator_concept is random_access_iterator_tag[.](#iterator-1.1.sentence-1)

- [(1.2)](#iterator-1.2)

  Otherwise, if W models [*decrementable*](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]"), theniterator_concept is bidirectional_iterator_tag[.](#iterator-1.2.sentence-1)

- [(1.3)](#iterator-1.3)

  Otherwise, if W models [incrementable](iterator.concept.inc#concept:incrementable "24.3.4.5 Concept incrementable [iterator.concept.inc]"), theniterator_concept is forward_iterator_tag[.](#iterator-1.3.sentence-1)

- [(1.4)](#iterator-1.4)

  Otherwise, iterator_concept is input_iterator_tag[.](#iterator-1.4.sentence-1)

[2](#iterator-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3179)

[*Note [1](#iterator-note-1)*:

Overloads for iter_move and iter_swap are omitted intentionally[.](#iterator-2.sentence-1)

â *end note*]

[ð](#lib:iota_view::iterator,constructor)

`constexpr explicit iterator(W value);
`

[3](#iterator-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3190)

*Effects*: Initializes *value_* with value[.](#iterator-3.sentence-1)

[ð](#lib:operator*,iota_view::iterator)

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

[4](#iterator-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3201)

*Effects*: Equivalent to: return *value_*;

[5](#iterator-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3205)

[*Note [2](#iterator-note-2)*:

The noexcept clause is needed by the default iter_move implementation[.](#iterator-5.sentence-1)

â *end note*]

[ð](#lib:operator++,iota_view::iterator)

`constexpr iterator& operator++();
`

[6](#iterator-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3218)

*Effects*: Equivalent to:++*value_*;return *this;

[ð](#lib:operator++,iota_view::iterator_)

`constexpr void operator++(int);
`

[7](#iterator-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3233)

*Effects*: Equivalent to ++*this[.](#iterator-7.sentence-1)

[ð](#lib:operator++,iota_view::iterator__)

`constexpr iterator operator++(int) requires [incrementable](iterator.concept.inc#concept:incrementable "24.3.4.5 Concept incrementable [iterator.concept.inc]")<W>;
`

[8](#iterator-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3244)

*Effects*: Equivalent to:auto tmp = *this;++*this;return tmp;

[ð](#lib:operator--,iota_view::iterator)

`constexpr iterator& operator--() requires [decrementable](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>;
`

[9](#iterator-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3260)

*Effects*: Equivalent to:--*value_*;return *this;

[ð](#lib:operator--,iota_view::iterator_)

`constexpr iterator operator--(int) requires [decrementable](#concept:decrementable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>;
`

[10](#iterator-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3275)

*Effects*: Equivalent to:auto tmp = *this;--*this;return tmp;

[ð](#lib:operator+=,iota_view::iterator)

`constexpr iterator& operator+=(difference_type n)
  requires [advanceable](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>;
`

[11](#iterator-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3292)

*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;

[ð](#lib:operator-=,iota_view::iterator)

`constexpr iterator& operator-=(difference_type n)
  requires [advanceable](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>;
`

[12](#iterator-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3315)

*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;

[ð](#lib:operator%5b%5d,iota_view::iterator)

`constexpr W operator[](difference_type n) const
  requires [advanceable](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>;
`

[13](#iterator-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3338)

*Effects*: Equivalent to: return W(*value_* + n);

[ð](#lib:operator==,iota_view::iterator)

`friend constexpr bool operator==(const iterator& x, const iterator& y)
  requires [equality_comparable](concept.equalitycomparable#concept:equality_comparable "18.5.4 Concept equality_­comparable [concept.equalitycomparable]")<W>;
`

[14](#iterator-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3350)

*Effects*: Equivalent to: return x.*value_* == y.*value_*;

[ð](#lib:operator%3c,iota_view::iterator)

`friend constexpr bool operator<(const iterator& x, const iterator& y)
  requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W>;
`

[15](#iterator-15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3362)

*Effects*: Equivalent to: return x.*value_* < y.*value_*;

[ð](#lib:operator%3e,iota_view::iterator)

`friend constexpr bool operator>(const iterator& x, const iterator& y)
  requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W>;
`

[16](#iterator-16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3374)

*Effects*: Equivalent to: return y < x;

[ð](#lib:operator%3c=,iota_view::iterator)

`friend constexpr bool operator<=(const iterator& x, const iterator& y)
  requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W>;
`

[17](#iterator-17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3386)

*Effects*: Equivalent to: return !(y < x);

[ð](#lib:operator%3e=,iota_view::iterator)

`friend constexpr bool operator>=(const iterator& x, const iterator& y)
  requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W>;
`

[18](#iterator-18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3398)

*Effects*: Equivalent to: return !(x < y);

[ð](#lib:operator%3c=%3e,iota_view::iterator)

`friend constexpr auto operator<=>(const iterator& x, const iterator& y)
  requires [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<W> && [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]")<W>;
`

[19](#iterator-19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3410)

*Effects*: Equivalent to: return x.*value_* <=> y.*value_*;

[ð](#lib:operator+,iota_view::iterator)

`friend constexpr iterator operator+(iterator i, difference_type n)
  requires [advanceable](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>;
`

[20](#iterator-20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3422)

*Effects*: Equivalent to:i += n;return i;

[ð](#lib:operator+,iota_view::iterator_)

`friend constexpr iterator operator+(difference_type n, iterator i)
  requires [advanceable](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>;
`

[21](#iterator-21)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3438)

*Effects*: Equivalent to: return i + n;

[ð](#lib:operator-,iota_view::iterator)

`friend constexpr iterator operator-(iterator i, difference_type n)
  requires [advanceable](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>;
`

[22](#iterator-22)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3450)

*Effects*: Equivalent to:i -= n;return i;

[ð](#lib:operator-,iota_view::iterator_)

`friend constexpr difference_type operator-(const iterator& x, const iterator& y)
  requires [advanceable](#concept:advanceable "25.6.4.2 Class template iota_­view [range.iota.view]")<W>;
`

[23](#iterator-23)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3466)

*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_*)); elsereturn (y.*value_* > x.*value_*)? D(-D(y.*value_* - x.*value_*)): D(x.*value_* - y.*value_*);} else {return x.*value_* - y.*value_*;}

#### [25.6.4.4](#sentinel) Class iota_view​::​*sentinel* [[range.iota.sentinel]](range.iota.sentinel)

[ð](#lib:iota_view::sentinel)

namespace std::ranges {template<[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_­incrementable [iterator.concept.winc]") W, [semiregular](concepts.object#concept:semiregular "18.6 Object concepts [concepts.object]") Bound>requires [*weakly-equality-comparable-with*](concept.equalitycomparable#concept:weakly-equality-comparable-with "18.5.4 Concept equality_­comparable [concept.equalitycomparable]")<W, Bound> && [copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]")<W>struct iota_view<W, Bound>::*sentinel* {private: Bound *bound_* = Bound(); // *exposition only*public:*sentinel*() = default; constexpr explicit *sentinel*(Bound bound); friend constexpr bool operator==(const *iterator*& x, const *sentinel*& y); friend constexpr iter_difference_t<W> operator-(const *iterator*& x, const *sentinel*& y)requires [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<Bound, W>; friend constexpr iter_difference_t<W> operator-(const *sentinel*& x, const *iterator*& y)requires [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<Bound, W>; };}

[ð](#lib:iota_view::sentinel,constructor)

`constexpr explicit sentinel(Bound bound);
`

[1](#sentinel-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3515)

*Effects*: Initializes *bound_* with bound[.](#sentinel-1.sentence-1)

[ð](#lib:operator==,iota_view::sentinel)

`friend constexpr bool operator==(const iterator& x, const sentinel& y);
`

[2](#sentinel-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3526)

*Effects*: Equivalent to: return x.*value_* == y.*bound_*;

[ð](#lib:operator-,iota_view::sentinel)

`friend constexpr iter_difference_t<W> operator-(const iterator& x, const sentinel& y)
  requires [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<Bound, W>;
`

[3](#sentinel-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3538)

*Effects*: Equivalent to: return x.*value_* - y.*bound_*;

[ð](#lib:operator-,iota_view::sentinel_)

`friend constexpr iter_difference_t<W> operator-(const sentinel& x, const iterator& y)
  requires [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<Bound, W>;
`

[4](#sentinel-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L3550)

*Effects*: Equivalent to: return -(y - x);
