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

Go to the source code of this file.

Description

Metaprogramming tools for transforming functor types.

Sometimes it is necessary to build and remould a function signature, e.g. for creating a functor or a closure based on an existing function of function pointer. This is a core task of functional programming, but sadly C++ in its current shape is still lacking in this area. (C++11 significantly improved this situation). As an pragmatic fix, we define here a collection of templates, specialising them in a very repetitive way for up to 9 function arguments. Doing so enables us to capture a function, access the return type and argument types as a typelist, eventually to manipulate them and re-build a different signature, or to create specifically tailored bindings.

If the following code makes you feel like vomiting, please look away, and rest assured: you aren't alone.

Todo:
get rid of the repetitive specialisations and use variadic templates to represent the arguments /////////////////////////////////TICKET #994
See also
control::CommandDef usage example
function-closure.hpp generic function application
typelist.hpp
tuple.hpp

Definition in file function.hpp.

#include "lib/meta/typelist.hpp"
#include "lib/meta/util.hpp"
#include <functional>

Classes

struct  _Fun< FUN, SEL >
 Helper for uniform access to function signature types. More...
 
struct  _Fun< FUN, enable_if< has_FunctionOperator< FUN > > >
 Specialisation for function objects and lambdas. More...
 
struct  _Fun< RET(ARGS...)>
 Specialisation for a bare function signature. More...
 
struct  _Fun< RET(C::*)(ARGS...) const >
 Specialisation to handle member pointer to const function; indirectly this specialisation also handles lambdas, as redirected by the main template (via decltype) More...
 
struct  _Fun< RET(C::*)(ARGS...)>
 Specialisation to deal with member pointer to function. More...
 
struct  _Fun< SIG & >
 Specialisation when using a function reference. More...
 
struct  _Fun< SIG && >
 Specialisation for passing a rvalue reference. More...
 
struct  _Fun< SIG * >
 Specialisation for using a function pointer. More...
 
struct  FunctionTypedef< RET, ARGS >
 Build function types from given Argument types. More...
 
struct  FunctionTypedef< RET, Types< A1 > >
 
struct  FunctionTypedef< RET, Types< A1, A2 > >
 
struct  FunctionTypedef< RET, Types< A1, A2, A3 > >
 
struct  FunctionTypedef< RET, Types< A1, A2, A3, A4 > >
 
struct  FunctionTypedef< RET, Types< A1, A2, A3, A4, A5 > >
 
struct  FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6 > >
 
struct  FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6, A7 > >
 
struct  FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6, A7, A8 > >
 
struct  FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6, A7, A8, A9 > >
 
struct  FunctionTypedef< RET, Types<> >
 

Namespaces

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

Class Documentation

struct lib::meta::FunctionTypedef
+ Collaboration diagram for FunctionTypedef< RET, ARGS >:
struct lib::meta::FunctionTypedef< RET, Types< A1 > >
Class Members
typedef function< RET(A1)> Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types< A1 > >:
struct lib::meta::FunctionTypedef< RET, Types< A1, A2 > >
Class Members
typedef function< RET(A1, A2)> Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types< A1, A2 > >:
struct lib::meta::FunctionTypedef< RET, Types< A1, A2, A3 > >
Class Members
typedef function< RET(A1, A2, A3)> Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types< A1, A2, A3 > >:
struct lib::meta::FunctionTypedef< RET, Types< A1, A2, A3, A4 > >
Class Members
typedef function< RET(A1, A2,
A3, A4)>
Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types< A1, A2, A3, A4 > >:
struct lib::meta::FunctionTypedef< RET, Types< A1, A2, A3, A4, A5 > >
Class Members
typedef function< RET(A1, A2,
A3, A4, A5)>
Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types< A1, A2, A3, A4, A5 > >:
struct lib::meta::FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6 > >
Class Members
typedef function< RET(A1, A2,
A3, A4, A5, A6)>
Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6 > >:
struct lib::meta::FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6, A7 > >
Class Members
typedef function< RET(A1, A2,
A3, A4, A5, A6, A7)>
Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6, A7 > >:
struct lib::meta::FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6, A7, A8 > >
Class Members
typedef function< RET(A1, A2,
A3, A4, A5, A6, A7, A8)>
Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6, A7, A8 > >:
struct lib::meta::FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6, A7, A8, A9 > >
Class Members
typedef function< RET(A1, A2,
A3, A4, A5, A6, A7, A8, A9)>
Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types< A1, A2, A3, A4, A5, A6, A7, A8, A9 > >:
struct lib::meta::FunctionTypedef< RET, Types<> >
Class Members
typedef function< RET(void)> Func
typedef RET Sig
+ Collaboration diagram for FunctionTypedef< RET, Types<> >: