Mirror reflection library 0.5.13

mirror/meta_prog/lambda.hpp

Go to the documentation of this file.
00001 
00010 #ifndef MIRROR_META_PROG_LAMBDA_1011291729_HPP
00011 #define MIRROR_META_PROG_LAMBDA_1011291729_HPP
00012 
00013 
00014 #include <mirror/meta_prog/range.hpp>
00015 
00016 MIRROR_NAMESPACE_BEGIN
00017 namespace mp {
00018 
00020 
00026 template <unsigned Number>
00027 struct arg
00028 {
00029     template <typename ... Params>
00030     struct apply
00031     {
00032         typedef typename at_c<
00033             range<Params...>,
00034             Number - 1
00035         >::type type;
00036     };
00037 };
00038 
00039 
00040 #ifdef MIRROR_DOCUMENTATION_ONLY
00041 
00042 
00049 template <typename LambdaExpression, typename ... Params>
00050 struct apply
00051 {
00053     typedef unspecified type;
00054 };
00055 #else
00056 // specialization for meta-function classes
00057 template <typename MetaFunctionClass, typename ... Params>
00058 struct apply
00059 {
00060     typedef typename MetaFunctionClass::
00061         template apply<Params...>::type type;
00062 };
00063 #endif
00064 
00065 #ifdef MIRROR_DOCUMENTATION_ONLY
00066 
00067 
00076 template <typename Expr, typename ... Params>
00077 struct use_arg
00078 {
00080     typedef unspecified type;
00081 };
00082 #else
00083 // The default implementation which returns the Arg type
00084 template <typename Arg, typename ... Params>
00085 struct use_arg
00086 {
00087     typedef Arg type;
00088 };
00089 #endif
00090 
00091 #ifdef MIRROR_DOCUMENTATION_ONLY
00092 
00093 
00098 template <typename PlaceholderExpression>
00099 struct protect
00100 {
00101     typedef unspecified type;
00102 };
00103 #else
00104 template <typename Expr>
00105 struct protect
00106 {
00107     typedef Expr type;
00108 };
00109 #endif
00110 
00111 // Specialization for the arg<N> meta-function class
00112 template <unsigned Number, typename ... Params>
00113 struct use_arg<arg<Number>, Params...>
00114 {
00115     typedef typename at_c<range<Params...>, Number - 1>::type type;
00116 };
00117 
00118 // Specialization for the arg<N> meta-function wrapped in 1 expression template
00119 template <
00120     template <class> class Expr,
00121     unsigned Number,
00122     typename ... Params
00123 >
00124 struct use_arg<Expr<arg<Number> >, Params...>
00125 {
00126     // get the N-th parameter and pass it to the expression template
00127     typedef typename Expr<
00128         typename at_c<range<Params...>, Number - 1>::type
00129     >::type type;
00130 };
00131 
00132 template <
00133     typename Expr,
00134     typename ... Params
00135 >
00136 struct use_arg<protect<Expr>, Params...>
00137 {
00138     typedef Expr type;
00139 };
00140 
00141 template <
00142     template <class...> class Expr,
00143     typename ... SubExprs,
00144     typename ... Params
00145 >
00146 struct use_arg<Expr<SubExprs...>, Params...>
00147 {
00148     typedef typename Expr<
00149         typename use_arg<
00150             SubExprs,
00151             Params...
00152         >::type...
00153     >::type type;
00154 };
00155 
00156 // specialization for expression template instantiations
00157 template <
00158     template <typename ...> class Expr,
00159     typename ... ExprArgs,
00160     typename ... Params
00161 >
00162 struct apply<Expr<ExprArgs...>, Params...>
00163 {
00164     typedef typename Expr<
00165         typename use_arg<ExprArgs, Params...>::type ...
00166     >::type type;
00167 };
00168 
00169 // specialization for the arg<N> meta-function class
00170 template <unsigned Number, typename ... Params>
00171 struct apply<arg<Number>, Params...>
00172 {
00173     typedef typename arg<Number>::
00174         template apply<Params...>::type type;
00175 };
00176 
00177 } // namespace mp
00178 MIRROR_NAMESPACE_END
00179 
00180 #endif //include guard
00181 

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.