Boost logo

Boost Users :

Subject: [Boost-users] binary mpl::transform fails to compile with fusion::vector
From: Mike Tegtmeyer (tegtmeye_at_[hidden])
Date: 2009-06-17 10:09:48


I am hoping someone can point me the in right direction regarding this
code snippit failing to compile. My suspicion is that it is a header
problem but any help would be appreciated.

In short, I seem to be missing why the binary form of mpl::transform
won't work with fusion::vector. (unary form works just fine).

The code below just attempts to make a std::pair<> from the contents of
two sequences (this is just an example to illustrate the transform
problem). If the two sequences are mpl::vectors, everything is fine. If
they are fusion::vectors then 'lots of errors'.

I'm fairly new to both mpl and fusion so I am not ruling out the fact that
I have done something stupid.

Thanks in advance,
Mike

See code below.

#include <boost/mpl/transform.hpp>
#include <boost/mpl/vector.hpp>

#include <boost/fusion/include/mpl.hpp>
#include <boost/fusion/container/vector.hpp>

#include <utility>

using namespace boost;

struct my_make_pair {
   template<typename T1, typename T2>
   struct apply {
     typedef std::pair<T1,T2> type;
   };
};

int main(int argc, char *argv[])
{
#if 0
   typedef mpl::vector<int,long> seq1;
   typedef mpl::vector<float,double> seq2;
   typedef mpl::vector<std::pair<int,float>,std::pair<long,double> > pairs;

   typedef mpl::transform<seq1,seq2,my_make_pair>::type result;

   BOOST_MPL_ASSERT(( equal<result,pairs> ));
#endif

   typedef fusion::vector<int,long> seq1;
   typedef fusion::vector<float,double> seq2;
   typedef fusion::vector<std::pair<int,float>,std::pair<long,double> >
pairs;

   typedef mpl::transform<seq1,seq2,my_make_pair>::type result;

   BOOST_MPL_ASSERT(( equal<result,pairs> ));

   return 0;
}


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