1 .. Metafunctions/Composition and Argument Binding//lambda |20
13 , typename Tag = |unspecified|
17 typedef |unspecified| type;
25 If ``X`` is a |placeholder expression|, transforms ``X`` into a corresponding
26 |Metafunction Class|, otherwise ``X`` is returned unchanged.
34 #include <boost/mpl/lambda.hpp>
40 +---------------+-----------------------+-----------------------------------------------+
41 | Parameter | Requirement | Description |
42 +===============+=======================+===============================================+
43 | ``X`` | Any type | An expression to transform. |
44 +---------------+-----------------------+-----------------------------------------------+
45 | ``Tag`` | Any type | A tag determining transform semantics. |
46 +---------------+-----------------------+-----------------------------------------------+
51 For arbitrary types ``x`` and ``tag``:
56 typedef lambda<x>::type f;
62 If ``x`` is a |placeholder expression| in a general form ``X<a1,...an>``, where
63 ``X`` is a class template and ``a1``,... ``an`` are arbitrary types, equivalent
68 typedef protect< bind<
70 , lambda<a1>::type,\ |...| lambda<a\ *n*\ >::type
73 otherwise, ``f`` is identical to ``x``.
75 .. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79 typedef lambda<x,tag>::type f;
85 If ``x`` is a |placeholder expression| in a general form ``X<a1,...an>``, where
86 ``X`` is a class template and ``a1``,... ``an`` are arbitrary types, equivalent
91 typedef protect< bind<
93 , lambda<a1,tag>::type,\ |...| lambda<a\ *n*\ ,tag>::type
96 otherwise, ``f`` is identical to ``x``.
104 template< typename N1, typename N2 > struct int_plus
105 : int_<( N1::value + N2::value )>
109 typedef lambda< int_plus<_1, int_<42> > >::type f1;
110 typedef bind< quote\ ``2``\ <int_plus>, _1, int_<42> > f2;
112 typedef f1::apply<42>::type r1;
113 typedef f2::apply<42>::type r2;
115 BOOST_MPL_ASSERT_RELATION( r1::value, ==, 84 );
116 BOOST_MPL_ASSERT_RELATION( r2::value, ==, 84 );
122 |Composition and Argument Binding|, |Invocation|, |Placeholders|, |bind|, |quote|, |protect|, |apply|
125 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
126 Distributed under the Boost Software License, Version 1.0. (See accompanying
127 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)