std::ranges..._view::begin(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

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 ✨

  1. Equivalent to return iterator<false>(this, ranges::begin(base_));.
  2. Equivalent to return iterator<true>(this, ranges::begin(base_));.
🚨 real talk: Overload (1) does not participate in overload resolution if V is a simple view (that is, if V and const V are 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