std::ranges...de_view::end(3)
π std::ranges::stride_view::end π
okay so this is a page from the C++ Standard Library manual, section 3, and it's all about std::ranges::stride_view::end. she's the one who tells you where the party stops. π
β¨ SYNOPSIS β¨
constexpr auto end() requires (!__simple_view<V>); (1) (since C++23)
constexpr auto end() const requires ranges::range<const V> (2) (since C++23)
So there's two overloads bestie, both constexpr, both landing in C++23. number (1) is the non-const one and it's only available when !__simple_view<V> is true; number (2) is the const one and it needs ranges::range<const V> to hold. π«Ά
πΈ DESCRIPTION πΈ
She returns an iterator or a sentinel representing the end of the stride_view. literally her whole job. π
okay so let's define the players β base_ and stride_ are the underlying data members:
- overload (1) β
Constis defined asusing Const = false;andBaseasusing Base = V; - overload (2) β
Constis defined asusing Const = true;andBaseasusing Base = const V;
and it's equivalent to this, no cap:
if constexpr (ranges::common_range<Base> &&
ranges::sized_range<Base> &&
ranges::forward_range<Base>)
{
auto missing = (stride_ - ranges::distance(base_) % stride_) % stride_;
return iterator<Const>(this, ranges::end(base_), missing);
}
else if constexpr (ranges::common_range<Base> &&
!ranges::bidirectional_range<Base>)
{
return iterator<Const>(this, ranges::end(base_));
}
else
{
return std::default_sentinel;
}
three branches, three vibes. she checks the concepts and picks the right one, periodt. π
π¦ PARAMETERS π¦
- (none) β yeah bestie, she takes zero arguments. the way that she just knows π
π RETURN VALUE π
An iterator to the element following the last element, if the underlying view V models common_range. Otherwise, it's the std::default_sentinel, and that sentinel compares equal to the end iterator. both are valid endings, iykyk. π
π₯ NOTES π₯
stride_view<V> models common_range whenever the underlying view V does. so like, the commonness trickles down. π§
π EXAMPLE π
This section is incomplete π Reason: no example π
not me showing up with zero examples, iconic honestly. Category: * Todo no example π
π 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) β
okay that's the whole page slay π the source is http://cppreference.com, dated 2024.06.10, from the std::ranges...de_view::end(3) page β catch you in the group chat bestie, mwah ππ¦πΈ
π¦ 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