Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Struct template fold

boost::proto::fold — A PrimitiveTransform that invokes the fusion::fold<> algorithm to accumulate a value.


// In header: <boost/proto/transform/fold.hpp>

template<typename Sequence, typename State0, typename Fun> 
struct fold :  proto::transform< fold<Sequence, State0, Fun> > {
  template<typename Expr, typename State, typename Data> 
  struct impl :  proto::transform_impl< Expr, State, Data > {
    // types
    typedef when<_, Sequence>                                        X;            // For exposition only
    typedef when<_, State0>                                          Y;            // For exposition only
    typedef typename boost::result_of<X(Expr, State, Data)>::type    seq;          // A Fusion sequence, for exposition only
    typedef typename boost::result_of<Y(Expr, State, Data)>::type    state0;       // An initial state for the fold, for exposition only
    typedef unspecified                                              fun;          // fun(v)(e,s) == when<_,Fun>()(e,s,v)
    typedef typename fusion::result_of::fold<seq, state0, fun>::type result_type;

    // public member functions
    result_type operator()(typename impl::expr_param, 
                           typename impl::state_param, 
                           typename impl::data_param) const;


For the complete description of the behavior of the proto::fold<> transform, see the documentation for the nested proto::fold::impl<> class template.