std::ranges...e_view::end(3)

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

✨ NAME ✨

std::ranges::enumerate_view::end β€” bestie, it's literally the end of std::ranges::enumerate_view πŸ’…

Okay so real talk: this page comes from the C++ Standard Libary manual (that's how the page spells it, don't come for me 😭), and we're about to make end() make sense. Buckle up πŸŽ€


πŸŽ€ Synopsis πŸŽ€

Two overloads, both constexpr, both iconic, both since C++23:

constexpr auto end() requires (!__simple_view<V>);

(1) (since C++23)

constexpr auto end() const requires
/*range-with-movable-references*/<const V>;

(2) (since C++23)

So what does it actually do? It returns an iterator or a sentinel that compares equal to the end iterator of the enumerate_view. That's the whole vibe πŸ¦‹

Let base_ denote the underlying view. (Say it with me: base_ is the underlying view.)

  • Overload (1) is equivalent to:
if constexpr (ranges::forward_range<V> and
              ranges::common_range<V>  and
              ranges::sized_range<V>)
    return /*iterator*/<false>(ranges::end(base_),
ranges::distance(base_));
else
    return /*sentinel*/<false>(ranges::end(base_));
  • Overload (2) is equivalent to:
if constexpr (ranges::forward_range<const V> and
              ranges::common_range<const V>  and
              ranges::sized_range<const V>)
    return /*iterator*/<true>(ranges::end(base_),
ranges::distance(base_));
else
    return /*sentinel*/<true>(ranges::end(base_));

🌸 Parameters 🌸

(none) β€” zero, nada, it takes no parameters, bestie 🫢

πŸ’– Return value πŸ’–

An iterator or a sentinel representing the end of the enumerate_view, as described above.

πŸ¦‹ Example πŸ¦‹

This section is incomplete.

Reason: no example.

It's giving unfinished, ngl 😭 no example yet, periodt.

πŸ”₯ Defect reports πŸ”₯

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • LWG 3919 β€” applied to C++23. Behavior as published: ranges::distance may invoke UB for sized common non-forward underlying ranges. Correct behavior: sentinel type is returned for such ranges. Slay for fixing that one, fr fr πŸ’€

πŸ‘‘ See also πŸ‘‘

  • begin β€” returns an iterator to the beginning (C++23) (public member function)
  • ranges::end β€” returns a sentinel indicating the end of a range (C++20) (customization point object)

πŸ’€ Category πŸ’€

  • Todo no example

And that's the whole page, bestie πŸ’– source/version and date moment: http://cppreference.com, 2024.06.10, page title std::ranges...e_view::end(3) β€” mwah πŸ’‹

πŸ“¦ where this page comes from