Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::proto::pass_through< Grammar, Domain > Struct Template Reference

A PrimitiveTransform that transforms the child expressions of an expression node according to the corresponding children of a Grammar. More...

#include <pass_through.hpp>

Inheritance diagram for boost::proto::pass_through< Grammar, Domain >:
Collaboration diagram for boost::proto::pass_through< Grammar, Domain >:

Classes

struct  impl
 

Public Types

typedef pass_through< Grammar,
Domain > 
transform_type
 

Public Member Functions

 BOOST_PROTO_CALLABLE () typedef X proto_is_transform_
 
BOOST_FORCEINLINE
boost::proto::detail::apply_transform
< transform_type(Expr const &)>
::result_type 
operator() (Expr &&e) const
 
BOOST_FORCEINLINE
boost::proto::detail::apply_transform
< transform_type(Expr const
&, State const &)>
::result_type 
operator() (Expr &&e, State &&s) const
 
BOOST_FORCEINLINE
boost::proto::detail::apply_transform
< transform_type(Expr const
&, State const &, Data const &)>
::result_type 
operator() (Expr &&e, State &&s, Data &&d) const
 

Detailed Description

template<typename Grammar, typename Domain>
struct boost::proto::pass_through< Grammar, Domain >

A PrimitiveTransform that transforms the child expressions of an expression node according to the corresponding children of a Grammar.

Given a Grammar such as plus<T0, T1>, an expression type that matches the grammar such as plus<E0, E1>::type, a state S and a data V, the result of applying the pass_through<plus<T0, T1> > transform is:

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 explicit use of pass_through<> is not usually needed, since the expression generator metafunctions such as plus<> have pass_through<> as their default transform. So, for instance, these are equivalent:

// Within a grammar definition, these are equivalent:
when< plus<X, Y>, pass_through< plus<X, Y> > >
when< plus<X, Y>, plus<X, Y> >
when< plus<X, Y> > // because of when<class X, class Y=X>
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
: or_<
when<terminal<float>, terminal<double>::type(_value) >
// terminal<>'s default transform is a no-op:
, terminal<_>
// nary_expr<> has a pass_through<> transform:
, nary_expr<_, vararg<Promote> >
>
{};

Member Typedef Documentation

typedef pass_through< Grammar, Domain > boost::proto::transform< pass_through< Grammar, Domain > , X >::transform_type
inherited

Member Function Documentation

boost::proto::transform< pass_through< Grammar, Domain > , X >::BOOST_PROTO_CALLABLE ( )
inherited
BOOST_FORCEINLINE boost::proto::detail::apply_transform<transform_type(Expr const &, State const &, Data const &)>::result_type boost::proto::transform< pass_through< Grammar, Domain > , X >::operator() ( Expr &&  e,
State &&  s,
Data &&  d 
) const
inlineinherited
BOOST_FORCEINLINE boost::proto::detail::apply_transform<transform_type(Expr const &, State const &)>::result_type boost::proto::transform< pass_through< Grammar, Domain > , X >::operator() ( Expr &&  e,
State &&  s 
) const
inlineinherited
BOOST_FORCEINLINE boost::proto::detail::apply_transform<transform_type(Expr const &)>::result_type boost::proto::transform< pass_through< Grammar, Domain > , X >::operator() ( Expr &&  e) const
inlineinherited

The documentation for this struct was generated from the following file: