std::ranges..._view::begin(3)
π NAME π
std::ranges::drop_while_view::begin β okay bestie, this is the std::ranges..._view::begin(3) page from the C++ Standard Libary manual, and itβs literally the begin member of drop_while_view. No cap, itβs giving iterator-to-the-front energy. β¨
β¨ Synopsis β¨
constexpr auto begin(); (since C++20)
Returns an iterator to the first element of the view. π
Effectively returns ranges::find_if_not(base_, std::cref(pred())), where base_ is the underlying view. The behavior is undefined if *this does not store a predicate. π
β οΈ Warning bestie: undefined behavior if *this does not store a predicate. Not a vibe. Keep the predicate stored, fr fr.
In order to provide the amortized constant time complexity required by the range concept, this function caches the result within the drop_while_view object for use on subsequent calls. Itβs lowkey doing main character caching so later calls stay fast. π₯
πΈ Parameters πΈ
(none) β literally zero parameters, bestie. Nothing. Nada. π«Ά
π Return value π
Iterator to the first element of the view. Periodt. π
π¦ Example π¦
Run this code, bestie π
#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; }
};
std::cout << *view.begin() << '\n';
}
π Output π
3
π See also π
endβ returns an iterator or a sentinel to the end(C++20)(public member function) π
Source/version: http://cppreference.com Β· date: 2024.06.10 β bye bestie, go slay those ranges π§ππ
π¦ 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