[range.factories]

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

## 25.6 Range factories [range.factories]

### [25.6.1](#general) General [[range.factories.general]](range.factories.general)

[1](#general-1)

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

Subclause [range.factories] defines [*range factories*](#def:range_factories),
which are utilities to create a view[.](#general-1.sentence-1)

[2](#general-2)

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

Range factories are declared in namespace std​::​ranges​::​views[.](#general-2.sentence-1)

### [25.6.2](#range.empty) Empty view [[range.empty]](range.empty)

#### [25.6.2.1](#range.empty.overview) Overview [[range.empty.overview]](range.empty.overview)

[1](#range.empty.overview-1)

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

empty_view produces a view of no elements of
a particular type[.](#range.empty.overview-1.sentence-1)

[2](#range.empty.overview-2)

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

[*Example [1](#range.empty.overview-example-1)*: auto e = views::empty<int>;static_assert(ranges::empty(e));static_assert(0 == e.size()); â *end example*]

#### [25.6.2.2](#range.empty.view) Class template empty_view [[range.empty.view]](range.empty.view)

[ð](#lib:empty_view)

namespace std::ranges {template<class T>requires is_object_v<T>class empty_view : public view_interface<empty_view<T>> {public:static constexpr T* begin() noexcept { return nullptr; }static constexpr T* end() noexcept { return nullptr; }static constexpr T* data() noexcept { return nullptr; }static constexpr size_t size() noexcept { return 0; }static constexpr bool empty() noexcept { return true; }};}

### [25.6.3](#range.single) Single view [[range.single]](range.single)

#### [25.6.3.1](#range.single.overview) Overview [[range.single.overview]](range.single.overview)

[1](#range.single.overview-1)

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

single_view produces a view that contains
exactly one element of a specified value[.](#range.single.overview-1.sentence-1)

[2](#range.single.overview-2)

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

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

Given a subexpression E, the expressionviews​::​single(E) is expression-equivalent tosingle_view<decay_t<decltype((E))>>(E)[.](#range.single.overview-2.sentence-2)

[3](#range.single.overview-3)

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

[*Example [1](#range.single.overview-example-1)*: for (int i : views::single(4)) cout << i; // prints 4 â *end example*]

#### [25.6.3.2](#range.single.view) Class template single_view [[range.single.view]](range.single.view)

[ð](#lib:single_view)

namespace std::ranges {template<[move_constructible](concept.moveconstructible#concept:move_constructible "18.4.13 Concept move_­constructible [concept.moveconstructible]") T>requires is_object_v<T>class single_view : public view_interface<single_view<T>> {private:*movable-box*<T> *value_*; // *exposition only* (see [[range.move.wrap]](range.move.wrap "25.7.3 Movable wrapper"))public: single_view() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<T> = default; constexpr explicit single_view(const T& t) requires [copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14 Concept copy_­constructible [concept.copyconstructible]")<T>; constexpr explicit single_view(T&& t); template<class... Args>requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<T, Args...>constexpr explicit single_view(in_place_t, Args&&... args); constexpr T* begin() noexcept; constexpr const T* begin() const noexcept; constexpr T* end() noexcept; constexpr const T* end() const noexcept; static constexpr bool empty() noexcept; static constexpr size_t size() noexcept; constexpr T* data() noexcept; constexpr const T* data() const noexcept; }; template<class T> single_view(T) -> single_view<T>;}

[ð](#lib:single_view,constructor)

`constexpr explicit single_view(const T& t) requires [copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14 Concept copy_­constructible [concept.copyconstructible]")<T>;
`

[1](#range.single.view-1)

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

*Effects*: Initializes *value_* with t[.](#range.single.view-1.sentence-1)

[ð](#lib:single_view,constructor_)

`constexpr explicit single_view(T&& t);
`

[2](#range.single.view-2)

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

*Effects*: Initializes *value_* with std​::​move(t)[.](#range.single.view-2.sentence-1)

[ð](#lib:single_view,constructor__)

`template<class... Args>
  requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<T, Args...>
constexpr explicit single_view(in_place_t, Args&&... args);
`

[3](#range.single.view-3)

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

*Effects*: Initializes *value_* as if by*value_*{in_place, std​::​forward<Args>(args)...}[.](#range.single.view-3.sentence-1)

[ð](#lib:begin,single_view)

`constexpr T* begin() noexcept;
constexpr const T* begin() const noexcept;
`

[4](#range.single.view-4)

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

*Effects*: Equivalent to: return data();

[ð](#lib:end,single_view)

`constexpr T* end() noexcept;
constexpr const T* end() const noexcept;
`

[5](#range.single.view-5)

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

*Effects*: Equivalent to: return data() + 1;

[ð](#lib:empty,single_view)

`static constexpr bool empty() noexcept;
`

[6](#range.single.view-6)

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

*Effects*: Equivalent to: return false;

[ð](#lib:size,single_view)

`static constexpr size_t size() noexcept;
`

[7](#range.single.view-7)

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

*Effects*: Equivalent to: return 1;

[ð](#lib:data,single_view)

`constexpr T* data() noexcept;
constexpr const T* data() const noexcept;
`

[8](#range.single.view-8)

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

*Effects*: Equivalent to: return *value_*.operator->();

### [25.6.4](#range.iota) Iota view [[range.iota]](range.iota)

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

[1](#range.iota.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[.](#range.iota.overview-1.sentence-1)

[2](#range.iota.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"))[.](#range.iota.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[.](#range.iota.overview-2.sentence-2)

[3](#range.iota.overview-3)

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

[*Example [1](#range.iota.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](#range.iota.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"))[.](#range.iota.overview-4.sentence-1)

Given subexpression E,
let T be remove_cvref_t<decltype((E))>[.](#range.iota.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[.](#range.iota.overview-4.sentence-3)

#### [25.6.4.2](#range.iota.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]](#range.iota.iterator "25.6.4.3 Class iota_­view​::​iterator"), class iota_view​::​*iterator*struct *iterator*; // *exposition only*// [[range.iota.sentinel]](#range.iota.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](#range.iota.view-1)

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

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

- [(1.1)](#range.iota.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>[.](#range.iota.view-1.1.sentence-1)

- [(1.2)](#range.iota.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[.](#range.iota.view-1.2.sentence-1)

- [(1.3)](#range.iota.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[.](#range.iota.view-1.3.sentence-1)
  [*Note [1](#range.iota.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]")[.](#range.iota.view-1.3.sentence-2)
 â *end note*]

[2](#range.iota.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](#range.iota.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)[.](#range.iota.view-3.sentence-1)

[4](#range.iota.view-4)

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

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

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

- [(4.1)](#range.iota.view-4.1)

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

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

  * [(4.1.2)](#range.iota.view-4.1.2)

bool(a-- == b)

  * [(4.1.3)](#range.iota.view-4.1.3)

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

  * [(4.1.4)](#range.iota.view-4.1.4)

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

- [(4.2)](#range.iota.view-4.2)

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

[5](#range.iota.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)[.](#range.iota.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[.](#range.iota.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[.](#range.iota.view-sentence-1)

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

- I(a + n) is equal to (a += n)[.](#range.iota.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)[.](#range.iota.view-sentence-1)

- I(a + D(0)) is equal to a[.](#range.iota.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)))[.](#range.iota.view-sentence-1)

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

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

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

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

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

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

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

[ð](#lib:iota_view,constructor)

`constexpr explicit iota_view(W value);
`

[6](#range.iota.view-6)

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

*Preconditions*: Bound denotes unreachable_sentinel_t orBound() is reachable from value[.](#range.iota.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[.](#range.iota.view-6.sentence-2)

[7](#range.iota.view-7)

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

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

[ð](#lib:iota_view,constructor_)

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

[8](#range.iota.view-8)

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

*Preconditions*: Bound denotes unreachable_sentinel_t orbound is reachable from value[.](#range.iota.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[.](#range.iota.view-8.sentence-2)

[9](#range.iota.view-9)

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

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

[ð](#lib:iota_view,constructor__)

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

[10](#range.iota.view-10)

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

*Effects*: Equivalent to:

- [(10.1)](#range.iota.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_*)[.](#range.iota.view-10.1.sentence-1)

- [(10.2)](#range.iota.view-10.2)

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

- [(10.3)](#range.iota.view-10.3)

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

[11](#range.iota.view-11)

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

*Remarks*: The type of last is:

- [(11.1)](#range.iota.view-11.1)

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

- [(11.2)](#range.iota.view-11.2)

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

- [(11.3)](#range.iota.view-11.3)

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

[ð](#lib:begin,iota_view)

`constexpr iterator begin() const;
`

[12](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.iterator-1)

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

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

- [(1.1)](#range.iota.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[.](#range.iota.iterator-1.1.sentence-1)

- [(1.2)](#range.iota.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[.](#range.iota.iterator-1.2.sentence-1)

- [(1.3)](#range.iota.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[.](#range.iota.iterator-1.3.sentence-1)

- [(1.4)](#range.iota.iterator-1.4)

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

[2](#range.iota.iterator-2)

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

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

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

â *end note*]

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

`constexpr explicit iterator(W value);
`

[3](#range.iota.iterator-3)

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

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

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

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

[4](#range.iota.iterator-4)

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

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

[5](#range.iota.iterator-5)

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

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

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

â *end note*]

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

`constexpr iterator& operator++();
`

[6](#range.iota.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](#range.iota.iterator-7)

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

*Effects*: Equivalent to ++*this[.](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.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](#range.iota.sentinel-1)

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

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

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

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

[2](#range.iota.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](#range.iota.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](#range.iota.sentinel-4)

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

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

### [25.6.5](#range.repeat) Repeat view [[range.repeat]](range.repeat)

#### [25.6.5.1](#range.repeat.overview) Overview [[range.repeat.overview]](range.repeat.overview)

[1](#range.repeat.overview-1)

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

repeat_view generates a sequence of elements
by repeatedly producing the same value[.](#range.repeat.overview-1.sentence-1)

[2](#range.repeat.overview-2)

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

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

Given subexpressions E and F,
the expressions views​::​repeat(E) and views​::​repeat(E, F) are expression-equivalent torepeat_view<decay_t<decltype((E))>>(E) and repeat_view(E, F), respectively[.](#range.repeat.overview-2.sentence-2)

[3](#range.repeat.overview-3)

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

[*Example [1](#range.repeat.overview-example-1)*: for (int i : views::repeat(17, 4)) cout << i << ' ';// prints 17 17 17 17 â *end example*]

#### [25.6.5.2](#range.repeat.view) Class template repeat_view [[range.repeat.view]](range.repeat.view)

namespace std::ranges {template<class T>concept [*integer-like-with-usable-difference-type*](#concept:integer-like-with-usable-difference-type "25.6.5.2 Class template repeat_­view [range.repeat.view]") = // *exposition only**is-signed-integer-like*<T> || (*is-integer-like*<T> && [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_­incrementable [iterator.concept.winc]")<T>); template<[move_constructible](concept.moveconstructible#concept:move_constructible "18.4.13 Concept move_­constructible [concept.moveconstructible]") T, [semiregular](concepts.object#concept:semiregular "18.6 Object concepts [concepts.object]") Bound = unreachable_sentinel_t>requires (is_object_v<T> && [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<T, remove_cv_t<T>> &&([*integer-like-with-usable-difference-type*](#concept:integer-like-with-usable-difference-type "25.6.5.2 Class template repeat_­view [range.repeat.view]")<Bound> ||[same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<Bound, unreachable_sentinel_t>))class [repeat_view](#lib:repeat_view "25.6.5.2 Class template repeat_­view [range.repeat.view]") : public view_interface<repeat_view<T, Bound>> {private:// [[range.repeat.iterator]](#range.repeat.iterator "25.6.5.3 Class repeat_­view​::​iterator"), class repeat_view​::​*iterator*struct *iterator*; // *exposition only**movable-box*<T> *value_*; // *exposition only*, see [[range.move.wrap]](range.move.wrap "25.7.3 Movable wrapper") Bound *bound_* = Bound(); // *exposition only*public: repeat_view() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<T> = default; constexpr explicit repeat_view(const T& value, Bound bound = Bound())requires [copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14 Concept copy_­constructible [concept.copyconstructible]")<T>; constexpr explicit repeat_view(T&& value, Bound bound = Bound()); template<class... TArgs, class... BoundArgs>requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<T, TArgs...> &&[constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<Bound, BoundArgs...>constexpr explicit repeat_view(piecewise_construct_t,
 tuple<TArgs...> value_args, tuple<BoundArgs...> bound_args = tuple<>{}); constexpr *iterator* begin() const; constexpr *iterator* end() const requires (![same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<Bound, unreachable_sentinel_t>); constexpr unreachable_sentinel_t end() const noexcept; constexpr auto size() const requires (![same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<Bound, unreachable_sentinel_t>); }; template<class T, class Bound = unreachable_sentinel_t> repeat_view(T, Bound = Bound()) -> repeat_view<T, Bound>;}

[ð](#lib:repeat_view,constructor)

`constexpr explicit repeat_view(const T& value, Bound bound = Bound())
  requires [copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14 Concept copy_­constructible [concept.copyconstructible]")<T>;
`

[1](#range.repeat.view-1)

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

*Preconditions*: If Bound is not unreachable_sentinel_t,bound â¥ 0[.](#range.repeat.view-1.sentence-1)

[2](#range.repeat.view-2)

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

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

[ð](#lib:repeat_view,constructor_)

`constexpr explicit repeat_view(T&& value, Bound bound = Bound());
`

[3](#range.repeat.view-3)

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

*Preconditions*: If Bound is not unreachable_sentinel_t, bound â¥ 0[.](#range.repeat.view-3.sentence-1)

[4](#range.repeat.view-4)

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

*Effects*: Initializes *value_* with std​::​move(value) and*bound_* with bound[.](#range.repeat.view-4.sentence-1)

[ð](#lib:repeat_view,constructor__)

`template<class... TArgs, class... BoundArgs>
  requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<T, TArgs...> &&
           [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_­from [concept.constructible]")<Bound, BoundArgs...>
constexpr explicit repeat_view(piecewise_construct_t,
  tuple<TArgs...> value_args, tuple<BoundArgs...> bound_args = tuple<>{});
`

[5](#range.repeat.view-5)

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

*Effects*: Initializes *value_* withmake_from_tuple<T>(std​::​move(value_args)) and
initializes *bound_* withmake_from_tuple<Bound>(std​::​move(bound_args))[.](#range.repeat.view-5.sentence-1)

The behavior is undefined ifBound is not unreachable_sentinel_t and*bound_* is negative[.](#range.repeat.view-5.sentence-2)

[ð](#lib:begin,repeat_view)

`constexpr iterator begin() const;
`

[6](#range.repeat.view-6)

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

*Effects*: Equivalent to: return *iterator*(addressof(**value_*));

[ð](#lib:end,repeat_view)

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

[7](#range.repeat.view-7)

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

*Effects*: Equivalent to: return *iterator*(addressof(**value_*), *bound_*);

[ð](#lib:end,repeat_view_)

`constexpr unreachable_sentinel_t end() const noexcept;
`

[8](#range.repeat.view-8)

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

*Effects*: Equivalent to: return unreachable_sentinel;

[ð](#lib:size,repeat_view)

`constexpr auto size() const requires (![same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<Bound, unreachable_sentinel_t>);
`

[9](#range.repeat.view-9)

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

*Effects*: Equivalent to: return *to-unsigned-like*(*bound_*);

#### [25.6.5.3](#range.repeat.iterator) Class repeat_view​::​*iterator* [[range.repeat.iterator]](range.repeat.iterator)

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

namespace std::ranges {template<[move_constructible](concept.moveconstructible#concept:move_constructible "18.4.13 Concept move_­constructible [concept.moveconstructible]") T, [semiregular](concepts.object#concept:semiregular "18.6 Object concepts [concepts.object]") Bound>requires (is_object_v<T> && [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<T, remove_cv_t<T>> &&([*integer-like-with-usable-difference-type*](#concept:integer-like-with-usable-difference-type "25.6.5.2 Class template repeat_­view [range.repeat.view]")<Bound> ||[same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<Bound, unreachable_sentinel_t>))class repeat_view<T, Bound>::*iterator* {private:using *index-type* = // *exposition only* conditional_t<[same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<Bound, unreachable_sentinel_t>, ptrdiff_t, Bound>; const T* *value_* = nullptr; // *exposition only**index-type* *current_* = *index-type*(); // *exposition only*constexpr explicit *iterator*(const T* value, *index-type* b = *index-type*()); // *exposition only*public:using iterator_concept = random_access_iterator_tag; using iterator_category = random_access_iterator_tag; using value_type = T; using difference_type = *see below*; *iterator*() = default; constexpr const T& operator*() const noexcept; constexpr *iterator*& operator++(); constexpr *iterator* operator++(int); constexpr *iterator*& operator--(); constexpr *iterator* operator--(int); constexpr *iterator*& operator+=(difference_type n); constexpr *iterator*& operator-=(difference_type n); constexpr const T& operator[](difference_type n) const noexcept; friend constexpr bool operator==(const *iterator*& x, const *iterator*& y); friend constexpr auto operator<=>(const *iterator*& x, const *iterator*& y); friend constexpr *iterator* operator+(*iterator* i, difference_type n); friend constexpr *iterator* operator+(difference_type n, *iterator* i); friend constexpr *iterator* operator-(*iterator* i, difference_type n); friend constexpr difference_type operator-(const *iterator*& x, const *iterator*& y); };}

[1](#range.repeat.iterator-1)

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

If *is-signed-integer-like*<*index-type*> is true,
the member [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]") difference_type denotes *index-type*[.](#range.repeat.iterator-1.sentence-1)

Otherwise, it denotes *IOTA-DIFF-T*(*index-type*) ([[range.iota.view]](#range.iota.view "25.6.4.2 Class template iota_­view"))[.](#range.repeat.iterator-1.sentence-2)

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

`constexpr explicit iterator(const T* value, index-type b = index-type());
`

[2](#range.repeat.iterator-2)

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

*Preconditions*: If Bound is not unreachable_sentinel_t, b â¥ 0[.](#range.repeat.iterator-2.sentence-1)

[3](#range.repeat.iterator-3)

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

*Effects*: Initializes *value_* with value and*current_* with b[.](#range.repeat.iterator-3.sentence-1)

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

`constexpr const T& operator*() const noexcept;
`

[4](#range.repeat.iterator-4)

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

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

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

`constexpr iterator& operator++();
`

[5](#range.repeat.iterator-5)

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

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

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

`constexpr iterator operator++(int);
`

[6](#range.repeat.iterator-6)

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

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

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

`constexpr iterator& operator--();
`

[7](#range.repeat.iterator-7)

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

*Preconditions*: If Bound is not unreachable_sentinel_t,current_>0[.](#range.repeat.iterator-7.sentence-1)

[8](#range.repeat.iterator-8)

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

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

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

`constexpr iterator operator--(int);
`

[9](#range.repeat.iterator-9)

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

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

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

`constexpr iterator& operator+=(difference_type n);
`

[10](#range.repeat.iterator-10)

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

*Preconditions*: If Bound is not unreachable_sentinel_t,current_+nâ¥0[.](#range.repeat.iterator-10.sentence-1)

[11](#range.repeat.iterator-11)

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

*Effects*: Equivalent to:*current_* += n;return *this;

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

`constexpr iterator& operator-=(difference_type n);
`

[12](#range.repeat.iterator-12)

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

*Preconditions*: If Bound is not unreachable_sentinel_t,current_ânâ¥0[.](#range.repeat.iterator-12.sentence-1)

[13](#range.repeat.iterator-13)

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

*Effects*: Equivalent to:*current_* -= n;return *this;

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

`constexpr const T& operator[](difference_type n) const noexcept;
`

[14](#range.repeat.iterator-14)

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

*Effects*: Equivalent to: return *(*this + n);

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

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

[15](#range.repeat.iterator-15)

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

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

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

`friend constexpr auto operator<=>(const iterator& x, const iterator& y);
`

[16](#range.repeat.iterator-16)

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

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

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

`friend constexpr iterator operator+(iterator i, difference_type n);
friend constexpr iterator operator+(difference_type n, iterator i);
`

[17](#range.repeat.iterator-17)

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

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

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

`friend constexpr iterator operator-(iterator i, difference_type n);
`

[18](#range.repeat.iterator-18)

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

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

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

`friend constexpr difference_type operator-(const iterator& x, const iterator& y);
`

[19](#range.repeat.iterator-19)

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

*Effects*: Equivalent to:return static_cast<difference_type>(x.*current_*) - static_cast<difference_type>(y.*current_*);

### [25.6.6](#range.istream) Istream view [[range.istream]](range.istream)

#### [25.6.6.1](#range.istream.overview) Overview [[range.istream.overview]](range.istream.overview)

[1](#range.istream.overview-1)

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

basic_istream_view models [input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") and
reads (using operator>>) successive elements
from its corresponding input stream[.](#range.istream.overview-1.sentence-1)

[2](#range.istream.overview-2)

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

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

Given a type T and a subexpression E of type U,
if U models[derived_from](concept.derived#concept:derived_from "18.4.3 Concept derived_­from [concept.derived]")<basic_istream<typename U​::​char_type,typename U​::​traits_type>>,
then the expression views​::​istream<T>(E) is expression-equivalent tobasic_istream_view<T, typename U​::​char_type,typename U​::​traits_type>(E);
otherwise, views​::​istream<T>(E) is ill-formed[.](#range.istream.overview-2.sentence-2)

[3](#range.istream.overview-3)

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

[*Example [1](#range.istream.overview-example-1)*: auto ints = istringstream{"0 1 2 3 4"};
ranges::copy(views::istream<int>(ints), ostream_iterator<int>{cout, "-"});// prints 0-1-2-3-4- â *end example*]

#### [25.6.6.2](#range.istream.view) Class template basic_istream_view [[range.istream.view]](range.istream.view)

[ð](#lib:basic_istream_view)

namespace std::ranges {template<class Val, class CharT, class Traits>concept [*stream-extractable*](#concept:stream-extractable "25.6.6.2 Class template basic_­istream_­view [range.istream.view]") = // *exposition only*requires(basic_istream<CharT, Traits>& is, Val& t) { is >> t; }; template<[movable](concepts.object#concept:movable "18.6 Object concepts [concepts.object]") Val, class CharT, class Traits = char_traits<CharT>>requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<Val> &&[*stream-extractable*](#concept:stream-extractable "25.6.6.2 Class template basic_­istream_­view [range.istream.view]")<Val, CharT, Traits>class basic_istream_view : public view_interface<basic_istream_view<Val, CharT, Traits>> {public:constexpr explicit basic_istream_view(basic_istream<CharT, Traits>& stream); constexpr auto begin() {**stream_* >> *value_*; return *iterator*{*this}; }constexpr default_sentinel_t end() const noexcept; private:// [[range.istream.iterator]](#range.istream.iterator "25.6.6.3 Class basic_­istream_­view​::​iterator"), class basic_istream_view​::​*iterator*struct *iterator*; // *exposition only* basic_istream<CharT, Traits>* *stream_*; // *exposition only* Val *value_* = Val(); // *exposition only*};}

[ð](#lib:basic_istream_view,constructor)

`constexpr explicit basic_istream_view(basic_istream<CharT, Traits>& stream);
`

[1](#range.istream.view-1)

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

*Effects*: Initializes *stream_* with addressof(stream)[.](#range.istream.view-1.sentence-1)

[ð](#lib:end,basic_istream_view)

`constexpr default_sentinel_t end() const noexcept;
`

[2](#range.istream.view-2)

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

*Effects*: Equivalent to: return default_sentinel;

#### [25.6.6.3](#range.istream.iterator) Class basic_istream_view​::​*iterator* [[range.istream.iterator]](range.istream.iterator)

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

namespace std::ranges {template<[movable](concepts.object#concept:movable "18.6 Object concepts [concepts.object]") Val, class CharT, class Traits>requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<Val> &&[*stream-extractable*](#concept:stream-extractable "25.6.6.2 Class template basic_­istream_­view [range.istream.view]")<Val, CharT, Traits>class basic_istream_view<Val, CharT, Traits>::*iterator* {public:using iterator_concept = input_iterator_tag; using difference_type = ptrdiff_t; using value_type = Val; constexpr explicit *iterator*(basic_istream_view& parent) noexcept; *iterator*(const *iterator*&) = delete; *iterator*(*iterator*&&) = default; *iterator*& operator=(const *iterator*&) = delete; *iterator*& operator=(*iterator*&&) = default; *iterator*& operator++(); void operator++(int);

 Val& operator*() const; friend bool operator==(const *iterator*& x, default_sentinel_t); private: basic_istream_view* *parent_*; // *exposition only*};}

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

`constexpr explicit iterator(basic_istream_view& parent) noexcept;
`

[1](#range.istream.iterator-1)

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

*Effects*: Initializes *parent_* with addressof(parent)[.](#range.istream.iterator-1.sentence-1)

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

`iterator& operator++();
`

[2](#range.istream.iterator-2)

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

*Effects*: Equivalent to:**parent_*->*stream_* >> *parent_*->*value_*;return *this;

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

`void operator++(int);
`

[3](#range.istream.iterator-3)

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

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

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

`Val& operator*() const;
`

[4](#range.istream.iterator-4)

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

*Effects*: Equivalent to: return *parent_*->*value_*;

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

`friend bool operator==(const iterator& x, default_sentinel_t);
`

[5](#range.istream.iterator-5)

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

*Effects*: Equivalent to: return !*x.*parent_*->*stream_*;
