Back to Arangodb

Metafunction Composition

3rdParty/boost/1.78.0/libs/mpl/doc/tutorial/metafunction-composition.html

3.12.9.11.3 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Tutorial: Metafunctions and Higher-Order Metaprogramming / More Lambda Capabilities / Metafunction Composition |

Metafunction Composition

Lambda expressions can also be used to assemble more interesting computations from simple metafunctions. For example, the following expression, which multiplies the sum of two numbers by their difference, is a composition of the three metafunctions multiplies, plus, and minus:

mpl::multiplies<mpl::plus<_1,_2>, mpl::minus<_1,_2> >

When evaluating a lambda expression, MPL checks to see if any of its arguments are themselves lambda expressions, and evaluates each one that it finds. The results of these inner evaluations are substituted into the outer expression before it is evaluated.

| Prev Next | Back Along | Up Home | Full TOC |