|
Boost Users : |
From: Christian Henning (chhenning_at_[hidden])
Date: 2007-03-19 15:38:44
My fault. I was using forward class declarations instead of class
definitions. This works now:
#include <vector>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/sequence/adapted/mpl.hpp>
#include <boost/fusion/sequence/container.hpp>
#include <boost/fusion/sequence/conversion/as_list.hpp>
using namespace std;
using namespace boost;
template <typename T>
struct add_vector
{
typedef std::vector<T> type;
};
struct A { void print() { cout << "A" << endl; }};
struct B { void print() { cout << "B" << endl; }};
struct C { void print() { cout << "C" << endl; }};
struct create_empty_vec
{
template< class T >
std::vector<T> operator()( T& t ) const
{
return std::vector<T>();
}
};
struct add_one
{
template< class T >
void operator()( T& vec ) const
{
vec.push_back( T::value_type() );
}
};
struct print
{
template< class T >
void operator()( T& vec ) const
{
vec[0].print();
}
};
int main()
{
typedef mpl::list< A, B, C > _types_;
typedef mpl::transform1< _types_, add_vector<mpl::_1> >::type
_mpl_list_of_vectors_;
typedef fusion::result_of::as_list<_mpl_list_of_vectors_>::type
_fusion_list_of_vectors_;
_fusion_list_of_vectors_ vectors;
fusion::for_each( vectors, create_empty_vec() );
fusion::for_each( vectors, add_one() );
fusion::for_each( vectors, print() );
return 0;
}
Sorry for the noise,
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