Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
FunctionResult< SIG > Struct Template Reference

#include "lib/wrapper-function-result.hpp"

Description

template<typename SIG>
struct 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
deliberately non-copyable, since we capture a reference to this in order to write to the embedded ItemWrapper. (to alleviate, we'd have to re-link after copying/moving)

Definition at line 52 of file wrapper-function-result.hpp.

Public Types

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

Public Attributes

ResWrapper lastResult_
 

Public Member Functions

 FunctionResult ()=default
 by default locked to invalid state

 
template<typename FUN >
 FunctionResult (FUN &&targetFunction)
 Create result-remembering functor by outfitting a copy of the given function with an adaptor to capture each produced result.
 
Resoperator* () const
 retrieve the last function result observed
 
bool isValid () const
 
 operator bool () const
 

Additional Inherited Members

- Protected Member Functions inherited from NonCopyable
 ~NonCopyable ()=default
 
 NonCopyable ()=default
 
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Constructor & Destructor Documentation

◆ FunctionResult() [1/2]

template<typename SIG >
FunctionResult ( )
default

by default locked to invalid state

◆ FunctionResult() [2/2]

template<typename SIG >
template<typename FUN >
FunctionResult ( FUN &&  targetFunction)
inline

Create result-remembering functor by outfitting a copy of the given function with an adaptor to capture each produced result.

Warning
if function result is a value, it is copied.

Definition at line 72 of file wrapper-function-result.hpp.

References lib::meta::func::chained(), and FunctionResult< SIG >::lastResult_.

+ Here is the call graph for this function:

Member Typedef Documentation

◆ Res

template<typename SIG >
using Res = _Fun<SIG>::Ret

Definition at line 56 of file wrapper-function-result.hpp.

◆ ResWrapper

template<typename SIG >
using ResWrapper = ItemWrapper<Res>

Definition at line 57 of file wrapper-function-result.hpp.

Member Function Documentation

◆ operator*()

template<typename SIG >
Res & operator* ( ) const
inline

retrieve the last function result observed

Definition at line 83 of file wrapper-function-result.hpp.

References FunctionResult< SIG >::lastResult_.

◆ isValid()

template<typename SIG >
bool isValid ( ) const
inline

Definition at line 84 of file wrapper-function-result.hpp.

References ItemWrapper< TY >::isValid(), and FunctionResult< SIG >::lastResult_.

Referenced by FunctionResult< SIG >::operator bool().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator bool()

template<typename SIG >
operator bool ( ) const
inlineexplicit

Definition at line 87 of file wrapper-function-result.hpp.

References FunctionResult< SIG >::isValid().

+ Here is the call graph for this function:

Member Data Documentation

◆ lastResult_

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

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