MPL11
 All Classes Namespaces Files Typedefs Macros Groups Pages
List of all members
boost::mpl11::compose< f, fs > Struct Template Reference

Returns the composition of several metafunction classes. More...

#include <boost/mpl11/fwd/functional.hpp>

Detailed Description

template<typename f, typename... fs>
struct boost::mpl11::compose< f, fs >

Returns the composition of several metafunction classes.

Specifically, apply<compose<f, g>, x, xs...> is equivalent to apply<f, apply<g, x>, xs...>, and compose<f> is equivalent to f. Note that only the first argument is passed to g; use bind<f, g> instead if all the arguments must be passed to g.

More than two metafunction classes can also be composed at once; compose<f1, f2, fs...> is equivalent to compose<f1, compose<f2, fs...>>. Also note that compose is associative, i.e. compose<f, compose<g, h>> is equivalent to compose<compose<f, g>, h>.

Haskell pseudo-code:

-- definition (`.` is `compose`)
f . g $ x xs... = f (g x) xs...
-- proof of associativity
f . (g . h) $ x xs... == f ((g . h) x) xs...
== f (g (h x)) xs...
(f . g) . h $ x xs... == (f . g) (h x) xs...
== f (g (h x)) xs...