• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3  Copyright 2012 Eric Niebler
4
5  Distributed under the Boost
6  Software License, Version 1.0. (See accompanying
7  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8  -->
9<header name="boost/proto/transform/call.hpp">
10  <para>Contains definition of the call&lt;&gt; transform. </para>
11  <namespace name="boost">
12    <namespace name="proto">
13      <struct name="call">
14        <template>
15          <template-type-parameter name="T"/>
16        </template>
17        <purpose>Make the given <conceptname>CallableTransform</conceptname> into a <conceptname>PrimitiveTransform</conceptname>.</purpose>
18
19        <description>
20          <para>
21            The purpose of <computeroutput>proto::call&lt;&gt;</computeroutput> is to annotate a transform as callable
22            so that <computeroutput><classname alt="proto::when">proto::when&lt;&gt;</classname></computeroutput> knows
23            how to apply it. The template parameter must be either a <conceptname>PrimitiveTransform</conceptname> or a
24            <conceptname>CallableTransform</conceptname>; that is, a function type for which the return type is a callable
25            <conceptname>PolymorphicFunctionObject</conceptname>.
26          </para>
27
28          <para>
29            For the complete description of the behavior of the <computeroutput>proto::call&lt;&gt;</computeroutput>
30            transform, see the documentation for the nested
31            <computeroutput>
32              <classname alt="proto::call::impl">proto::call::impl&lt;&gt;</classname>
33            </computeroutput>
34            class template.
35          </para>
36        </description>
37
38        <inherit><type><classname>proto::transform</classname>&lt; call&lt;T&gt; &gt;</type></inherit>
39
40        <struct name="impl">
41          <template>
42            <template-type-parameter name="Expr"/>
43            <template-type-parameter name="State"/>
44            <template-type-parameter name="Data"/>
45          </template>
46          <inherit><type><classname>proto::transform_impl</classname>&lt;Expr, State, Data&gt;</type></inherit>
47          <typedef name="result_type">
48            <type><replaceable>see-below</replaceable></type>
49            <description>
50              <para>
51                In the description that follows, a type <computeroutput>T</computeroutput> is determined to model the
52                <conceptname>PrimitiveTransform</conceptname> concept if
53                <computeroutput><classname>proto::is_transform</classname>&lt;T&gt;::value</computeroutput> is
54                <computeroutput>true</computeroutput>.
55              </para>
56              <para>
57                <computeroutput><classname>proto::call</classname>&lt;T&gt;::impl&lt;Expr,State,Data&gt;::result_type</computeroutput>
58                is computed as follows:
59                <itemizedlist>
60                  <listitem>
61                    <para>
62                      If <computeroutput>T</computeroutput> if of the form
63                      <computeroutput><conceptname>PrimitiveTransform</conceptname></computeroutput> or
64                      <computeroutput><conceptname>PrimitiveTransform</conceptname>()</computeroutput>, then
65                      <computeroutput>result_type</computeroutput> is:
66                      <programlisting>typename boost::result_of&lt;PrimitiveTransform(Expr, State, Data)&gt;::type</programlisting>
67                    </para>
68                  </listitem>
69                  <listitem>
70                    <para>
71                      If <computeroutput>T</computeroutput> is of the form
72                      <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>)</computeroutput>, then
73                      <computeroutput>result_type</computeroutput> is:
74                      <programlisting>typename boost::result_of&lt;PrimitiveTransform(
75  typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;(Expr, State, Data)&gt;::type,
76  State,
77  Data
78)&gt;::type</programlisting>
79                    </para>
80                  </listitem>
81                  <listitem>
82                    <para>
83                      If <computeroutput>T</computeroutput> is of the form
84                      <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>)</computeroutput>, then
85                      <computeroutput>result_type</computeroutput> is:
86                      <programlisting>typename boost::result_of&lt;PrimitiveTransform(
87  typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;(Expr, State, Data)&gt;::type,
88  typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>1</subscript>&gt;(Expr, State, Data)&gt;::type,
89  Data
90)&gt;::type</programlisting>
91                    </para>
92                  </listitem>
93                  <listitem>
94                    <para>
95                      If <computeroutput>T</computeroutput> is of the form
96                      <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>, A<subscript>2</subscript>)</computeroutput>, then
97                      <computeroutput>result_type</computeroutput> is:
98                      <programlisting>typename boost::result_of&lt;PrimitiveTransform(
99  typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;(Expr, State, Data)&gt;::type,
100  typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>1</subscript>&gt;(Expr, State, Data)&gt;::type,
101  typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>2</subscript>&gt;(Expr, State, Data)&gt;::type
102)&gt;::type</programlisting>
103                    </para>
104                  </listitem>
105                  <listitem>
106                    <para>
107                      If <computeroutput>T</computeroutput> is of the form
108                      <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n</subscript>)</computeroutput>, then
109                      <computeroutput>result_type</computeroutput> is:
110                      <programlisting>typename boost::result_of&lt;PolymorphicFunctionObject(
111  typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;(Expr, State, Data)&gt;::type,
112113  typename boost::result_of&lt;<classname>when</classname>&lt;<classname>_</classname>,A<subscript>n</subscript>&gt;(Expr, State, Data)&gt;::type
114&gt;::type</programlisting>
115                    </para>
116                  </listitem>
117                  <listitem>
118                    <para>
119                      If <computeroutput>T</computeroutput> is of the form
120                      <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n</subscript> ...)</computeroutput>, then
121                      let <computeroutput>T&apos;</computeroutput> be <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n-1</subscript>, <replaceable>S</replaceable>)</computeroutput>,
122                      where <replaceable>S</replaceable> is a type sequence computed from the unpacking expression <computeroutput>A<subscript>n</subscript></computeroutput>
123                      as described in the reference for <computeroutput><classname>proto::pack</classname></computeroutput>.
124                      Then, <computeroutput>result_type</computeroutput> is:
125                      <programlisting><computeroutput>typename <classname>proto::call</classname>&lt;T&apos;&gt;::impl&lt;Expr,State,Data&gt;::result_type</computeroutput></programlisting>
126                    </para>
127                  </listitem>
128                </itemizedlist>
129              </para>
130            </description>
131          </typedef>
132          <method-group name="public member functions">
133            <method name="operator()" cv="const">
134              <type>result_type</type>
135              <parameter name="expr">
136                <paramtype>typename impl::expr_param</paramtype>
137              </parameter>
138              <parameter name="state">
139                <paramtype>typename impl::state_param</paramtype>
140              </parameter>
141              <parameter name="data">
142                <paramtype>typename impl::data_param</paramtype>
143              </parameter>
144              <description>
145                <para>
146                  In the description that follows, a type <computeroutput>T</computeroutput> is determined to model the
147                  <conceptname>PrimitiveTransform</conceptname> concept if
148                  <computeroutput><classname>proto::is_transform</classname>&lt;T&gt;::value</computeroutput> is
149                  <computeroutput>true</computeroutput>.
150                </para>
151                <para>
152                  <computeroutput><classname>proto::call</classname>&lt;T&gt;::impl&lt;Expr,State,Data&gt;::operator()</computeroutput> behaves as follows:
153                  <itemizedlist>
154                    <listitem>
155                      <para>
156                        If <computeroutput>T</computeroutput> if of the form
157                        <computeroutput><conceptname>PrimitiveTransform</conceptname></computeroutput> or
158                        <computeroutput><conceptname>PrimitiveTransform</conceptname>()</computeroutput>, then
159                        return
160                        <programlisting>PrimitiveTransform()(expr, state, data)</programlisting>
161                      </para>
162                    </listitem>
163                    <listitem>
164                      <para>
165                        If <computeroutput>T</computeroutput> is of the form
166                        <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>)</computeroutput>, then
167                        return
168                        <programlisting>PrimitiveTransform()(
169  <classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;()(expr, state, data),
170  state,
171  sata
172)</programlisting>
173                      </para>
174                    </listitem>
175                    <listitem>
176                      <para>
177                        If <computeroutput>T</computeroutput> is of the form
178                        <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>)</computeroutput>, then
179                        return:
180                        <programlisting>PrimitiveTransform()(
181  <classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;()(expr, state, data),
182  <classname>when</classname>&lt;<classname>_</classname>,A<subscript>1</subscript>&gt;()(expr, state, data),
183  Data
184)</programlisting>
185                      </para>
186                    </listitem>
187                    <listitem>
188                      <para>
189                        If <computeroutput>T</computeroutput> is of the form
190                        <computeroutput><conceptname>PrimitiveTransform</conceptname>(A<subscript>0</subscript>, A<subscript>1</subscript>, A<subscript>2</subscript>)</computeroutput>, then
191                        return
192                        <programlisting>PrimitiveTransform()(
193  <classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;()(expr, state, data),
194  <classname>when</classname>&lt;<classname>_</classname>,A<subscript>1</subscript>&gt;()(expr, state, data),
195  <classname>when</classname>&lt;<classname>_</classname>,A<subscript>2</subscript>&gt;()(expr, state, data)
196)</programlisting>
197                      </para>
198                    </listitem>
199                    <listitem>
200                      <para>
201                        If <computeroutput>T</computeroutput> is of the form
202                        <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n</subscript>)</computeroutput>, then
203                        return:
204                        <programlisting>PolymorphicFunctionObject()(
205  <classname>when</classname>&lt;<classname>_</classname>,A<subscript>0</subscript>&gt;()(expr, state, data),
206  ...
207  <classname>when</classname>&lt;<classname>_</classname>,A<subscript>n</subscript>&gt;()(expr, state, data)
208)</programlisting>
209                      </para>
210                    </listitem>
211                  <listitem>
212                    <para>
213                      If <computeroutput>T</computeroutput> is of the form
214                      <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n</subscript> ...)</computeroutput>, then
215                      let <computeroutput>T&apos;</computeroutput> be <computeroutput><conceptname>PolymorphicFunctionObject</conceptname>(A<subscript>0</subscript>,…A<subscript>n-1</subscript>, <replaceable>S</replaceable>)</computeroutput>,
216                      where <replaceable>S</replaceable> is a type sequence computed from the unpacking expression <computeroutput>A<subscript>n</subscript></computeroutput>
217                      as described in the reference for <computeroutput><classname>proto::pack</classname></computeroutput>.
218                      Then, return:
219                      <programlisting><computeroutput><classname>proto::call</classname>&lt;T&apos;&gt;()(expr, state, data)</computeroutput></programlisting>
220                    </para>
221                  </listitem>
222                  </itemizedlist>
223                </para>
224              </description>
225            </method>
226          </method-group>
227        </struct>
228      </struct>
229    </namespace>
230  </namespace>
231</header>
232