Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] deduce type of resulting vector from a transformation
From: Christopher Schmidt (mr.chr.schmidt_at_[hidden])
Date: 2010-10-10 06:17:54


Am 10.10.2010 12:02, schrieb alfC:
> Hi,
>
> (I keep struggling with Boos.Fusion.)
>
> How do I deduce the type of the vector resulting from the
> transformation of another vector?
>
> I have a source vector of different types, e.g.
> vector<quantity<si::length>, quantity<si::mass>, quantity<si::time>
>>
>
> and I have a transformation that is well defined and returns another
> type depending on the original type.
> The question is how do I generate a vector type that is the result of
> the given transformation. I though that
> result_of::transform was the function to obtain the result but it
> turns not because it returns a type transform_view instead of a
> vector.
>
> vector< ... > v1;
> T? v2(transform(v1, transformation()));
>
> i.e. what is the type of T as a fusion::vector as deduced from the
> type of v1 and the transformation type? -- Thank you, Alfredo--

You can generate a vector from an arbitrary fusion sequence using the
conversion metafunction:

http://www.boost.org/doc/libs/1_44_0/libs/fusion/doc/html/fusion/container/conversion/metafunctions/as_vector.html

fusion::result_of::as_vector<
        fusion::result_of::transform<
                v1,
                transformation
>::type
>::type v2(fusion::transform(v1, transformation()));

-Christopher


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