SERiF v0.0.1a
Stellar Evolution and Rotation in Four Dimensions
Loading...
Searching...
No Matches
serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT > Class Template Reference

A calculation may reuse unchanged pieces of its previous immutable result. More...

#include <incremental_computation.hpp>

Public Types

using Key = KeyT
 
using Inputs = std::remove_cvref_t<InputsT>
 
using Function = FunctionT
 
using Update = ComputationUpdate<Inputs, ValueT>
 

Public Member Functions

 IncrementalComputation (FunctionT function)
 Own a callable taking (update, declared inputs...) and returning Value or expected<Value, Error>.
 
template<typename... Arguments>
requires std::invocable<const FunctionT&, const Update&, const Arguments&...> && std::same_as<typename detail::Result<std::remove_cv_t<std::invoke_result_t<const FunctionT&, const Update&, const Arguments&...>>>::Value, ValueT>
decltype(auto) evaluate (const Arguments &... arguments) const
 Without a cache, evaluation is a complete calculation with no previous result.
 
template<typename... Arguments>
decltype(auto) evaluate_update (const Update &update, const Arguments &... arguments) const
 Previous state is read-only; only the returned candidate can become the next accepted result.
 

Static Public Attributes

static constexpr bool owns_inputs = false
 

Private Attributes

FunctionT m_function
 

Detailed Description

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
requires std::is_object_v<ValueT> && std::move_constructible<ValueT>
class serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >

A calculation may reuse unchanged pieces of its previous immutable result.

Member Typedef Documentation

◆ Function

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
using serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >::Function = FunctionT

◆ Inputs

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
using serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >::Inputs = std::remove_cvref_t<InputsT>

◆ Key

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
using serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >::Key = KeyT

◆ Update

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
using serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >::Update = ComputationUpdate<Inputs, ValueT>

Constructor & Destructor Documentation

◆ IncrementalComputation()

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >::IncrementalComputation ( FunctionT function)
inlineexplicit

Own a callable taking (update, declared inputs...) and returning Value or expected<Value, Error>.

Member Function Documentation

◆ evaluate()

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
template<typename... Arguments>
requires std::invocable<const FunctionT&, const Update&, const Arguments&...> && std::same_as<typename detail::Result<std::remove_cv_t<std::invoke_result_t<const FunctionT&, const Update&, const Arguments&...>>>::Value, ValueT>
decltype(auto) serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >::evaluate ( const Arguments &... arguments) const
inlinenodiscard

Without a cache, evaluation is a complete calculation with no previous result.

◆ evaluate_update()

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
template<typename... Arguments>
decltype(auto) serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >::evaluate_update ( const Update & update,
const Arguments &... arguments ) const
inlinenodiscard

Previous state is read-only; only the returned candidate can become the next accepted result.

Member Data Documentation

◆ m_function

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
FunctionT serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >::m_function
private

◆ owns_inputs

template<typename KeyT, typename ValueT, IsKeyList InputsT, typename FunctionT>
bool serif::utils::dependencies::IncrementalComputation< KeyT, ValueT, InputsT, FunctionT >::owns_inputs = false
staticconstexpr

The documentation for this class was generated from the following file: