//Purpose: // Answer question in post: // // http://article.gmane.org/gmane.comp.lib.boost.user/62386 // //References: // [ffold] // http://www.boost.org/doc/libs/1_44_0/libs/fusion/doc/html // /fusion/algorithm/iteration/functions/fold.html // #include #include #include #include #include #include struct join_ftor /**@brief * Forward decl of functor for joining 2 fusion sequences. */ ; namespace boost { template < typename LhSequence , typename RhSequence > struct result_of < join_ftor(LhSequence const,RhSequence const) > /**@brief * As specified by table 1.37 Requirement for Parameter f * in [ffold]. */ : fusion::result_of::join { }; }//exit boost namespace struct join_ftor /**@brief * modified from 'struct make_string' from [ffold]. */ { template typename boost::result_of::type operator()(LhSequence const& lhs, RhSequence const& rhs)const { return boost::fusion::join(lhs,rhs); } }; template struct tu { tu(T a_t):my_t(a_t){} T my_t; friend std::ostream& operator<< ( std::ostream& sout , tu const& x ) { sout<<"tu<"<("< state0; typedef fusion::vector, tu, tu > t0; t0 v0(100,'b',300.1); typedef fusion::vector, tu, tu > t1; t1 v1(100,'b',300.1); std::cout<<"v0="< vv(v0,v1); join_ftor joiner; auto fold_vv=fusion::fold(vv,state0,joiner); std::cout <<"fold(vv,state0,join_ftor())=" <