//ChangeLog: // 2010-10-06.1207 CST // WHAT: // Followed Christopher's suggestions in post: // http://article.gmane.org/gmane.comp.lib.boost.user/62731 // RESULT: // Compiles with variadic fusion; however, still fails compile // without variadic fusion. // //WARNING@2010-09-29: // 1) Don't try to compile this code with that from: /* http://svn.boost.org/svn/boost/sandbox/variadic_templates/ */ // otherwise, you'll get a compile-time error about // mpl::vector0. // // 2) Only works with variadic fusion: /* http://svn.boost.org/svn/boost/sandbox/SOC/2009/fusion/ */ // otherwise, you'll get compile-time error in category_of.hpp // about joine_view<...>& not being class, struct, or union. // //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 namespace fold_join { struct join_ftor /**@brief * Forward decl of functor for joining 2 fusion sequences. */ ; 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<"<("< struct result; template struct result { typedef boost::fusion::joint_view < typename boost::remove_reference::type , typename boost::remove_reference::type > type ; }; template typename result::type operator()(Lhs& lhs, Rhs& rhs)const { return boost::fusion::joint_view< Lhs, Rhs >(lhs,rhs); } }; }//exit fold_join namespace using namespace boost; using namespace fold_join; int main(void) { typedef fusion::vector<> t0; typedef fusion::vector, tu, tu > t1; typedef fusion::vector, tu, tu > t2; typedef fusion::vector, tu, tu > t3; t0 v0; t1 v1(100,'b',300.1); t2 v2(100,'b',300.1); t3 v3(100,'b',300.1); std::cout<<"v0="< vv(v1,v2,v3); std::cout<<"vv="<