std::ranges::slide_view::end - cppreference.com (original) (raw)
| constexpr auto end() requires (!(/*simple-view*/<V> && /*slide-caches-nothing*/<const V>)); | (1) | (since C++23) |
|---|---|---|
| constexpr auto end() const requires /*slide-caches-nothing*/<const V>; | (2) | (since C++23) |
Returns a sentinel or an iterator representing the end of the slide_view.
- Let
_[base](../slide%5Fview.html#base "cpp/ranges/slide view")_and_[n](../slide%5Fview.html#n "cpp/ranges/slide view")_be the underlying data members. Equivalent to:
- If V models
_[slide-caches-nothing](../slide%5Fview.html#slide-caches-nothing "cpp/ranges/slide view")_, return iterator<false>(ranges::begin(base_) + ranges::range_difference_t<V>(size()), n_);. - Otherwise, if V models
_[slide-caches-last](../slide%5Fview.html#slide-caches-last "cpp/ranges/slide view")_, return iterator<false>(ranges::prev(ranges::end(base_), n_ - 1, ranges::begin(base_)), n_);. - Otherwise, if V models common_range, return iterator<false>(ranges::end(base_), ranges::end(base_), n_);.
- Otherwise, return sentinel(ranges::end(base_));.
If V models _[slide-caches-last](../slide%5Fview.html#slide-caches-last "cpp/ranges/slide view")_, this function caches the result within the _[cachedend](../slide%5Fview.html#cached%5Fend "cpp/ranges/slide view")_ for use on subsequent calls. This is necessary to provide the amortized constant-time complexity required by the range.
[edit] Parameters
(none)
[edit] Return value
A sentinel or an iterator representing the end of the slide_view.
[edit] Example
#include #include int main() { static constexpr auto source = {'A', 'B', 'C', 'D'}; for (const auto subrange: source | std::views::slide(3)) { std::cout << "[ "; for (auto it = subrange.begin(); it != subrange.end(); ++it) std::cout << *it << ' '; std::cout << "]\n"; } }
Output:
[edit] See also
| | returns an iterator to the beginning (public member function) [edit] | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | returns an iterator to the beginning of a range(customization point object)[edit] | | | returns a sentinel indicating the end of a range(customization point object)[edit] |