Boost logo

Boost Users :

Subject: Re: [Boost-users] from a variant to class with members templated over the variant types
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-09-21 10:22:52


AMDG

On 09/21/2011 05:44 AM, Olivier Tournaire wrote:
> I am not sure if the title is self explanatory, so, let me show an example
> of the goal.
>
> I have:
>
> variant<type1, type2, type3> v;
>
> I want:
>
> struct {
> anobject<type1> _type1_object;
> anobject<type2> _type2_object;
> anobject<type3> _type3_object;
> }
>
> Is there a way to do such a thing with boost pp (or something else)?
>

Something like this should work:

typedef variant<type1, type2, type3> variant_type;
typedef fusion::result_of::as_vector<
  mpl::transform<
    variant_type::types,
    anobject<mpl::_> >::type>::type vector_type;

In Christ,
Steven Watanabe




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