Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
function-closure.hpp File Reference

Go to the source code of this file.

Description

Partial function application and building a complete function closure.

This is a addendum to (and thin wrapper for) <functional>, supporting the case when a function should be closed over (partially or all) arguments, where especially the parameter values to close on are provided as a tuple. Additionally, we allow for composing (chaining) of two functions.

Because we have to deal with arbitrary functions and arbitrary parameter types, we need a lot of repetitive code to "catch" functions from zero to nine arguments. At the bottom of this header, you'll find a function-style interface, which wraps up all these technicalities.

Todo:
the implementation is able to handle partial application with N arguments, but currently we need just one argument, thus only this case was wrapped up into a convenient functions func::applyFirst and func::applyLast
See also
control::CommandDef usage example
function.hpp

Definition in file function-closure.hpp.

#include "lib/meta/function.hpp"
#include "lib/meta/tuple-helper.hpp"
#include <functional>
#include <tuple>

Classes

class  BindToArgument< SIG, X, pos >
 Bind a specific argument to an arbitrary value. More...
 
struct  Build< RES, F1, F2, n >
 
struct  Build< RES, F1, F2, 0 >
 
struct  Build< RES, F1, F2, 1 >
 
struct  Build< RES, F1, F2, 2 >
 
struct  Build< RES, F1, F2, 3 >
 
struct  Build< RES, F1, F2, 4 >
 
struct  Build< RES, F1, F2, 5 >
 
struct  Build< RES, F1, F2, 6 >
 
struct  Build< RES, F1, F2, 7 >
 
struct  Build< RES, F1, F2, 8 >
 
struct  Build< RES, F1, F2, 9 >
 
class  FunctionClosure< SIG >
 Closing a function over its arguments. More...
 
class  FunctionComposition< F1, RET >
 Functional composition. More...
 
class  PApply< SIG, VAL >
 Partial function application Takes a function and a value tuple, using the latter to close function arguments either from the front (left) or aligned to the end of the function argument list. More...
 
class  TupleApplicator< SIG >
 Closure-creating template. More...
 

Functions

template<typename SIG , typename... ARG>
_Fun< SIG >::Ret apply (SIG &f, std::tuple< ARG...> &args)
 apply the given function to the argument tuple More...
 
template<typename SIG , typename ARG >
_PapS< SIG >::Function applyFirst (SIG &f, ARG arg)
 close the given function over the first argument More...
 
template<typename SIG , typename ARG >
_PapE< SIG >::Function applyLast (SIG &f, ARG arg)
 close the given function over the last argument More...
 
template<typename SIG , typename TERM >
_PapE< SIG >::Function bindLast (SIG &f, TERM const &arg)
 bind the last function argument to an arbitrary term, which especially might be a (nested) binder... More...
 
template<typename SIG1 , typename SIG2 >
_Chain< SIG1, SIG2 >::Function chained (SIG1 &f1, SIG2 &f2)
 build a functor chaining the given functions More...
 
template<typename SIG , typename... ARG>
_Clo< SIG, Types< ARG...> >::Type closure (SIG &f, std::tuple< ARG...> &args)
 close the given function over all arguments, using the values from the argument tuple. More...
 
template<typename... ARG>
_Sig< void, Types< ARG...>
>::Applicator 
tupleApplicator (std::tuple< ARG...> &args)
 build a TupleApplicator, which embodies the given argument tuple and can be used to apply them to various functions repeatedly. More...
 

Namespaces

 lib
 Implementation namespace for support and library code.
 
 lib::meta
 
 lib::meta::func
 
 lib::meta::func::_composed
 

Class Documentation

struct lib::meta::func::_composed::Build
+ Collaboration diagram for Build< RES, F1, F2, n >: