Thrill
0.1
|
A FunctionStack is a chain of functor that can be folded to a single functor (which is usually optimize by the compiler).
All functors within the chain receive a single input value and a emitter function. The emitter function is used for chaining functors together by enabling items to pushed down the sequence. The single exception to this is the last functor, which receives no emitter, and hence usually stores the items somehow.
The FunctionStack basically consists of a tuple that contains functor objects of varying types.
Input_ | Input to first functor. |
Functors | Types of the different functor. |
Definition at line 90 of file function_stack.hpp.
#include <function_stack.hpp>
Public Types | |
using | Input = Input_ |
Public Member Functions | |
FunctionStack ()=default | |
Construct an empty FunctionStack. More... | |
FunctionStack (const std::tuple< Functors... > &stack) | |
Initialize the function stack with a given tuple of functors. More... | |
auto | fold () const |
Build a single functor by "folding" the stack. More... | |
template<typename Functor > | |
auto | operator& (const Functor &functor) const |
Add a functor to the end of the stack. More... | |
template<typename Functor > | |
auto | push (const Functor &functor) const |
Add a functor function to the end of the stack. More... | |
Static Public Attributes | |
static constexpr bool | empty = (sizeof ... (Functors) == 0) |
Is true if the FunctionStack is empty. More... | |
static constexpr size_t | size = sizeof ... (Functors) |
Number of functors on the FunctionStack. More... | |
Private Member Functions | |
template<size_t... Is> | |
auto | fold_stack (index_sequence< Is... >) const |
Auxilary function for "folding" the stack. More... | |
Private Attributes | |
std::tuple< Functors... > | stack_ |
Tuple of varying type that stores all functor objects functions. More... | |
using Input = Input_ |
Definition at line 93 of file function_stack.hpp.
|
default |
Construct an empty FunctionStack.
|
inlineexplicit |
Initialize the function stack with a given tuple of functors.
stack | Tuple of functor. |
Definition at line 103 of file function_stack.hpp.
|
inline |
Build a single functor by "folding" the stack.
Folding means that the stack is processed from front to back and each emitter is composed using previous functors.
Definition at line 141 of file function_stack.hpp.
|
inlineprivate |
Auxilary function for "folding" the stack.
This is needed to send all functors as parameters to the function that folds them together.
Definition at line 162 of file function_stack.hpp.
|
inline |
Add a functor to the end of the stack.
Alias for push().
Functor | Type of the functors. |
functor | functor that should be added to the stack. |
Definition at line 132 of file function_stack.hpp.
|
inline |
Add a functor function to the end of the stack.
Functor | Type of the functor. |
functor | Functor that should be added to the stack. |
Definition at line 116 of file function_stack.hpp.
|
static |
Is true if the FunctionStack is empty.
Definition at line 146 of file function_stack.hpp.
|
static |
Number of functors on the FunctionStack.
Definition at line 149 of file function_stack.hpp.
|
private |
Tuple of varying type that stores all functor objects functions.
Definition at line 153 of file function_stack.hpp.