File: impl.xml

package info (click to toggle)
boost1.62 1.62.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 686,420 kB
  • sloc: cpp: 2,609,004; xml: 972,558; ansic: 53,674; python: 32,437; sh: 8,829; asm: 3,071; cs: 2,121; makefile: 964; perl: 859; yacc: 472; php: 132; ruby: 94; f90: 55; sql: 13; csh: 6
file content (306 lines) | stat: -rw-r--r-- 14,765 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright 2012 Eric Niebler

  Distributed under the Boost
  Software License, Version 1.0. (See accompanying
  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  -->
<header name="boost/proto/transform/impl.hpp">
  <para>Contains definition of transform&lt;&gt; and transform_impl&lt;&gt; helpers. </para>
  <namespace name="boost">
    <namespace name="proto">
      
      <!-- proto::transform -->
      <struct name="transform">
        <template>
          <template-type-parameter name="PrimitiveTransform"/>
        </template>
        <purpose>Inherit from this to make your type a <conceptname>PrimitiveTransform</conceptname>.</purpose>
        <struct-specialization name="result">
          <template>
            <template-type-parameter name="This"/>
            <template-type-parameter name="Expr"/>
          </template>
          <specialization>
            <template-arg>This(Expr)</template-arg>
          </specialization>
          <typedef name="type">
            <type>typename PrimitiveTransform::template impl&lt; Expr, <replaceable>unspecified</replaceable>, <replaceable>unspecified</replaceable> &gt;::result_type</type>
          </typedef>
        </struct-specialization>
        <struct-specialization name="result">
          <template>
            <template-type-parameter name="This"/>
            <template-type-parameter name="Expr"/>
            <template-type-parameter name="State"/>
          </template>
          <specialization>
            <template-arg>This(Expr, State)</template-arg>
          </specialization>
          <typedef name="type">
            <type>typename PrimitiveTransform::template impl&lt; Expr, State, <replaceable>unspecified</replaceable> &gt;::result_type</type>
          </typedef>
        </struct-specialization>
        <struct-specialization name="result">
          <template>
            <template-type-parameter name="This"/>
            <template-type-parameter name="Expr"/>
            <template-type-parameter name="State"/>
            <template-type-parameter name="Data"/>
          </template>
          <specialization>
            <template-arg>This(Expr, State, Data)</template-arg>
          </specialization>
          <typedef name="type">
            <type>typename PrimitiveTransform::template impl&lt; Expr, State, Data &gt;::result_type</type>
          </typedef>
        </struct-specialization>
        <typedef name="transform_type">
          <type>PrimitiveTransform</type>
        </typedef>
        <method-group name="public member functions">
          <method name="operator()" cv="const">
            <type>typename PrimitiveTransform::template impl&lt;Expr &amp;, <replaceable>unspecified</replaceable>, <replaceable>unspecified</replaceable>&gt;::result_type</type>
            <template>
              <template-type-parameter name="Expr"/>
            </template>
            <parameter name="expr">
              <paramtype>Expr &amp;</paramtype>
            </parameter>
            <returns>
              <computeroutput>
                typename PrimitiveTransform::template impl&lt;Expr &amp;, <replaceable>unspecified</replaceable>, <replaceable>unspecified</replaceable>&gt;()(expr, <replaceable>unspecified</replaceable>, <replaceable>unspecified</replaceable>)
              </computeroutput>
            </returns>
          </method>
          <method name="operator()" cv="const">
            <type>typename PrimitiveTransform::template impl&lt;Expr &amp;, State &amp;, <replaceable>unspecified</replaceable>&gt;::result_type</type>
            <template>
              <template-type-parameter name="Expr"/>
              <template-type-parameter name="State"/>
            </template>
            <parameter name="expr">
              <paramtype>Expr &amp;</paramtype>
            </parameter>
            <parameter name="state">
              <paramtype>State &amp;</paramtype>
            </parameter>
            <returns>
              <computeroutput>
                typename PrimitiveTransform::template impl&lt;Expr &amp;, State &amp;, <replaceable>unspecified</replaceable>&gt;()(expr, state, <replaceable>unspecified</replaceable>)
              </computeroutput>
            </returns>
          </method>
          <method name="operator()" cv="const">
            <type>typename PrimitiveTransform::template impl&lt;Expr &amp;, State const &amp;, <replaceable>unspecified</replaceable>&gt;::result_type</type>
            <template>
              <template-type-parameter name="Expr"/>
              <template-type-parameter name="State"/>
            </template>
            <parameter name="expr">
              <paramtype>Expr &amp;</paramtype>
            </parameter>
            <parameter name="state">
              <paramtype>State const &amp;</paramtype>
            </parameter>
            <returns>
              <computeroutput>
                typename PrimitiveTransform::template impl&lt;Expr &amp;, State const &amp;, <replaceable>unspecified</replaceable>&gt;()(expr, state, <replaceable>unspecified</replaceable>)
              </computeroutput>
            </returns>
          </method>
          <method name="operator()" cv="const">
            <type>typename PrimitiveTransform::template impl&lt;Expr &amp;, State &amp;, Data &amp;&gt;::result_type</type>
            <template>
              <template-type-parameter name="Expr"/>
              <template-type-parameter name="State"/>
              <template-type-parameter name="Data"/>
            </template>
            <parameter name="expr">
              <paramtype>Expr &amp;</paramtype>
            </parameter>
            <parameter name="state">
              <paramtype>State &amp;</paramtype>
            </parameter>
            <parameter name="data">
              <paramtype>Data &amp;</paramtype>
            </parameter>
            <returns>
              <computeroutput>
                typename PrimitiveTransform::template impl&lt;Expr &amp;, State &amp;, Data &amp;&gt;()(expr, state, data)
              </computeroutput>
            </returns>
          </method>
          <method name="operator()" cv="const">
            <type>typename PrimitiveTransform::template impl&lt;Expr &amp;, State const &amp;, Data &amp;&gt;::result_type</type>
            <template>
              <template-type-parameter name="Expr"/>
              <template-type-parameter name="State"/>
              <template-type-parameter name="Data"/>
            </template>
            <parameter name="expr">
              <paramtype>Expr &amp;</paramtype>
            </parameter>
            <parameter name="state">
              <paramtype>State const &amp;</paramtype>
            </parameter>
            <parameter name="data">
              <paramtype>Data &amp;</paramtype>
            </parameter>
            <returns>
              <computeroutput>
                typename PrimitiveTransform::template impl&lt;Expr &amp;, State const &amp;, Data &amp;&gt;()(expr, state, data)
              </computeroutput>
            </returns>
          </method>
        </method-group>
      </struct>

      <!-- proto::transform_impl -->
      <struct name="transform_impl">
        <template>
          <template-type-parameter name="Expr"/>
          <template-type-parameter name="State"/>
          <template-type-parameter name="Data"/>
        </template>
        <typedef name="expr">
          <type>typename boost::remove_reference&lt;Expr const&gt;::type</type>
        </typedef>
        <typedef name="expr_param">
          <type>typename boost::add_reference&lt;Expr const&gt;::type</type>
        </typedef>
        <typedef name="state">
          <type>typename boost::remove_reference&lt;State const&gt;::type</type>
        </typedef>
        <typedef name="state_param">
          <type>typename boost::add_reference&lt;State const&gt;::type</type>
        </typedef>
        <typedef name="data">
          <type>typename boost::remove_reference&lt;Data const&gt;::type</type>
        </typedef>
        <typedef name="data_param">
          <type>typename boost::add_reference&lt;Data const&gt;::type</type>
        </typedef>
      </struct>

      <!-- proto::pack -->
      <struct name="pack">
        <purpose>To turn an expression into a pseudo-parameter pack containing the
        expression's children, for the purpose of expanding the pack expression within
        a <conceptname>CallableTransform</conceptname> or
        <conceptname>ObjectTransform</conceptname>.</purpose>
        <description>
          <para>
            <computeroutput>proto::pack</computeroutput> is useful within
            <conceptname>CallableTransform</conceptname>s and
            <conceptname>ObjectTransform</conceptname>s when one wishes to unpack an expression
            into a function call or an object constructor. <computeroutput>proto::pack</computeroutput>
            turns a Proto expression into a pseudo-parameter pack, which may appear in an unpacking
            pattern to be expanded with the "<computeroutput>...</computeroutput>" syntax.
          </para>

          <para>
            <emphasis role="bold">Example:</emphasis>
          </para>

          <para>
            <programlisting>// The following demonstrates how to use a pseudo-pack expansion
// to unpack an expression into a function call.

struct do_sum : <classname alt="boost::proto::callable">proto::callable</classname>
{
    typedef int result_type;
    
    int operator()(int i) const { return i; }
    int operator()(int i, int j) const { return i + j; }
    int operator()(int i, int j, int k) const { return i + j + k; }
};

// Take any n-ary expression where the children are all int terminals and sum all the ints
struct sum
  : <classname alt="boost::proto::when">proto::when</classname>&lt;
  
        // Match any nary expression where the children are all int terminals
        <classname alt="boost::proto::nary_expr">proto::nary_expr</classname>&lt;<classname alt="boost::proto::_">_</classname>, <classname alt="boost::proto::vararg">proto::vararg</classname>&lt;<classname alt="boost::proto::terminal">proto::terminal</classname>&lt;int&gt; &gt; &gt;

        // Turn the current expression into a pseudo-parameter pack, then expand it,
        // extracting the value from each child in turn.
      , do_sum(<classname alt="boost::proto::_value">proto::_value</classname>(proto::pack(<classname alt="boost::proto::_">_</classname>))...)
    &gt;
{};

int main()
{
    <classname alt="boost::proto::terminal">proto::terminal</classname>&lt;int&gt;::type i = {42};
    int result = sum()( i(3,5) ); // Creates a ternary functional-call expression
    std::cout &lt;&lt; "Sum of 42, 3, and 5 : " &lt;&lt; result &lt;&lt; std::endl;
}</programlisting>
          </para>

          <para>
            The above program displays:
          </para>

          <para>
            <computeroutput>Sum of 42, 3, and 5 : 50</computeroutput>
          </para>

          <para>
            In the above example, the type
            <computeroutput>
              <classname alt="boost::proto::_value">proto::_value</classname>(proto::pack(<classname alt="boost::proto::_">_</classname>))
            </computeroutput>
            is a so-called <emphasis>unpacking pattern</emphasis>, described below.
          </para>

          <para>
            <emphasis role="bold">Unpacking Patterns:</emphasis>
          </para>

          <para>
            Composite transforms (either <conceptname>CallableTransform</conceptname>s or
            <conceptname>ObjectTransform</conceptname>s) usually have the form
            <computeroutput>X(A<subscript>0</subscript>,…A<subscript>n</subscript>)</computeroutput>.
            However, when the argument list in a composite transform is terminated with a C-style
            vararg ellipsis as in <computeroutput>X(A<subscript>0</subscript>,…A<subscript>n</subscript> ...)</computeroutput>,
            the final argument <computeroutput>A<subscript>n</subscript></computeroutput> is treated
            as an <emphasis>unpacking pattern</emphasis>.
          </para>
          
          <para>
            An unpacking pattern must itself be a composite transform; that is, it must be a
            function type representing either a <conceptname>CallableTransform</conceptname> or
            an <conceptname>ObjectTransform</conceptname>. The type <computeroutput>proto::pack(_)</computeroutput>
            must appear exactly once in the unpacking pattern. This type will receive a substitution
            when the unpacking pattern is expanded.
          </para>

          <para>
            A composite transform like <computeroutput>X(A<subscript>0</subscript>,…A<subscript>n</subscript> ...)</computeroutput>,
            when evaluated against a given expression <replaceable>E</replaceable>, state and data, is evaluated as if it were
            <computeroutput>X(A<subscript>0</subscript>,…A<subscript>n-1</subscript>,<replaceable>S</replaceable>)</computeroutput>
            where <replaceable>S</replaceable> is a type sequence computed as follows:
          </para>
          <para>
            Let <computeroutput><replaceable>SUB</replaceable>(A,B)</computeroutput> be a type function that replaces every occurence of
            <computeroutput>proto::pack(_)</computeroutput> within <computeroutput>A</computeroutput> with <computeroutput>B</computeroutput>.
            <itemizedlist>
              <listitem>
                If the expression <replaceable>E</replaceable> is a terminal (i.e. it has arity 0), <replaceable>S</replaceable>
                is the one-element sequence containing <computeroutput><replaceable>SUB</replaceable>(A<subscript>n</subscript>, <classname alt="boost::proto::_value">proto::_value</classname>)</computeroutput>.
              </listitem>
              <listitem>
                If the expression <replaceable>E</replaceable> is a non-terminal, <replaceable>S</replaceable> is the sequence
                <computeroutput><replaceable>SUB</replaceable>(A<subscript>n</subscript>, <classname alt="boost::proto::_child_c">proto::_child_c</classname>&lt;0&gt;),…
                <replaceable>SUB</replaceable>(A<subscript>n</subscript>, <classname alt="boost::proto::_child_c">proto::_child_c</classname>&lt;<replaceable>M</replaceable>-1&gt;)</computeroutput>, where
                <replaceable>M</replaceable> is the arity of the expression <replaceable>E</replaceable>.
              </listitem>
            </itemizedlist>
          </para>
        </description>
      </struct>
      
    </namespace>
  </namespace>
</header>