views:

577

answers:

3

How to generate fusion::vector from mpl::vector? How to generate mpl::vector from fusion::vector?

BOOST_MPL_ASSERT((is_same<
                  fusion::vector<int, char>,
                  generate_fusion_vector<mpl::vector<int, char> >::type >));

BOOST_MPL_ASSERT((is_same<
                  mpl::vector<int, char>,
                  generate_mpl_vector<fusion::vector<int, char> >::type >));

I need generate_fusion_vector and generate_mpl_vector metafunctions. I can write my own metafunctions, but i suspect that they already exist.

I had an experience of generating fusion::map with help result_of::as_map before, but in current boost(trunk, 1.39 also) such error occur:

D:\Libraries\boost_trunk\boost/fusion/sequence/intrinsic/size.hpp(56) : error C2903: 'apply' : symbol is neither a class template nor a function template
        D:\Libraries\boost_trunk\boost/fusion/container/vector/convert.hpp(23) : see reference to class template instantiation 'boost::fusion::result_of::size' being compiled
        with
        [
            Sequence=boost::mpl::vector
        ]
        temp.cpp(71) : see reference to class template instantiation 'boost::fusion::result_of::as_vector' being compiled

I don't understand what is going on?

+4  A: 

As fusion accepts mpl types as arguments to functions you could try this:

BOOST_MPL_ASSERT((is_same<
fusion::vector<int, char>,
fusion::result_of::as_vector<mpl::vector<int, char> >::type >));

Edit:

I think the reason this isn't working for you is that you have to include certain header files to enable mpl compatibility in fusion.

#include <boost/fusion/adapted/mpl.hpp>
#include <boost/fusion/include/mpl.hpp>
Matthew Monaghan
I generated fusion::map with help result_of::as_map before, but in current boost(trunk, 1.39 also) such error occur:<pre>D:\Libraries\boost_trunk\boost/fusion/sequence/intrinsic/size.hpp(56) : error C2903: 'apply' : symbol is neither a class template nor a function template D:\Libraries\boost_trunk\boost/fusion/container/vector/convert.hpp(23) : see reference to class template instantiation 'boost::fusion::result_of::size<Sequence>' being compiled with [ Sequence=boost::mpl::vector<int,char> ]</pre>I don't understand what is going on?
Andreo
A: 

I generated fusion::map with help result_of::as_map before, but in current boost(trunk, 1.39 also) such error occur:

D:\Libraries\boost_trunk\boost/fusion/sequence/intrinsic/size.hpp(56) : error C2903: 'apply' : symbol is neither a class template nor a function template
        D:\Libraries\boost_trunk\boost/fusion/container/vector/convert.hpp(23) : see reference to class template instantiation 'boost::fusion::result_of::size' being compiled
        with
        [
            Sequence=boost::mpl::vector
        ]
        temp.cpp(71) : see reference to class template instantiation 'boost::fusion::result_of::as_vector' being compiled

I don't understand what is going on?

Andreo
You should probably edit this into your original question. It sounds like you had it working before the new version of boost? If so that's a more specific question and you may get better help.
Matthew Monaghan
A: 

I don't know if you're still doing char,int but I ran into the same error and my problem was that I tried to make a length 11 vector, but FUSION_MAX_VECTOR_SIZE was 10.

Lau Lau Labs