std::ranges...le_view::end(3)
π 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
- 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