std::ranges::slide_view<V>::begin
From cppreference.com
< cpp | ranges | slide view
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++26)(C++26)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
std::ranges::slide_view
slide_view::begin
(C++26)
Member functions
Non-member functions
Member functions
Non-member functions
constexpr auto begin()
requires (!(/*simple-view*/<V> && /*slide-caches-nothing*/<const V>));
(1)
(since C++23)
requires (!(/*simple-view*/<V> && /*slide-caches-nothing*/<const V>));
constexpr auto begin() const
requires /*slide-caches-nothing*/<const V>;
(2)
(since C++23)
requires /*slide-caches-nothing*/<const V>;
Returns an iterator to the first element of the slide_view
.
return
iterator
<false>(ranges::begin (base_
),
ranges::next (ranges::begin (base_
),
n_
- 1, ranges::end (base_
)),
n_
);
Otherwise, equivalent to return
iterator
<false>(ranges::begin (base_
),
n_
);. If V models
slide-caches-first
this function caches the result within the cached_begin_
for use on subsequent calls. This is necessary to provide the amortized constant-time complexity required by the range
.2) Equivalent to return
iterator
<true>(ranges::begin (base_
),
n_
);.Contents
[edit] Parameters
(none)
[edit] Return value
An iterator to the first element of slide_view
, which points to the n_
-sized subrange of the underlying view type: V for overload (1) or const V for overload (2).
[edit] Example
Run this code
#include <iostream> #include <ranges> #include <string_view> 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:
∀x ∃y