Lumiera  0.pre.03
»edit your freedom«
FunctionResult< SIG > Class Template Reference

#include "lib/wrapper.hpp"

Description

template<typename SIG>
class lib::wrapper::FunctionResult< SIG >

Extension of ItemWrapper: a function remembering the result of the last invocation.

Initially, the "value" is bottom (undefined, NIL), until the function is invoked for the first time. After that, the result of the last invocation can be accessed by operator* ()

Note
non-copyable. (removing this limitation would require a much more expensive implementation, by implementing operator() ourselves)

Definition at line 410 of file wrapper.hpp.

Public Member Functions

 FunctionResult ()
 default ctor yields an object locked to invalid state
 
template<typename FUN >
 FunctionResult (FUN targetFunction)
 Create result-remembering functor by binding the given function. More...
 
bool isValid () const
 
 operator bool () const
 
Res & operator* () const
 

Private Types

using Res = typename _Fun< SIG >::Ret
 
using ResWrapper = ItemWrapper< Res >
 

Private Member Functions

Res captureResult (Res res)
 
- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Private Attributes

ResWrapper lastResult_
 

Constructor & Destructor Documentation

◆ FunctionResult()

FunctionResult ( FUN  targetFunction)
inline

Create result-remembering functor by binding the given function.

Explanation:

  • *this is a function
  • initially it is defined as invalid
  • then we build the function composition of the target function, and a function storing the result value into the ResWrapper member
  • define ourselves by assigning the resulting composite function

Definition at line 443 of file wrapper.hpp.

+ Inheritance diagram for FunctionResult< SIG >:
+ Collaboration diagram for FunctionResult< SIG >:

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