std::ranges::slide_view::begin - cppreference.com (original) (raw)

constexpr auto begin() requires (!(/*simple-view*/<V> && /*slide-caches-nothing*/<const V>)); (1) (since C++23)
constexpr auto begin() const requires /*slide-caches-nothing*/<const V>; (2) (since C++23)

Returns an iterator to the first element of the slide_view.

If V models _[slide-caches-first](../slide%5Fview.html#slide-caches-first "cpp/ranges/slide view")_ this function caches the result within the _[cachedbegin](../slide%5Fview.html#cached%5Fbegin "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

An iterator to the first element of slide_view, which points to the _[n](../slide%5Fview.html#n "cpp/ranges/slide view")_-sized subrange of the underlying view type: V for overload (1) or const V for overload (2).

[edit] Example

#include #include #include using namespace std::literals;   int main() { static constexpr auto source = {"∀x"sv, "∃y"sv, "ε"sv, "δ"sv}; auto view{std::ranges::slide_view(source, 2)}; const auto subrange{*(view.begin())}; for (std::string_view const s : subrange) std::cout << s << ' '; std::cout << '\n'; }

Output:

[edit] See also

| | returns an iterator or a sentinel to the end (public member function) [edit] | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | compares a sentinel with an iterator returned from slide_view::begin (function) [edit] |