Back to Arangodb

Partial Metafunction Application

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

3.12.9.11.4 KB
Original Source

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

Partial Metafunction Application

Consider the lambda expression mpl::plus<_1,_1>. A single argument is directed to both of plus's parameters, thereby adding a number to itself. Thus, a binary metafunction, plus, is used to build a unary lambda expression. In other words, we've created a whole new computation! We're not done yet, though: By supplying a non-placeholder as one of the arguments, we can build a unary lambda expression that adds a fixed value, say 42, to its argument:

mpl::plus<_1, mpl::int_<42> >

The process of binding argument values to a subset of a function's parameters is known in the world of functional programming as partial function application.

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