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

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

πŸ’… std::ranges::drop_while_view::end

okay bestie, so this page is literally about std::ranges::drop_while_view::end from the C++ Standard Library β€” yes, that whole mouthful β€” and it's the member that tells you where your dropped-while view ends. iconic behavior, honestly.


✨ NAME ✨

std::ranges::drop_while_view::end β€” that's the one, that's the queen. She hands you the end of a drop_while_view.

🌸 Synopsis 🌸

constexpr auto end();  (since C++20)

so she returns a sentinel or an iterator that represents the end of the drop_while_view. no cap.

and like, effectively? she returns ranges::end(base_), where base_ is the underlying view. that's it. that's the whole vibe. 🫢

πŸŽ€ Parameters πŸŽ€

  • (none) β€” nothing, nada, not a single argument. she takes zero input and still serves. main character energy fr fr πŸ’…

πŸ¦‹ Return value πŸ¦‹

a sentinel or an iterator representing the end of the view. that's the whole answer, bestie β€” she's not gonna over-explain it to you. ✨

πŸ“ Example πŸ“

// Run this code

#include <array>
#include <iostream>
#include <ranges>

int main()
{
    constexpr std::array data{0, -1, -2, 3, 1, 4, 1, 5};

    auto view = std::ranges::drop_while_view
    {
        data, [](int x) { return x <= 0; }
    };

    for (auto it = view.begin(); it != view.end(); ++it)
        std::cout << *it << ' ';
    std::cout << '\n';
}

like look at her go β€” she drops everything <= 0 from the front and then loops from view.begin() all the way to view.end(). the way that end() is doing the quiet heavy lifting in the loop condition… we see you, girl. πŸ‘‘

⭐ Output ⭐

3 1 4 1 5

ate and left no crumbs. πŸ”₯

πŸ’œ See also πŸ’œ

  • begin β€” returns an iterator to the beginning. (C++20) (public member function) β€” the other half of the duo, the opener to this closer, we love a matched set 🌈

sign-off szn: this little gem lives over at http://cppreference.com, dated 2024.06.10, and the page itself is std::ranges...le_view::end(3) β€” go forth and drop-while responsibly, bestie πŸ§šπŸ’–

πŸ“¦ where this page comes from