Namespaces
Variants
Views
Actions

std::ranges::slide_view<V>::end

From cppreference.com
< cpp‎ | ranges‎ | slide view
 
 
Ranges library
Range access
Range conversions
(C++23)
Range primitives



Dangling iterator handling
Range concepts
Views

Factories




Adaptors
Range generators
Range adaptor objects
Range adaptor closure objects
Helper items
 
 
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.

1) Let base_ and n_ be the underlying data members. Equivalent to:
If V models __slide_caches_last, this function caches the result within the slide_view::cached_end_ for use on subsequent calls. This is necessary to provide the amortized constant-time complexity required by the range.
2) Equivalent to begin() + ranges::range_difference_t<const V>(size()).

Contents

[edit] Parameters

(none)

[edit] Return value

A sentinel or an iterator representing the end of the slide_view.

[edit] Example

A link to test: Compiler Explorer.

#include <iostream>
#include <ranges>
 
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:

[ A B C ]
[ B C D ]

[edit] See also

(C++23)
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]