![]() |
Home | Libraries | People | FAQ | More |
boost::proto::pass_through — 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.
// In header: <boost/proto/transform/pass_through.hpp> template<typename Grammar, typename Domain = proto::deduce_domain> struct pass_through : proto::transform< pass_through<Grammar, Domain> > { // member classes/structs/unions template<typename Expr, typename State, typename Data> struct impl : proto::transform_impl<Expr, State, Data> { // types typedef ; // For each N in [0,Expr arity), for exposition only typedef ; // For each N in [0,Expr arity), for exposition only typedef ; // For each N in [0,Expr arity), for exposition only typedef ; // For exposition only typedef deduce_domain> ; // For exposition only typedef ; // For exposition only typedef ; // For exposition only typedef ; // For exposition only typedef proto::listN< ; // For exposition only typedef proto::expr< ; // For exposition only typedef proto::basic_expr< ; // For exposition only typedef proto::wants_basic_expr< ; // For exposition only typedef ; // public member functions (, , ) ; }; };
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<
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. proto::or_< proto::when<proto::terminal<proto::terminal<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<