20 #ifndef TLX_META_FUNCTION_STACK_HEADER 21 #define TLX_META_FUNCTION_STACK_HEADER 32 namespace meta_detail {
41 template <
typename Functor>
46 return [=, functor = functor](
const auto& input)
mutable ->
void {
60 template <
typename Functor,
typename... MoreFunctors>
61 auto call_stack(
const Functor& functor,
const MoreFunctors& ... rest) {
65 return [=, functor = functor](
const auto& input)
mutable ->
void {
89 template <
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>
132 auto operator & (
const Functor& functor)
const {
return push(functor); }
146 static constexpr
bool empty = (
sizeof ... (Functors) == 0);
149 static constexpr
size_t size =
sizeof ... (Functors);
161 template <
size_t... Is>
168 template <
typename Input,
typename Functor>
178 #endif // !TLX_META_FUNCTION_STACK_HEADER
auto fold_stack(index_sequence< Is... >) const
Auxilary function for "folding" the stack.
A FunctionStack is a chain of functor that can be folded to a single functor (which is usually optimi...
auto push(const Functor &functor) const
Add a functor function to the end of the stack.
std::tuple< Functors... > stack_
Tuple of varying type that stores all functor objects functions.
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.