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

A PrimitiveTransform that recursively applies the reverse_fold<> transform to sub-trees that all share a common tag type. More...

#include <fold_tree.hpp>

Inheritance diagram for boost::proto::reverse_fold_tree< Sequence, State0, Fun >:
Collaboration diagram for boost::proto::reverse_fold_tree< Sequence, State0, Fun >:

Classes

struct  impl
 
struct  impl< Expr &, State, Data >
 

Public Types

typedef reverse_fold_tree
< Sequence, State0, Fun > 
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 Sequence, typename State0, typename Fun>
struct boost::proto::reverse_fold_tree< Sequence, State0, Fun >

A PrimitiveTransform that recursively applies the reverse_fold<> transform to sub-trees that all share a common tag type.

reverse_fold_tree<> is useful for flattening trees into lists; for example, you might use reverse_fold_tree<> to flatten an expression tree like a | b | c into a Fusion list like cons(a, cons(b, cons(c))).

reverse_fold_tree<> is easily understood in terms of a recurse_if_<> helper, defined as follows:

template<typename Tag, typename Fun>
struct recurse_if_
: if_<
// If the current node has type "Tag" ...
is_same<tag_of<_>, Tag>()
// ... recurse, otherwise ...
, reverse_fold<_, _state, recurse_if_<Tag, Fun> >
// ... apply the Fun transform.
, Fun
>
{};

With recurse_if_<> as defined above, reverse_fold_tree<Sequence, State0, Fun>()(e, s, d) is equivalent to reverse_fold<Sequence, State0, recurse_if_<Expr::proto_tag, Fun> >()(e, s, d). It has the effect of folding a tree back-to-front, recursing into child nodes that share a tag type with the parent node.

Member Typedef Documentation

typedef reverse_fold_tree< Sequence, State0, Fun > boost::proto::transform< reverse_fold_tree< Sequence, State0, Fun > , X >::transform_type
inherited

Member Function Documentation

boost::proto::transform< reverse_fold_tree< Sequence, State0, Fun > , 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< reverse_fold_tree< Sequence, State0, Fun > , 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< reverse_fold_tree< Sequence, State0, Fun > , X >::operator() ( Expr &&  e,
State &&  s 
) const
inlineinherited
BOOST_FORCEINLINE boost::proto::detail::apply_transform<transform_type(Expr const &)>::result_type boost::proto::transform< reverse_fold_tree< Sequence, State0, Fun > , X >::operator() ( Expr &&  e) const
inlineinherited

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