Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion][mpl] Generating a fusion sequence type from an MPL sequence
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-10-18 20:01:20


On 10/19/2010 3:24 AM, Gabriel Redner wrote:
> Hi all,
>
> I am unexpectedly stuck looking for some functionality which I assumed
> would be present. Given an MPL sequence, I want to generate the type
> of a corresponding fusion sequence, which I can then use to store
> things:
>
> mpl::vector<int, string> mpl_vec;
> typedef some_metafunction<mpl_vec>::type fusion_vec; // equivalent to
> fusion::vector<int, string>
> fusion_vec vec(5, "foo");
>
> Does some_metafunction exist? I'm not sure if I'm just not seeing it
> (or perhaps thinking wrongly about the problem), or if it really is
> not present.
>
> I was looking at the fusion/mpl bridge at [1], but its functionality
> seems orthogonal to what I want.
>
> Thanks,
> -Gabe
>
>
> [1] http://www.boost.org/doc/libs/1_44_0/libs/fusion/doc/html/fusion/adapted/mpl_sequence.html

Sure. Check out fusion::as_vector. You can use it to convert any fusion
compatible sequence to a fusion vector. MPL sequences are fusion
compatible.

     typedef fusion::result_of::as_vector<mpl_vec>::type fusion_vec;

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

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