std::ranges..._view::begin(3)
std::ranges..._view::begin(3) β hiii bestie, welcome to the C++ Standard Libary manual page for std::ranges::stride_view::begin (we folded the manual name in here instead of copying the whole header line, you're welcome π
).
πΈ NAME πΈ
std::ranges::stride_view::begin β std::ranges::stride_view::begin (yes, it says it twice, and honestly? iconic π).
β¨ Synopsis β¨
constexpr auto begin() requires (!__simple_view<V>); (1)
(since C++23)
constexpr auto begin() const requires ranges::range<const V>; (2)
(since C++23)
Returns an iterator to the first element of the stride_view. periodt β¨
- Equivalent to
return iterator<false>(this, ranges::begin(base_));. - Equivalent to
return iterator<true>(this, ranges::begin(base_));.
π¨ real talk: Overload (1) does not participate in overload resolution ifVis a simple view (that is, ifVandconst Vare views with the same iterator and sentinel types).
π¦ Parameters π¦
(none) β literally none, bestie π«Ά
π Return value π
Iterator to the first element of the view. slay β¨
π Example π
A link to test: Compiler Explorer. (The page says it, not me π)
// Run this code
#include <print>
#include <ranges>
int main()
{
constexpr auto v = {'A', 'B', 'C'};
const auto x = v | std::views::stride(2);
const auto y = v | std::views::reverse | std::views::stride(2);
const auto z = v | std::views::stride(2) | std::views::reverse;
std::println("{} {} {}", *x.begin(), *y.begin(), *z.begin());
}
π Output π
A C C
π«Ά See also π«Ά
endβ returns an iterator or a sentinel to the end;(C++23)(public member function) π«
that's the whole vibe! source/version: http://cppreference.com; date: 2024.06.10; page: std::ranges..._view::begin(3) β bye bestie, go iterate something cute ππ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms