std::ranges...e_while_view(3)
β¨ NAME β¨
std::ranges::take_while_view::take_while_view β bestie, it's literally the constructor of itself. The class keeps the name, the constructor keeps the name, it's giving "I contain multitudes" but make it a class template π
(This lil page lives in the C++ Standard Libary man pages β yes, that's the manual name, typos and all, we're keeping it exactly as it is, no cap π«Ά)
π SYNOPSIS π
take_while_view() requires std::default_initializable<V> &&
std::default_initializable<Pred> =
(1) (since C++20)
default;
constexpr explicit take_while_view( V base, Pred pred );
(2) (since C++20)
Ok so picture this: you're constructing a take_while_view. Two ways in, both of them since C++20, both of them iconic π
- The default constructor. Constraints check first though β it only exists if
std::default_initializable<V>&&std::default_initializable<Pred>. When it does exist, it value-initializes the underlying view and the predicate. That's it. Clean. Fresh. Effortless. - The two-arg one.
constexpr explicit. Not messing around. It move constructs the underlying view frombaseand the predicate frompred.Lowkey the explicit is a whole story β scroll down to the defect reports, iykyk π
πΈ PARAMETERS πΈ
baseβ the underlying view. The actual content, if you will. Main character energy πfunβ the predicate. (Yes, the page calls itfunwhile the synopsis calls itpred. That's the original's vibe, we do not correct the vibes, we respect them π)
π EXAMPLE π
This section is incomplete Reason: no example
π Not a single example in sight. We simply must imagine one. Manifesting examples for us all, bestie π
π¦ DEFECT REPORTS π¦
Real talk β the following behavior-changing defect reports were applied retroactively to previously published C++ standards. The committee literally said "oops, let's go back and fix that" and honestly? Queen behavior π
LWG 3714(P2711R1), applied to C++20- Behavior as published: the multi-parameter constructor was not explicit
- Correct behavior: it was made explicit π₯
P2325R3, applied to C++20- Behavior as published: if
Predis notdefault_initializable, the default constructor constructs atake_while_viewwhich does not contain anPred - Correct behavior: the
take_while_viewis also notdefault_initializable⨠(so it just... doesn't exist. vibe check failed. respectfully.)
- Behavior as published: if
β CATEGORY β
Todo no example
Still no example. It's a journey. We're on it together π¦π
And that's the whole page, bestie β signed off from the C++ Standard Libary manual, source http://cppreference.com, dated 2024.06.10, filed under std::ranges...e_while_view(3). Slay, go write that take_while_view π
β¨π·
π¦ 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