Boost C++ 库

...世界上最受尊敬和设计最精良的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ 编码规范

PrevUpHomeNext

结构体模板 fold

boost::proto::fold — 一个 PrimitiveTransform,它调用 fusion::fold<> 算法来累积一个值。

概要

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

template<typename Sequence, typename State0, typename Fun> 
struct fold :  proto::transform< fold<Sequence, State0, Fun> > {
  // member classes/structs/unions
  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(d)(s,e) == when<_,Fun>()(e,s,d)
    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;
  };
};

描述

有关 proto::fold<> 转换的完整行为描述,请参阅嵌套的 proto::fold::impl<> 类模板的文档。


PrevUpHomeNext