KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches
kumi::function::foldable< T > Class Template Reference

Functional wrapper for values to facilitate pipelined transformations. More...

#include <kumi/functional/monadic.hpp>

Detailed Description

template<typename T>
class kumi::function::foldable< T >

Functional wrapper for values to facilitate pipelined transformations.

kumi::function::foldable provides a lightweight wrapper that enables functional-style chaining of operations using the >> and << operators. It acts as an identity functor, allowing a value to be transformed through a sequence of callables without manual temporary variables.

Template Parameters
TType of the value stored inside kumi::foldable.

Public Member Functions

constexpr auto operator() () const noexcept
 Finalizes the fold.

Friends

template<typename C>
constexpr decltype(auto) operator<< (C &&c, foldable &&f)
 Pipelines the value contained in the foldable into a unary callable, chaining computation from right to left.
template<typename C>
constexpr decltype(auto) operator>> (foldable &&f, C &&c)
 Pipelines the value contained in the foldable into a unary callable, chaining computation from left to right.

(Note that these are not member symbols.)

template<typename T>
 foldable (T &&t) -> foldable< std::unwrap_ref_decay_t< T > >
 kumi::function::foldable deduction guide

Member Function Documentation

◆ operator()()

template<typename T>
auto kumi::function::foldable< T >::operator() ( ) const
inlineconstexprnoexcept

Finalizes the fold.

Returns
The value contained in a foldable, essentially marking the end of a computation.

◆ foldable()

template<typename T>
foldable ( T && t) -> foldable< std::unwrap_ref_decay_t< T > >
related

kumi::function::foldable deduction guide

Template Parameters
TType to wrap into the foldable context.

◆ operator<<

template<typename T>
template<typename C>
decltype(auto) operator<< ( C && c,
foldable< T > && f )
friend

Pipelines the value contained in the foldable into a unary callable, chaining computation from right to left.

Parameters
fThe foldable instance.
cThe unary callable
Returns
A new kumi::foldable containing the result of the invocation.

◆ operator>>

template<typename T>
template<typename C>
decltype(auto) operator>> ( foldable< T > && f,
C && c )
friend

Pipelines the value contained in the foldable into a unary callable, chaining computation from left to right.

Parameters
fThe foldable instance.
cThe unary callable
Returns
A new kumi::foldable containing the result of the invocation.