std::ranges...e_while_view(3)

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

✨ 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 πŸ’–

  1. 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.
  2. The two-arg one. constexpr explicit. Not messing around. It move constructs the underlying view from base and the predicate from pred. 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 it fun while the synopsis calls it pred. 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 Pred is not default_initializable, the default constructor constructs a take_while_view which does not contain an Pred
    • Correct behavior: the take_while_view is also not default_initializable ✨ (so it just... doesn't exist. vibe check failed. respectfully.)

⭐ 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