26 Ranges library [ranges]

26.7 Range adaptors [range.adaptors]

26.7.28 Slide view [range.slide]

26.7.28.3 Class template slide_­view​::​iterator [range.slide.iterator]

namespace std::ranges { template<forward_­range V> requires 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_difference_t<Base> n_ = 0; // exposition only constexpr iterator(iterator_t<Base> current, range_difference_t<Base> n) // exposition only requires (!slide-caches-first<Base>); constexpr iterator(iterator_t<Base> current, iterator_t<Base> last_ele, // exposition only range_difference_t<Base> n) requires slide-caches-first<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<iterator_t<V>, iterator_t<Base>>; constexpr auto operator*() const; constexpr iterator& operator++(); constexpr iterator operator++(int); constexpr iterator& operator--() requires bidirectional_­range<Base>; constexpr iterator operator--(int) requires bidirectional_­range<Base>; constexpr iterator& operator+=(difference_type x) requires random_­access_­range<Base>; constexpr iterator& operator-=(difference_type x) requires random_­access_­range<Base>; constexpr auto operator[](difference_type n) const requires random_­access_­range<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<Base>; friend constexpr bool operator>(const iterator& x, const iterator& y) requires random_­access_­range<Base>; friend constexpr bool operator<=(const iterator& x, const iterator& y) requires random_­access_­range<Base>; friend constexpr bool operator>=(const iterator& x, const iterator& y) requires random_­access_­range<Base>; friend constexpr auto operator<=>(const iterator& x, const iterator& y) requires random_­access_­range<Base> && three_­way_­comparable<iterator_t<Base>>; friend constexpr iterator operator+(const iterator& i, difference_type n) requires random_­access_­range<Base>; friend constexpr iterator operator+(difference_type n, const iterator& i) requires random_­access_­range<Base>; friend constexpr iterator operator-(const iterator& i, difference_type n) requires random_­access_­range<Base>; friend constexpr difference_type operator-(const iterator& x, const iterator& y) requires sized_­sentinel_­for<iterator_t<Base>, iterator_t<Base>>; }; }
iterator​::​iterator_­concept is defined as follows:
If the invocation of any non-const member function of iterator exits via an exception, the iterator acquires a singular value.
constexpr iterator(iterator_t<Base> current, range_difference_t<Base> n) requires (!slide-caches-first<Base>);
Effects: Initializes current_­ with current and n_­ with n.
constexpr iterator(iterator_t<Base> current, iterator_t<Base> last_ele, range_difference_t<Base> n) requires slide-caches-first<Base>;
Effects: Initializes current_­ with current, last_­ele_­ with last_­ele, and n_­ with n.
constexpr iterator(iterator<!Const> i) requires Const && convertible_­to<iterator_t<V>, iterator_t<Base>>;
Effects: Initializes current_­ with std​::​move(i.current_­) and n_­ with i.n_­.
[Note 1:
iterator<true> can only be formed when Base models slide-caches-nothing, in which case last_­ele_­ is not present.
— end note]
constexpr auto operator*() const;
Returns: views​::​counted(current_­, n_­).
constexpr iterator& operator++();
Preconditions: current_­ and last_­ele_­ (if present) are incrementable.
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.
Returns: *this.
constexpr iterator operator++(int);
Effects: Equivalent to: auto tmp = *this; ++*this; return tmp;
constexpr iterator& operator--() requires bidirectional_­range<Base>;
Preconditions: current_­ and last_­ele_­ (if present) are decrementable.
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.
Returns: *this.
constexpr iterator operator--(int) requires bidirectional_­range<Base>;
Effects: Equivalent to: auto tmp = *this; --*this; return tmp;
constexpr iterator& operator+=(difference_type x) requires random_­access_­range<Base>;
Preconditions: current_­ + x and last_­ele_­ + x (if last_­ele_­ is present) have well-defined behavior.
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.
Returns: *this.
constexpr iterator& operator-=(difference_type x) requires random_­access_­range<Base>;
Preconditions: current_­ - x and last_­ele_­ - x (if last_­ele_­ is present) have well-defined behavior.
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.
Returns: *this.
constexpr auto operator[](difference_type n) const requires random_­access_­range<Base>;
Effects: Equivalent to: return views​::​counted(current_­ + n, n_­);
friend constexpr bool operator==(const iterator& x, const iterator& y);
Returns: If last_­ele_­ is present, x.last_­ele_­ == y.last_­ele_­; otherwise, x.current_­ == y.current_­.
friend constexpr bool operator<(const iterator& x, const iterator& y) requires random_­access_­range<Base>;
Returns: x.current_­ < y.current_­.
friend constexpr bool operator>(const iterator& x, const iterator& y) requires random_­access_­range<Base>;
Effects: Equivalent to: return y < x;
friend constexpr bool operator<=(const iterator& x, const iterator& y) requires random_­access_­range<Base>;
Effects: Equivalent to: return !(y < x);
friend constexpr bool operator>=(const iterator& x, const iterator& y) requires random_­access_­range<Base>;
Effects: Equivalent to: return !(x < y);
friend constexpr auto operator<=>(const iterator& x, const iterator& y) requires random_­access_­range<Base> && three_­way_­comparable<iterator_t<Base>>;
Returns: x.current_­ <=> y.current_­.
friend constexpr iterator operator+(const iterator& i, difference_type n) requires random_­access_­range<Base>; friend constexpr iterator operator+(difference_type n, const iterator& i) requires random_­access_­range<Base>;
Effects: Equivalent to: auto r = i; r += n; return r;
friend constexpr iterator operator-(const iterator& i, difference_type n) requires random_­access_­range<Base>;
Effects: Equivalent to: auto r = i; r -= n; return r;
friend constexpr difference_type operator-(const iterator& x, const iterator& y) requires sized_­sentinel_­for<iterator_t<Base>, iterator_t<Base>>;
Returns: If last_­ele_­ is present, x.last_­ele_­ - y.last_­ele_­; otherwise, x.current_­ - y.current_­.