]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/lambda.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / lambda.rst
CommitLineData
7c673cae
FG
1.. Metafunctions/Composition and Argument Binding//lambda |20
2
3lambda
4======
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11 template<
12 typename X
13 , typename Tag = |unspecified|
14 >
15 struct lambda
16 {
17 typedef |unspecified| type;
18 };
19
20
21
22Description
23-----------
24
25If ``X`` is a |placeholder expression|, transforms ``X`` into a corresponding
26|Metafunction Class|, otherwise ``X`` is returned unchanged.
27
28
29Header
30------
31
32.. parsed-literal::
33
34 #include <boost/mpl/lambda.hpp>
35
36
37Parameters
38----------
39
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+---------------+-----------------------+-----------------------------------------------+
47
48Expression semantics
49--------------------
50
51For arbitrary types ``x`` and ``tag``:
52
53
54.. parsed-literal::
55
56 typedef lambda<x>::type f;
57
58:Return type:
59 |Metafunction Class|.
60
61:Semantics:
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
64 to
65
66 .. parsed-literal::
67
68 typedef protect< bind<
69 quote\ *n*\ <X>
70 , lambda<a1>::type,\ |...| lambda<a\ *n*\ >::type
71 > > f;
72
73 otherwise, ``f`` is identical to ``x``.
74
75.. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76
77.. parsed-literal::
78
79 typedef lambda<x,tag>::type f;
80
81:Return type:
82 |Metafunction Class|.
83
84:Semantics:
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
87 to
88
89 .. parsed-literal::
90
91 typedef protect< bind<
92 quote\ *n*\ <X,tag>
93 , lambda<a1,tag>::type,\ |...| lambda<a\ *n*\ ,tag>::type
94 > > f;
95
96 otherwise, ``f`` is identical to ``x``.
97
98
99Example
100-------
101
102.. parsed-literal::
103
104 template< typename N1, typename N2 > struct int_plus
105 : int_<( N1::value + N2::value )>
106 {
107 };
108
109 typedef lambda< int_plus<_1, int_<42> > >::type f1;
110 typedef bind< quote\ ``2``\ <int_plus>, _1, int_<42> > f2;
111
112 typedef f1::apply<42>::type r1;
113 typedef f2::apply<42>::type r2;
114
115 BOOST_MPL_ASSERT_RELATION( r1::value, ==, 84 );
116 BOOST_MPL_ASSERT_RELATION( r2::value, ==, 84 );
117
118
119See also
120--------
121
122|Composition and Argument Binding|, |Invocation|, |Placeholders|, |bind|, |quote|, |protect|, |apply|
123
124
125