]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/bind.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / bind.rst
CommitLineData
7c673cae
FG
1.. Metafunctions/Composition and Argument Binding//bind |30
2
3bind
4====
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11 template<
12 typename F
13 >
14 struct bind0
15 {
16 // |unspecified|
17 // |...|
18 };
19
20 template<
21 typename F, typename A1
22 >
23 struct bind1
24 {
25 // |unspecified|
26 // |...|
27 };
28
29 |...|
30
31 template<
32 typename F, typename A1,\ |...| typename An
33 >
34 struct bind\ *n*
35 {
36 // |unspecified|
37 // |...|
38 };
39
40 template<
41 typename F
42 , typename A1 = |unspecified|
43 |...|
44 , typename An = |unspecified|
45 >
46 struct bind
47 {
48 // |unspecified|
49 // |...|
50 };
51
52
53Description
54-----------
55
56``bind`` is a higher-order primitive for |Metafunction Class| composition
57and argument binding. In essence, it's a compile-time counterpart of
58the similar run-time functionality provided by |Boost.Bind| and |Boost.Lambda|
59libraries.
60
61
62Header
63------
64
65.. parsed-literal::
66
67 #include <boost/mpl/bind.hpp>
68
69
70Model of
71--------
72
73|Metafunction Class|
74
75
76Parameters
77----------
78
79+---------------+-----------------------------------+-----------------------------------------------+
80| Parameter | Requirement | Description |
81+===============+===================================+===============================================+
82| ``F`` | |Metafunction Class| | An metafunction class to perform binding on. |
83+---------------+-----------------------------------+-----------------------------------------------+
84| |A1...An| | Any type | Arguments to bind. |
85+---------------+-----------------------------------+-----------------------------------------------+
86
87
88Expression semantics
89--------------------
90
91For any |Metafunction Class| ``f`` and arbitrary types |a1...an|:
92
93.. parsed-literal::
94
95 typedef bind<f,a1,...a\ *n*\ > g;
96 typedef bind\ *n*\ <f,a1,...a\ *n*\ > g;
97
98:Return type:
99 |Metafunction Class|
100
101.. _`bind semantics`:
102
103:Semantics:
104 Equivalent to
105
106 .. parsed-literal::
107
108 struct g
109 {
110 template<
111 typename U1 = |unspecified|
112 |...|
113 , typename U\ *n* = |unspecified|
114 >
115 struct apply
116 : apply_wrap\ *n*\ <
117 typename h0<f,U1,\ |...|\ U\ *n*>::type
118 , typename h1<a1,U1,\ |...|\ U\ *n*>::type
119 |...|
120 , typename h\ *n*\ <a\ *n*\ ,U1,\ |...|\ U\ *n*>::type
121 >
122 {
123 };
124 };
125
126 where ``h``\ *k* is equivalent to
127
128 .. parsed-literal::
129
130 template< typename X, typename U1,\ |...| typename U\ *n* > struct h\ *k*
131 : apply_wrap\ *n*\ <X,U1,\ |...|\ U\ *n*>
132 {
133 };
134
135 if ``f`` or ``a``\ *k* is a |bind expression| or a |placeholder|, and
136
137 .. parsed-literal::
138
139 template< typename X, typename U1,\ |...| typename U\ *n* > struct h\ *k*
140 {
141 typedef X type;
142 };
143
144 otherwise. |Note:| Every ``n``\th appearance of the `unnamed placeholder`__
145 in the ``bind<f,a1,...an>`` specialization is replaced with the corresponding
146 numbered placeholder ``_``\ *n* |-- end note|
147
148__ `Placeholders`_
149
150
151Example
152-------
153
154.. parsed-literal::
155
156 struct f1
157 {
158 template< typename T1 > struct apply
159 {
160 typedef T1 type;
161 };
162 };
163
164 struct f5
165 {
166 template< typename T1, typename T2, typename T3, typename T4, typename T5 >
167 struct apply
168 {
169 typedef T5 type;
170 };
171 };
172
173 typedef apply_wrap\ ``1``\<
174 bind\ ``1``\<f1,_1>
175 , int
176 >::type r11;
177
178 typedef apply_wrap\ ``5``\<
179 bind\ ``1``\<f1,_5>
180 , void,void,void,void,int
181 >::type r12;
182
183 BOOST_MPL_ASSERT(( is_same<r11,int> ));
184 BOOST_MPL_ASSERT(( is_same<r12,int> ));
185
186 typedef apply_wrap\ ``5``\<
187 bind\ ``5``\<f5,_1,_2,_3,_4,_5>
188 , void,void,void,void,int
189 >::type r51;
190
191 typedef apply_wrap\ ``5``\<
192 bind\ ``5``\<f5,_5,_4,_3,_2,_1>
193 , int,void,void,void,void
194 >::type r52;
195
196 BOOST_MPL_ASSERT(( is_same<r51,int> ));
197 BOOST_MPL_ASSERT(( is_same<r52,int> ));
198
199
200See also
201--------
202
203|Composition and Argument Binding|, |Invocation|, |Placeholders|, |lambda|, |quote|,
204|protect|, |apply|, |apply_wrap|
205
206
207