Definition of the
proto::pass_through<>
transform, which is the default transform of all of the expression generator metafunctions such as
proto::unary_plus<>,
proto::plus<> and
proto::nary_expr<>.
proto::deduce_domain
proto::transform< pass_through<Grammar, Domain> >
A PrimitiveTransform that transforms the child expressions of an expression
node according to the corresponding children of a Grammar. The resulting expression is in the specified domain.
Given a Grammar such as proto::plus<T0, T1>,
an expression type that matches the grammar such as
proto::plus<E0, E1>::type, a state
S and a data D, the result of applying
the proto::pass_through<proto::plus<T0, T1> >
transform is: proto::plus<
boost::result_of<T0(E0, S, D)>::type,
boost::result_of<T1(E1, S, D)>::type
>::type
The above demonstrates how child transforms and child expressions are applied pairwise, and how the
results are reassembled into a new expression node with the same tag type as the original.
The Domain
template parameter determines which domain the resulting expression should
be in. If it is proto::deduce_domain
, which is the default,
the resulting expression is in the same domain as the expression passed in. Otherwise, the resulting
expression is in the specified domain. Practically, that means the specified domain's generator is
used to post-process the resulting expression.
The explicit use of proto::pass_through<> is not usually
needed, since the expression generator metafunctions such as
proto::plus<> have
proto::pass_through<> as their default transform. So,
for instance, these are equivalent:
proto::when< proto::plus<X, Y>, proto::pass_through< proto::plus<X, Y> > >
proto::when< proto::plus<X, Y>, proto::plus<X, Y> >
proto::when< proto::plus<X, Y> > // because of proto::when<class X, class Y=X>
proto::plus<X, Y> // because plus<> is both a grammar and a transform
For example, consider the following transform that promotes all
float terminals in an expression to
double.
// This transform finds all float terminals in an expression and promotes
// them to doubles.
struct Promote :
proto::or_<
proto::when<proto::terminal<float>, proto::terminal<double>::type(proto::_value) >,
// terminal<>'s default transform is a no-op:
proto::terminal<proto::_>,
// nary_expr<> has a pass_through<> transform:
proto::nary_expr<proto::_, proto::vararg<Promote> >
>
{};
proto::transform_impl<Expr, State, Data>
For each N in [0,Expr arity), for exposition only
typename proto::result_of::child_c<Grammar, N>::type
For each N in [0,Expr arity), for exposition only
typename proto::result_of::child_c<Expr, N>::type
For each N in [0,Expr arity), for exposition only
typename boost::result_of<GN(EN,State,Data)>::type
For exposition only
typename Expr::proto_tag
For exposition only
boost::is_same<Domain, deduce_domain>
For exposition only
typename Expr::proto_domain
For exposition only
typename mpl::if_<Deduce, DD, Domain>::type
For exposition only
typename D::proto_generator
For exposition only
proto::listN<R0,...RN>
For exposition only
proto::expr<T, A>
For exposition only
proto::basic_expr<T, A>
For exposition only
typename mpl::if_<proto::wants_basic_expr<G>, BE, E>::type
typename boost::result_of<D(expr_type)>::type
result_type
typename impl::expr_param
typename impl::state_param
typename impl::data_param
proto::matches<Expr, Grammar>::value
is true.
D()(expr_type::make(
G0()(proto::child_c<0>(expr), state, data),
...
GN()(proto::child_c<N>(expr), state, data)
))