Simple-Utility v2.3.1
Loading...
Searching...
No Matches
sl::functional Namespace Reference

Namespaces

namespace  arithmetic
 
namespace  compare
 
namespace  tuple
 
namespace  util
 

Classes

class  BasicClosure
 The core class, wrapping one functional object and enabling a variety of composing operators for it. More...
 
struct  closure_template
 Primary template, purposely undefined. More...
 
struct  closure_template< BasicClosure< Fn, InvokePolicy, OperatorPolicies... > >
 Specialization, providing the closure template as member alias. More...
 
class  Composition
 Functional type, composing multiple other functional types via the provided strategy. More...
 
class  ConjunctionOperator
 
struct  ConjunctionStrategy
 
class  DisjunctionOperator
 
struct  DisjunctionStrategy
 
class  EqualityOperator
 
struct  EqualityStrategy
 
struct  is_composition
 Primary template, yielding false type. More...
 
struct  is_composition< Composition< CompositionStrategy, Fns... > >
 Specialization for Composition. More...
 
class  NegationOperator
 
struct  Overloaded
 Helper invocable type which can hold an arbitrary amount of functions, from which the best match will be selected during invocation. More...
 
class  PipeOperator
 
struct  PipeStrategy
 
struct  unwrap_functional
 Primary template for non BasicClosure types. More...
 
struct  unwrap_functional< BasicClosure< Fn, InvokePolicy, OperatorPolicies... > & >
 Specialization for lvalue-references of BasicClosure class. More...
 
struct  unwrap_functional< BasicClosure< Fn, InvokePolicy, OperatorPolicies... > && >
 Specialization for rvalue-references of BasicClosure class. More...
 
struct  unwrap_functional< const BasicClosure< Fn, InvokePolicy, OperatorPolicies... > & >
 Specialization for const lvalue-references of BasicClosure class. More...
 
struct  unwrap_functional< const BasicClosure< Fn, InvokePolicy, OperatorPolicies... > && >
 Specialization for const rvalue-references of BasicClosure class. More...
 

Concepts

concept  function
 Determines whether the given type satisfies the constraints of a function type.
 
concept  invoke_policy
 Determines whether the given type satisfies the constraints of an invoke-policy.
 
concept  operator_policy
 Determines whether the given type satisfies the constraints of a operator-policy.
 
concept  composition_strategy
 Determines whether the given type satisfies the requirements of a composition strategy.
 

Typedefs

template<class T >
using unwrap_functional_t = typename unwrap_functional< T >::type
 Convenient alias for the type member alias to unwrap_functional trait.
 
template<concepts::unqualified Derived>
using BasicInvokePolicy = detail::BasicInvokePolicy< Derived, detail::InvocableStrategy >
 CRTP type, enabling all four operator () overloads for derived classes.
 
template<concepts::unqualified Derived>
using NodiscardInvokePolicy = detail::NodiscardInvokePolicy< Derived, detail::InvocableStrategy >
 CRTP type, enabling all four operator () overloads for derived classes, which are all marked with th enodiscard attribute.
 
template<concepts::unqualified Derived>
using PredicateInvokePolicy = detail::NodiscardInvokePolicy< Derived, detail::PredicateStrategy >
 CRTP type, enabling all four operator () overloads for derived classes, which are all marked with the nodiscard attribute.
 
template<concepts::unqualified Derived>
using BasicApplyPolicy = detail::NodiscardInvokePolicy< Derived, detail::ApplicableStrategy >
 CRTP type, enabling all four operator () overloads for derived classes and expects the params to be tied as tuple.
 
template<concepts::unqualified Derived>
using NodiscardApplyPolicy = detail::NodiscardInvokePolicy< Derived, detail::ApplicableStrategy >
 CRTP type, enabling all four operator () overloads for derived classes and expects the params to be tied as tuple. Additionally the call operators are marked with the nodiscard attribute.
 
template<function Fn>
using Predicate = BasicClosure< Fn, PredicateInvokePolicy, PipeOperator, EqualityOperator, ConjunctionOperator, DisjunctionOperator, NegationOperator >
 Closure template for predicate like types, which accepts a functional type and enables pipe, negation, conjunctive and disjunctive chaining, and equality comparison.
 
template<function Fn>
using Transform = BasicClosure< Fn, NodiscardInvokePolicy, PipeOperator >
 Closure template for variadic transform like functional types, which enables piping.
 
template<function Fn>
using Apply = BasicClosure< Fn, NodiscardApplyPolicy, PipeOperator >
 Stores a functional and forwards elements from provided tuples as params on invocation.
 

Functions

template<class Fn >
constexpr unwrap_functional_t< Fn && > && forward_unwrapped (std::remove_reference_t< Fn > &fn) noexcept
 Unwraps the functional if stored in a closure. Otherwise forwards as-is.
 
template<template< class > class Closure, class Fn >
constexpr Closure< std::remove_cvref_t< Fn > > envelop (Fn &&fn) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Fn >, Fn >)
 Wraps the given functional into the given closure type.
 
template<composition_strategy CompositionStrategy, class FirstFn , class SecondFn , class... OtherFns>
requires (std::same_as<unwrap_functional_t<FirstFn>, FirstFn> && std::same_as<unwrap_functional_t<SecondFn>, SecondFn> && (... && std::same_as<unwrap_functional_t<OtherFns>, OtherFns>))
constexpr auto make_composition (FirstFn &&firstFn, SecondFn &&secondFn, OtherFns &&... otherFns) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< FirstFn >, FirstFn > &&std::is_nothrow_constructible_v< std::remove_cvref_t< SecondFn >, SecondFn > &&(... &&std::is_nothrow_constructible_v< std::remove_cvref_t< OtherFns >, OtherFns >))
 Base factory overload, taking fully unwrapped functional objects and forwarding those to a newly created Composition instance.
 
template<composition_strategy CompositionStrategy, class FirstFn , class SecondFn , class... OtherFns>
constexpr auto make_composition (FirstFn &&firstFn, SecondFn &&secondFn, OtherFns &&... otherFns) noexcept(noexcept(make_composition< CompositionStrategy >(forward_unwrapped< FirstFn >(firstFn), forward_unwrapped< SecondFn >(secondFn), forward_unwrapped< OtherFns >(otherFns)...)))
 Factory overload, unwrapping the given functionals and forwarding those to a newly created Composition instance.
 
template<class... Fns>
 Overloaded (Fns...) -> Overloaded< Fns... >
 Deduction guide of overloaded type.
 

Variables

constexpr auto bind_back
 Helper function, which generates a forwarding call wrapper for the given function and curries the params beginning at the back.
 
template<class T >
constexpr bool is_composition_v = is_composition<T>::value
 Convenience constant, yielding the value of the is_composition trait.
 

Function Documentation

◆ make_composition()

template<composition_strategy CompositionStrategy, class FirstFn , class SecondFn , class... OtherFns>
constexpr auto sl::functional::make_composition ( FirstFn &&  firstFn,
SecondFn &&  secondFn,
OtherFns &&...  otherFns 
)
constexprnoexcept

Factory overload, unwrapping the given functionals and forwarding those to a newly created Composition instance.

Template Parameters
CompositionStrategyThe provided strategy type.
FirstFnThe first functional type.
SecondFnThe second functional type.
OtherFnsOther functional types.
Parameters
firstFnThe first functional object.
secondFnThe second functional object.
otherFnsOther functional objects.
Returns
A newly created Composition instance.