Boost logo

Boost Users :

Subject: [Boost-users] [Boost] [Fusion] Help with tuple adapter
From: Bill Nell (bnell_at_[hidden])
Date: 2010-01-20 14:52:41


Hi all,
I'm having some trouble getting the boost fusion tuple adapter working (the one that makes boost::tuples into conforming sequence types). I'm assuming that the adapted tuple should now be a legal MPL sequence but mpl::is_sequence yields false and consequently mpl::for_each doesn't work on the tuple type either. The following program is an illustration of what I am trying to do. I guess I must be missing something simple?

Any help would be appreciated.
Bill

#include <iostream>
#include <typeinfo>

#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/for_each.hpp>

#include <boost/fusion/tuple.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/iterator.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/fusion/adapted/boost_tuple.hpp>

struct helper {
 template <typename TT> void operator()(TT)
 {
   std::cout << typeid(TT).name() << std::endl;
 }
};

int main()
{
 typedef boost::fusion::tuple<int,char,double> FTUP;
 typedef boost::tuple<int,char,double> BTUP;

 // this works
 std::cout << boost::mpl::is_sequence<FTUP>::value << std::endl;
 std::cout << "fusion tuple\n";
 boost::mpl::for_each<FTUP>(helper());

 // this doesn't work
 std::cout << boost::mpl::is_sequence<BTUP>::value << std::endl;
 // the following lines won't compile because the BTUP is not a
 // sequence type.
 //std::cout << "boost tuple\n";
 //mpl::for_each<BTUP>(helper());

 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