Boost logo

Boost Users :

From: Christian Henning (chhenning_at_[hidden])
Date: 2006-08-22 10:57:27


Hi Joel,

>
> Oops, that should be
>
> typedef mpl::vector_c<int, 4> consts_type;
> typedef fusion::vector<int, float, int, double> vars_type;
>
> vars_type vars;
> fusion::joint_view<consts_type, vars_type> s3(consts_type(), vars);
>
> Anyway, I'm sure you got the point. With our 's3' above, we can,
> for exemple, write (using boost::lambda):
>
> fusion::for_each(s3, cout << _1 << endl);
>
> to print all the items.
>

I just tried your suggestion and it works until the fusion::for_each()
call. There, I get a million compiler errors. I'm sure I'm must
missing something simple here.

This is what I'm doing:

#include <iostream>
#include <tchar.h>

#include <boost/lambda/lambda.hpp>

#include <boost/mpl/vector_c.hpp>

#include <boost/fusion/algorithm.hpp>
#include <boost/fusion/sequence.hpp>

using namespace std;
using namespace boost;
using namespace boost::lambda;

struct s1
{
   static const int num_values = 1;

   int i;
};

struct s2
{
   static const int num_values = 2;

   int i;
   int j;
};

struct s3
{
   static const int num_values = 3;

   int i;
   int j;
   int k;
};

struct s4
{
   static const int num_values = 4;

   int i;
   float j;
   int k;
   double l;
};

template <class S> void doSomething( S& s )
{
   typedef mpl::vector_c<int, 4> consts_type;
   typedef fusion::vector<int, float, int, double> vars_type;

   vars_type vars;
   fusion::joint_view<consts_type, vars_type> view(consts_type(), vars);

   fusion::for_each( view, cout << _1 << endl );
}

int _tmain(int argc, _TCHAR* argv[])
{
   s4 s;

   doSomething( s );

        return 0;
}

When I got the CVS head there was no fusion documentation included. Is
that correct?

Greets,
Christian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net