1 <?xml version=
"1.0" encoding=
"utf-8"?>
3 Copyright 2012 Eric Niebler
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)
9 <header name=
"boost/proto/transform/default.hpp">
10 <namespace name=
"boost">
11 <namespace name=
"proto">
12 <struct name=
"_default">
14 <template-type-parameter name=
"Grammar">
15 <default><replaceable>unspecified
</replaceable></default>
16 </template-type-parameter>
18 <inherit><classname>proto::transform
</classname>< _default
<Grammar
> ></inherit>
19 <purpose>A
<conceptname>PrimitiveTransform
</conceptname> that gives expressions their
20 usual C++ behavior
</purpose>
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
<></classname>
26 </computeroutput> class template.
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
<></computeroutput>.
36 <template-type-parameter name=
"Expr"/>
37 <template-type-parameter name=
"State"/>
38 <template-type-parameter name=
"Data"/>
40 <inherit><type><classname>proto::transform_impl
</classname><Expr, State, Data
></type></inherit>
42 <purpose>For exposition only
</purpose>
43 <type>typename Expr::tag_type
</type>
45 <data-member name=
"s_expr" specifiers=
"static">
46 <purpose>For exposition only
</purpose>
49 <data-member name=
"s_state" specifiers=
"static">
50 <purpose>For exposition only
</purpose>
53 <data-member name=
"s_data" specifiers=
"static">
54 <purpose>For exposition only
</purpose>
57 <typedef name=
"result_type">
58 <type><emphasis>see-below
</emphasis></type>
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)
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
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)
91 If
<computeroutput>Tag
</computeroutput> is
<computeroutput>
92 <classname>proto::tag::subscript
</classname>
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) ]
103 If
<computeroutput>Tag
</computeroutput> is
<computeroutput>
104 <classname>proto::tag::if_else_
</classname>
106 then the result type is
107 <programlisting>decltype(
108 Grammar()(
<functionname>proto::child_c
</functionname><0>(s_expr), s_state, s_data) ?
109 Grammar()(
<functionname>proto::child_c
</functionname><1>(s_expr), s_state, s_data) :
110 Grammar()(
<functionname>proto::child_c
</functionname><2>(s_expr), s_state, s_data)
116 If
<computeroutput>Tag
</computeroutput> is
<computeroutput>
117 <classname>proto::tag::function
</classname>
119 then the result type is
120 <programlisting>decltype(
121 Grammar()(
<functionname>proto::child_c
</functionname><0>(s_expr), s_state, s_data) (
122 Grammar()(
<functionname>proto::child_c
</functionname><1>(s_expr), s_state, s_data),
124 Grammar()(
<functionname>proto::child_c
</functionname><N
>(s_expr), s_state, s_data) )
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>.)
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>
146 <parameter name=
"state">
147 <paramtype>typename impl::state_param
</paramtype>
149 <parameter name=
"data">
150 <paramtype>typename impl::data_param
</paramtype>
154 <classname>proto::_default
</classname><Grammar
>::impl
<Expr, State, Data
>::operator()
155 </computeroutput> returns the following:
159 If
<computeroutput>Tag
</computeroutput> corresponds to a unary prefix operator,
161 <programlisting>OP Grammar()(
<functionname>proto::child
</functionname>(expr), state, data)
</programlisting>
166 If
<computeroutput>Tag
</computeroutput> corresponds to a unary postfix operator,
168 <programlisting>Grammar()(
<functionname>proto::child
</functionname>(expr), state, data) OP
</programlisting>
173 If
<computeroutput>Tag
</computeroutput> corresponds to a binary infix operator,
175 <programlisting>Grammar()(
<functionname>proto::left
</functionname>(expr), state, data) OP
176 Grammar()(
<functionname>proto::right
</functionname>(expr), state, data)
</programlisting>
181 If
<computeroutput>Tag
</computeroutput> is
<computeroutput>
182 <classname>proto::tag::subscript
</classname>
185 <programlisting>Grammar()(
<functionname>proto::left
</functionname>(expr), state, data) [
186 Grammar()(
<functionname>proto::right
</functionname>(expr), state, data) ]
</programlisting>
191 If
<computeroutput>Tag
</computeroutput> is
<computeroutput>
192 <classname>proto::tag::if_else_
</classname>
195 <programlisting>Grammar()(
<functionname>proto::child_c
</functionname><0>(expr), state, data) ?
196 Grammar()(
<functionname>proto::child_c
</functionname><1>(expr), state, data) :
197 Grammar()(
<functionname>proto::child_c
</functionname><2>(expr), state, data)
</programlisting>
202 If
<computeroutput>Tag
</computeroutput> is
<computeroutput>
203 <classname>proto::tag::function
</classname>
206 <programlisting>Grammar()(
<functionname>proto::child_c
</functionname><0>(expr), state, data) (
207 Grammar()(
<functionname>proto::child_c
</functionname><1>(expr), state, data),
209 Grammar()(
<functionname>proto::child_c
</functionname><N
>(expr), state, data) )
</programlisting>
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.