• 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/default.hpp">
10  <namespace name="boost">
11    <namespace name="proto">
12      <struct name="_default">
13        <template>
14          <template-type-parameter name="Grammar">
15            <default><replaceable>unspecified</replaceable></default>
16          </template-type-parameter>
17        </template>
18        <inherit><classname>proto::transform</classname>&lt; _default&lt;Grammar&gt; &gt;</inherit>
19        <purpose>A <conceptname>PrimitiveTransform</conceptname> that gives expressions their
20          usual C++ behavior</purpose>
21        <description>
22          <para>
23            For the complete description of the behavior of the <computeroutput>proto::_default</computeroutput>
24            transform, see the documentation for the nested <computeroutput>
25              <classname>proto::_default::impl&lt;&gt;</classname>
26            </computeroutput> class template.
27          </para>
28          <para>
29            When used without specifying a <computeroutput>Grammar</computeroutput> parameter,
30            <computeroutput>proto::_default</computeroutput> behaves as if the parameter were
31            <computeroutput>proto::_default&lt;&gt;</computeroutput>.
32          </para>
33        </description>
34        <struct name="impl">
35          <template>
36            <template-type-parameter name="Expr"/>
37            <template-type-parameter name="State"/>
38            <template-type-parameter name="Data"/>
39          </template>
40          <inherit><type><classname>proto::transform_impl</classname>&lt;Expr, State, Data&gt;</type></inherit>
41          <typedef name="Tag">
42            <purpose>For exposition only</purpose>
43            <type>typename Expr::tag_type</type>
44          </typedef>
45          <data-member name="s_expr" specifiers="static">
46            <purpose>For exposition only</purpose>
47            <type>Expr</type>
48          </data-member>
49          <data-member name="s_state" specifiers="static">
50            <purpose>For exposition only</purpose>
51            <type>State</type>
52          </data-member>
53          <data-member name="s_data" specifiers="static">
54            <purpose>For exposition only</purpose>
55            <type>Data</type>
56          </data-member>
57          <typedef name="result_type">
58            <type><emphasis>see-below</emphasis></type>
59            <description>
60              <itemizedlist>
61                <listitem>
62                  <para>
63                    If <computeroutput>Tag</computeroutput> corresponds to a unary prefix operator,
64                    then the result type is
65                    <programlisting>decltype(
66  OP Grammar()(<functionname>proto::child</functionname>(s_expr), s_state, s_data)
67)</programlisting>
68                  </para>
69                </listitem>
70                <listitem>
71                  <para>
72                    If <computeroutput>Tag</computeroutput> corresponds to a unary postfix operator,
73                    then the result type is
74                    <programlisting>decltype(
75  Grammar()(<functionname>proto::child</functionname>(s_expr), s_state, s_data) OP
76)</programlisting>
77                  </para>
78                </listitem>
79                <listitem>
80                  <para>
81                    If <computeroutput>Tag</computeroutput> corresponds to a binary infix operator,
82                    then the result type is
83                    <programlisting>decltype(
84  Grammar()(<functionname>proto::left</functionname>(s_expr), s_state, s_data) OP
85  Grammar()(<functionname>proto::right</functionname>(s_expr), s_state, s_data)
86)</programlisting>
87                  </para>
88                </listitem>
89                <listitem>
90                <para>
91                  If <computeroutput>Tag</computeroutput> is <computeroutput>
92                    <classname>proto::tag::subscript</classname>
93                  </computeroutput>,
94                  then the result type is
95                  <programlisting>decltype(
96  Grammar()(<functionname>proto::left</functionname>(s_expr), s_state, s_data) [
97  Grammar()(<functionname>proto::right</functionname>(s_expr), s_state, s_data) ]
98)</programlisting>
99                </para>
100                </listitem>
101                <listitem>
102                  <para>
103                    If <computeroutput>Tag</computeroutput> is <computeroutput>
104                      <classname>proto::tag::if_else_</classname>
105                    </computeroutput>,
106                    then the result type is
107                    <programlisting>decltype(
108  Grammar()(<functionname>proto::child_c</functionname>&lt;0&gt;(s_expr), s_state, s_data) ?
109  Grammar()(<functionname>proto::child_c</functionname>&lt;1&gt;(s_expr), s_state, s_data) :
110  Grammar()(<functionname>proto::child_c</functionname>&lt;2&gt;(s_expr), s_state, s_data)
111)</programlisting>
112                  </para>
113                </listitem>
114                <listitem>
115                  <para>
116                    If <computeroutput>Tag</computeroutput> is <computeroutput>
117                      <classname>proto::tag::function</classname>
118                    </computeroutput>,
119                    then the result type is
120                    <programlisting>decltype(
121  Grammar()(<functionname>proto::child_c</functionname>&lt;0&gt;(s_expr), s_state, s_data) (
122  Grammar()(<functionname>proto::child_c</functionname>&lt;1&gt;(s_expr), s_state, s_data),
123  ...
124  Grammar()(<functionname>proto::child_c</functionname>&lt;N&gt;(s_expr), s_state, s_data) )
125)</programlisting>
126                  </para>
127                </listitem>
128              </itemizedlist>
129            </description>
130          </typedef>
131          <description>
132            <para>
133              Let <computeroutput><computeroutput>OP</computeroutput></computeroutput> be the C++ operator
134              corresponding to <computeroutput>Expr::proto_tag</computeroutput>. (For example, if
135              <computeroutput>Tag</computeroutput> is <computeroutput>
136              <classname>proto::tag::plus</classname></computeroutput>, let <computeroutput>
137              <computeroutput>OP</computeroutput></computeroutput> be <computeroutput>+</computeroutput>.)
138            </para>
139          </description>
140          <method-group name="public member functions">
141            <method name="operator()" cv="const">
142              <type>result_type</type>
143              <parameter name="expr">
144                <paramtype>typename impl::expr_param</paramtype>
145              </parameter>
146              <parameter name="state">
147                <paramtype>typename impl::state_param</paramtype>
148              </parameter>
149              <parameter name="data">
150                <paramtype>typename impl::data_param</paramtype>
151              </parameter>
152            <description>
153              <computeroutput>
154                <classname>proto::_default</classname>&lt;Grammar&gt;::impl&lt;Expr, State, Data&gt;::operator()
155              </computeroutput> returns the following:
156              <itemizedlist>
157                <listitem>
158                  <para>
159                    If <computeroutput>Tag</computeroutput> corresponds to a unary prefix operator,
160                    then return
161                    <programlisting>OP Grammar()(<functionname>proto::child</functionname>(expr), state, data)</programlisting>
162                  </para>
163                </listitem>
164                <listitem>
165                  <para>
166                    If <computeroutput>Tag</computeroutput> corresponds to a unary postfix operator,
167                    then return
168                    <programlisting>Grammar()(<functionname>proto::child</functionname>(expr), state, data) OP</programlisting>
169                  </para>
170                </listitem>
171                <listitem>
172                  <para>
173                    If <computeroutput>Tag</computeroutput> corresponds to a binary infix operator,
174                    then return
175                    <programlisting>Grammar()(<functionname>proto::left</functionname>(expr), state, data) OP
176Grammar()(<functionname>proto::right</functionname>(expr), state, data)</programlisting>
177                  </para>
178                </listitem>
179                <listitem>
180                <para>
181                  If <computeroutput>Tag</computeroutput> is <computeroutput>
182                    <classname>proto::tag::subscript</classname>
183                  </computeroutput>,
184                  then return
185                  <programlisting>Grammar()(<functionname>proto::left</functionname>(expr), state, data) [
186Grammar()(<functionname>proto::right</functionname>(expr), state, data) ]</programlisting>
187                </para>
188                </listitem>
189                <listitem>
190                  <para>
191                    If <computeroutput>Tag</computeroutput> is <computeroutput>
192                      <classname>proto::tag::if_else_</classname>
193                    </computeroutput>,
194                    then return
195                    <programlisting>Grammar()(<functionname>proto::child_c</functionname>&lt;0&gt;(expr), state, data) ?
196Grammar()(<functionname>proto::child_c</functionname>&lt;1&gt;(expr), state, data) :
197Grammar()(<functionname>proto::child_c</functionname>&lt;2&gt;(expr), state, data)</programlisting>
198                  </para>
199                </listitem>
200                <listitem>
201                  <para>
202                    If <computeroutput>Tag</computeroutput> is <computeroutput>
203                      <classname>proto::tag::function</classname>
204                    </computeroutput>,
205                    then return
206                    <programlisting>Grammar()(<functionname>proto::child_c</functionname>&lt;0&gt;(expr), state, data) (
207Grammar()(<functionname>proto::child_c</functionname>&lt;1&gt;(expr), state, data),
208...
209Grammar()(<functionname>proto::child_c</functionname>&lt;N&gt;(expr), state, data) )</programlisting>
210                  </para>
211                </listitem>
212              </itemizedlist>
213            </description>
214            </method>
215          </method-group>
216          <description>
217            <para>
218              The behavior of this class is specified in terms of the C++0x <computeroutput>decltype</computeroutput>
219              keyword. In systems where this keyword is not available, Proto uses the Boost.Typeof library to
220              approximate the behavior.
221            </para>
222          </description>
223        </struct>
224      </struct>
225    </namespace>
226  </namespace>
227</header>
228