20#ifndef TLX_META_FUNCTION_STACK_HEADER
21#define TLX_META_FUNCTION_STACK_HEADER
41template <
typename Functor>
46 return [=, functor = functor](
const auto& input)
mutable ->
void {
60template <
typename Functor,
typename... MoreFunctors>
61auto call_stack(
const Functor& functor,
const MoreFunctors& ... rest) {
65 return [=, functor = functor](
const auto& input)
mutable ->
void {
89template <
typename Input_,
typename... Functors>
115 template <
typename Functor>
116 auto push(
const Functor& functor)
const {
119 std::tuple_cat(
stack_, std::make_tuple(functor)));
131 template <
typename Functor>
146 static constexpr bool empty = (
sizeof ... (Functors) == 0);
149 static constexpr size_t size =
sizeof ... (Functors);
161 template <
size_t... Is>
168template <
typename Input,
typename Functor>
A FunctionStack is a chain of functor that can be folded to a single functor (which is usually optimi...
auto fold_stack(index_sequence< Is... >) const
Auxilary function for "folding" the stack.
auto push(const Functor &functor) const
Add a functor function to the end of the stack.
static constexpr bool empty
Is true if the FunctionStack is empty.
auto fold() const
Build a single functor by "folding" the stack.
FunctionStack(const std::tuple< Functors... > &stack)
Initialize the function stack with a given tuple of functors.
std::tuple< Functors... > stack_
Tuple of varying type that stores all functor objects functions.
FunctionStack()=default
Construct an empty FunctionStack.
auto operator&(const Functor &functor) const
Add a functor to the end of the stack.
static constexpr size_t size
Number of functors on the FunctionStack.