Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

std::ranges::take_while_view<V,Pred>::pred

Returns a reference to the stored predicate pred_.

NotebookLM
constexpr const Pred& pred() const;
(since C++20)

Returns a reference to the stored predicate pred_.

If *this does not store a predicate (e.g. an exception is thrown on the assignment to *this, which copy-constructs or move-constructs a Pred), the behavior is undefined.

Parameters

(none)

Return value

A reference to the stored predicate.

Example

example.cpp
#include <ranges>
 
int main()
{
    static constexpr int a[]{1, 2, 3, 4, 5};
    constexpr auto v = a | std::views::take_while([](int x){ return x < 4; });
    const auto pred = v.pred();
    static_assert(pred(3));
}

See also

returns a copy of the underlying (adapted) view
(public member function)

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.