Namespaces
Variants
Actions

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

From cppreference.com
 
C++
 
Ranges library
Range adaptors
 
std::ranges::chunk_by_view
constexpr const Pred& pred() const;
(since C++23)

Returns a reference to the contained Pred object. Equivalent to return *pred_;.

The behavior is undefined if pred_ does not contain a value.

[edit] Parameters

(none)

[edit] Return value

A reference to the contained Pred object.

[edit] Example

#include <cassert>
#include <concepts>
#include <functional>
#include <initializer_list>
#include <ranges>
 
int main()
{
    const auto v = {1, 1, 2, 1};
    auto chunks = v | std::views::chunk_by(std::equal_to{});
    auto pred = chunks.pred();
    static_assert(std::same_as<decltype(pred), std::equal_to<>>);
    assert(pred(v.begin()[0], 1);
}

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant