template <class Name, class Exp, class Body>
struct let
{
// unspecified
};
Name
a class, Exp
and Body
are syntaxes. let
replaces all occurances of Name
with Exp
in Body
. It recurses into template instantiations. The return value of the let
metafunction is the updated Body
.
Let can deal with templates taking not more than MPLLIBS_LIMIT_METAFUNCTION_ARITY
template arguments. This is macro and its value is 10 by default.
#include <mpllibs/metamonad/let.hpp>
For any n
, x
and f
classes, where none of them are the same and t
template the following are equivalent:
let<n, syntax<x>, syntax<f>>::type
f
let<n, syntax<x>, syntax<n>>::type
x
let<n, syntax<x>, syntax<t<f>>>::type
t<f>
let<n, syntax<x>, syntax<t<n>>>::type
t<x>
let<n, syntax<x>, syntax<let<n, f, f>>>::type
let<n, f, f>
using boost::mpl::times;
using boost::mpl::plus;
using boost::mpl::int_;
using namespace mpllibs::metamonad::name;
template <class N>
struct my_metafunction :
eval_syntax<
let<
x, syntax<plus<n, int_<13>>>,
syntax<times<x, x>>
>
>
{};
Copyright Abel Sinkovics (abel at elte dot hu) 2011. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt