match_let

Synopsis

template <class Pattern, class Exp, class Body>
struct match_let
{
  // unspecified
};

Description

Pattern matching version of let. The angly-bracket expression Exp is evaluated and matched against the pattern Pattern. The open variables of the match can be used in Body. Pattern and Body are syntaxes.

#include <mpllibs/metamonad/match_let.hpp>

Expression semantics

For any p, e and b angly-bracket expressions

match_let<p, e, b>::type

is equivalent to

multi_let<match<p, e>::type, b>::type

Example

using namespace mpllibs::metamonad::name;

template <class A>
struct maybe_something :
  boost::mpl::if_<
    typename boost::is_same<A, int>::type,
    just<double>,
    nothing
  >
{};

typedef
  eval_syntax<
    match_let<
      syntax<just<var<x>>>, maybe_something<int>::type,
      syntax<x>
    >
  >::type
  this_is_double;

[up]