KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches
kumi::function::scannable< F, V > Class Template Reference

Functional wrapper that accumulates state during a transformation chain. More...

#include <kumi/functional/monadic.hpp>

Detailed Description

template<typename F, typename V>
class kumi::function::scannable< F, V >

Functional wrapper that accumulates state during a transformation chain.

kumi::scannable tracks both a current value and a transformation history. As the value is piped through callables, the previous state is bound into the underlying function, effectively performing a "scan" or "prefix sum" at the type level.

Template Parameters
FThe accumulated function state (partial applications).
VThe current result value.

Public Member Functions

constexpr decltype(auto) operator() () const noexcept
 Finalizes the scan.

Friends

template<typename C>
constexpr decltype(auto) operator<< (C &&c, scannable &&s)
 Pipelines the current value into a unary callable and accumulates the operation into the function state, chaining computations from right to left.
template<typename C>
constexpr decltype(auto) operator>> (scannable &&s, C &&c)
 Pipelines the current value into a unary callable and accumulates the operation into the function state, chaining computations from left to right.

(Note that these are not member symbols.)

template<typename F, typename T>
 scannable (F &&f, T &&t) -> scannable< F, std::unwrap_ref_decay_t< T > >
 kumi::function::scannable deduction guide

Member Function Documentation

◆ operator()()

template<typename F, typename V>
decltype(auto) kumi::function::scannable< F, V >::operator() ( ) const
inlineconstexprnoexcept

Finalizes the scan.

Returns
The invocation of the bounded function with the last value contained in a scannable. Essentially marking the end of a computation.

◆ operator<<

template<typename F, typename V>
template<typename C>
decltype(auto) operator<< ( C && c,
scannable< F, V > && s )
friend

Pipelines the current value into a unary callable and accumulates the operation into the function state, chaining computations from right to left.

Parameters
cThe callable to apply.
sThe scannable instance.
Returns
A new kumi::scannable with updated value and bound function state.

◆ operator>>

template<typename F, typename V>
template<typename C>
decltype(auto) operator>> ( scannable< F, V > && s,
C && c )
friend

Pipelines the current value into a unary callable and accumulates the operation into the function state, chaining computations from left to right.

Parameters
sThe scannable instance.
cThe callable to apply.
Returns
A new kumi::scannable with updated value and bound function state.

◆ scannable()

template<typename F, typename T>
scannable ( F && f,
T && t ) -> scannable< F, std::unwrap_ref_decay_t< T > >
related

kumi::function::scannable deduction guide

Template Parameters
TType to wrap into the foldable context.
FFunction to bind arguments to in order to build the history.