Namespaces
Variants
Views
Actions

std::ranges::drop_while_view<V,Pred>::begin

From cppreference.com
 
 
 
 
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.

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.

Contents

[edit] Parameters

(none)

[edit] Return value

iterator to the first element of the view

[edit] Example

#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

[edit] See also

returns an iterator or a sentinel to the end
(public member function) [edit]