[range.slide.iterator]

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

## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.slide.iterator)

### 25.7.30 Slide view [[range.slide]](range.slide#iterator)

#### 25.7.30.3 Class template slide_view​::​*iterator* [range.slide.iterator]

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

namespace std::ranges {template<[forward_range](range.refinements#concept:forward_range "25.4.6 Other range refinements [range.refinements]") V>requires [view](range.view#concept:view "25.4.5 Views [range.view]")<V>template<bool Const>class slide_view<V>::*iterator* {using *Base* = *maybe-const*<Const, V>; // *exposition only* iterator_t<*Base*> *current_* = iterator_t<*Base*>(); // *exposition only* iterator_t<*Base*> *last_ele_* = iterator_t<*Base*>(); // *exposition only*,// present only if *Base* models [*slide-caches-first*](range.slide.view#concept:slide-caches-first "25.7.30.2 Class template slide_­view [range.slide.view]") range_difference_t<*Base*> *n_* = 0; // *exposition only*constexpr *iterator*(iterator_t<*Base*> current, range_difference_t<*Base*> n) // *exposition only*requires (![*slide-caches-first*](range.slide.view#concept:slide-caches-first "25.7.30.2 Class template slide_­view [range.slide.view]")<*Base*>); constexpr *iterator*(iterator_t<*Base*> current, iterator_t<*Base*> last_ele, // *exposition only* range_difference_t<*Base*> n)requires [*slide-caches-first*](range.slide.view#concept:slide-caches-first "25.7.30.2 Class template slide_­view [range.slide.view]")<*Base*>; public:using iterator_category = input_iterator_tag; using iterator_concept = *see below*; using value_type = decltype(views::counted(*current_*, *n_*)); using difference_type = range_difference_t<*Base*>; *iterator*() = default; constexpr *iterator*(*iterator*<!Const> i)requires Const && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<iterator_t<V>, iterator_t<*Base*>>; constexpr auto operator*() const; constexpr *iterator*& operator++(); constexpr *iterator* operator++(int); constexpr *iterator*& operator--() requires [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; constexpr *iterator* operator--(int) requires [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; constexpr *iterator*& operator+=(difference_type x)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; constexpr *iterator*& operator-=(difference_type x)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; constexpr auto operator[](difference_type n) constrequires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr bool operator==(const *iterator*& x, const *iterator*& y); friend constexpr bool operator<(const *iterator*& x, const *iterator*& y)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr bool operator>(const *iterator*& x, const *iterator*& y)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr bool operator<=(const *iterator*& x, const *iterator*& y)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr bool operator>=(const *iterator*& x, const *iterator*& y)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr auto operator<=>(const *iterator*& x, const *iterator*& y)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*> &&[three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]")<iterator_t<*Base*>>; friend constexpr *iterator* operator+(const *iterator*& i, difference_type n)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr *iterator* operator+(difference_type n, const *iterator*& i)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr *iterator* operator-(const *iterator*& i, difference_type n)requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<*Base*>; friend constexpr difference_type operator-(const *iterator*& 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]")<iterator_t<*Base*>, iterator_t<*Base*>>; };}

[1](#1)

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

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

- [(1.1)](#1.1)

  If *Base* models [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]"),
then iterator_concept denotes random_access_iterator_tag[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  Otherwise, if *Base* models [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]"),
then iterator_concept denotes bidirectional_iterator_tag[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  Otherwise, iterator_concept denotes forward_iterator_tag[.](#1.3.sentence-1)

[2](#2)

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

If the invocation of any non-const member function of *iterator* exits via an exception, the *iterator* acquires a singular value[.](#2.sentence-1)

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

`constexpr iterator(iterator_t<Base> current, range_difference_t<Base> n)
  requires (![slide-caches-first](range.slide.view#concept:slide-caches-first "25.7.30.2 Class template slide_­view [range.slide.view]")<Base>);
`

[3](#3)

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

*Effects*: Initializes *current_* with current and*n_* with n[.](#3.sentence-1)

[ð](#lib:slide_view::iterator,constructor_)

`constexpr iterator(iterator_t<Base> current, iterator_t<Base> last_ele,
                   range_difference_t<Base> n)
  requires [slide-caches-first](range.slide.view#concept:slide-caches-first "25.7.30.2 Class template slide_­view [range.slide.view]")<Base>;
`

[4](#4)

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

*Effects*: Initializes *current_* with current,*last_ele_* with last_ele, and*n_* with n[.](#4.sentence-1)

[ð](#lib:slide_view::iterator,constructor__)

`constexpr iterator(iterator<!Const> i)
  requires Const && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<iterator_t<V>, iterator_t<Base>>;
`

[5](#5)

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

*Effects*: Initializes *current_* with std​::​move(i.*current_*) and*n_* with i.*n_*[.](#5.sentence-1)

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

*iterator*<true> can only be formed
when *Base* models [*slide-caches-nothing*](range.slide.view#concept:slide-caches-nothing "25.7.30.2 Class template slide_­view [range.slide.view]"),
in which case *last_ele_* is not present[.](#5.sentence-2)

â *end note*]

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

`constexpr auto operator*() const;
`

[6](#6)

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

*Returns*: views​::​counted(*current_*, *n_*)[.](#6.sentence-1)

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

`constexpr iterator& operator++();
`

[7](#7)

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

*Preconditions*: *current_* and *last_ele_* (if present) are incrementable[.](#7.sentence-1)

[8](#8)

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

*Postconditions*: *current_* and *last_ele_* (if present) are
each equal to ranges​::​next(i),
where i is the value of that data member before the call[.](#8.sentence-1)

[9](#9)

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

*Returns*: *this[.](#9.sentence-1)

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

`constexpr iterator operator++(int);
`

[10](#10)

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

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

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

`constexpr iterator& operator--() requires [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[11](#11)

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

*Preconditions*: *current_* and *last_ele_* (if present) are decrementable[.](#11.sentence-1)

[12](#12)

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

*Postconditions*: *current_* and *last_ele_* (if present) are
each equal to ranges​::​prev(i),
where i is the value of that data member before the call[.](#12.sentence-1)

[13](#13)

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

*Returns*: *this[.](#13.sentence-1)

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

`constexpr iterator operator--(int) requires [bidirectional_range](range.refinements#concept:bidirectional_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[14](#14)

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

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

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

`constexpr iterator& operator+=(difference_type x)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[15](#15)

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

*Preconditions*: *current_* + x and *last_ele_* + x (if *last_ele_* is present)
have well-defined behavior[.](#15.sentence-1)

[16](#16)

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

*Postconditions*: *current_* and *last_ele_* (if present) are
each equal to i + x,
where i is the value of that data member before the call[.](#16.sentence-1)

[17](#17)

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

*Returns*: *this[.](#17.sentence-1)

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

`constexpr iterator& operator-=(difference_type x)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[18](#18)

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

*Preconditions*: *current_* - x and *last_ele_* - x (if *last_ele_* is present)
have well-defined behavior[.](#18.sentence-1)

[19](#19)

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

*Postconditions*: *current_* and *last_ele_* (if present) are
each equal to i - x,
where i is the value of that data member before the call[.](#19.sentence-1)

[20](#20)

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

*Returns*: *this[.](#20.sentence-1)

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

`constexpr auto operator[](difference_type n) const
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[21](#21)

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

*Effects*: Equivalent to: return views​::​counted(*current_* + n, *n_*);

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

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

[22](#22)

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

*Returns*: If *last_ele_* is present,x.*last_ele_* == y.*last_ele_*;
otherwise, x.*current_* == y.*current_*[.](#22.sentence-1)

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

`friend constexpr bool operator<(const iterator& x, const iterator& y)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[23](#23)

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

*Returns*: x.*current_* < y.*current_*[.](#23.sentence-1)

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

`friend constexpr bool operator>(const iterator& x, const iterator& y)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[24](#24)

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

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

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

`friend constexpr bool operator<=(const iterator& x, const iterator& y)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[25](#25)

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

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

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

`friend constexpr bool operator>=(const iterator& x, const iterator& y)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[26](#26)

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

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

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

`friend constexpr auto operator<=>(const iterator& x, const iterator& y)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base> &&
           [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]")<iterator_t<Base>>;
`

[27](#27)

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

*Returns*: x.*current_* <=> y.*current_*[.](#27.sentence-1)

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

`friend constexpr iterator operator+(const iterator& i, difference_type n)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
friend constexpr iterator operator+(difference_type n, const iterator& i)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[28](#28)

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

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

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

`friend constexpr iterator operator-(const iterator& i, difference_type n)
  requires [random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]")<Base>;
`

[29](#29)

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

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

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

`friend constexpr difference_type operator-(const iterator& 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]")<iterator_t<Base>, iterator_t<Base>>;
`

[30](#30)

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

*Returns*: If *last_ele_* is present,x.*last_ele_* - y.*last_ele_*;
otherwise, x.*current_* - y.*current_*[.](#30.sentence-1)
