let

Synopsis

template <class Name, class Exp, class Body>
struct let
{
  // unspecified
};

Description

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>

Expression semantics

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>

Example

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>>
    >
  >
{};

[up]