std::ranges..._view::begin(3)
π std::ranges::take_while_view::begin π
okay so bestie, this is the C++ Standard Libary manual page for std::ranges::take_while_view::begin β and the header labels the page std::ranges..._view::begin(3) (yes, with the ellipsis, we love an abbreviated moment π
). Itβs giving C++20 ranges energy, and weβre gonna get through every detail together, no cap.
π NAME π
std::ranges::take_while_view::begin - std::ranges::take_while_view::begin
πΈ Synopsis πΈ
Hereβs the synopsis, verbatim, because we do not mess with code in this group chat:
constexpr auto begin() requires (!__SimpleView<V>);
(1) (since C++20)
constexpr auto begin() const requires
ranges::range<const V> &&
(2) (since C++20)
std::indirect_unary_predicate<const Pred,
ranges::iterator_t<const V>>;
Overload (1) is the non-const one, and it 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). Overload (2) is the const one, with the constraints right there in the signature β ranges::range<const V> and std::indirect_unary_predicate<const Pred, ranges::iterator_t<const V>>, periodt. Both are constexpr auto begin(), both are (since C++20), and both are iconic π
.
π Parameters π
Parameters: none. Zero. Nada. Nothing to pass in, bestie π«Ά.
β¨ Return value β¨
ranges::begin(base_), where base_ is the underlying view. Thatβs the whole return value, and it ate π
.
Also, to be clear: begin() returns an iterator to the first element of the view. Effectively, it calls ranges::begin on the underlying view. Lowkey elegant, highkey useful.
π Example π
This section is incomplete. Reason: no example. Literally no example here, so no demo to slay with π. (The page is not hiding one; it just says no example.)
π₯ Defect reports π₯
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR:
LWG 3450 - Applied to:
C++20 - Behavior as published: the const overload might return an iterator non-comparable to the sentinel
- Correct behavior: constrained
So yeah, thatβs the defect-report tea: LWG 3450, applied to C++20, and the published behavior was that the const overload might return an iterator non-comparable to the sentinel. The correct behavior is constrained. Not me reading defect reports for funβ¦ okay maybe me π.
π¦ See also π¦
end(C++20)β returns a sentinel representing the end (public member function)operator==(C++20)β compares a sentinel with an iterator returned fromtake_while_view::begin(function)
π·οΈ Category π·οΈ
Category: * Todo no example
xoxo π source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::ranges..._view::begin(3)
π¦ 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