Boost logo

Boost Users :

From: Stjepan Rajko (stipe_at_[hidden])
Date: 2007-12-01 19:27:58


On Dec 1, 2007 9:22 AM, Germán Diago <germandiago_at_[hidden]> wrote:
> Hello. I'm trying to build a library and I'm doing heavy use of boost mpl
> and fusion libraries. I'd like to know a way to fill a
> boost::fusion::vector<>
> with the types contained in a boost::mpl::vector. Anyone knows how to do
> this? The code I have so far:
>
> template <class T1, class T2, class T3, class T4, class T5, class T6, class
> T7, class T8, class T9, class T10>
> struct Func {
>
> //This is the initial sequence
> typedef typename boost::mpl::vector<T1, T2, T3, T4, T5, T6, T7, T8, T9,
> T10> sequence;
>
> //The sequence without NullTypes
> typedef typename boost::mpl::filter_view<sequence,
> boost::mpl::not_<boost::is_same<NullType, boost::mpl::_1> > >::type
> validsequence;
>
> //The vector I want to fill with validsequence. Note that this is a
> fusion vector, not a mpl vector
> typedef boost::fusion::vector<> voidvector;
>
>
> /***************PROBLEM HERE*******************/
> //I want to copy validsequence types into voidvector
> typedef typename somewaytocopy::type type;
> };
>

Hi Germán,

I think the following might work (untested):

#include <boost/fusion/include/mpl.hpp>
#include <boost/fusion/include/as_vector.hpp>

// ...

typedef typename
boost::fusion::result_of::as_vector<validsequence>::type
fusion_valid_sequence;

fusion_valid_sequence fusion_vector;

(You can't fill voidvector with the types, since you already made it a
fusion::vector<>)

HTH,

Stjepan


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