|
Boost Users : |
Subject: Re: [Boost-users] Variant and Fusion
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-03-10 20:25:02
AMDG
Matthias Vallentin wrote:
>> In particular how are the runtime values of the elements of the
>> sequence to be determined?
>>
>
> Conceptually, I am thinking of a visitor that goes over the variant and
> flattens it. In the above example, the corresponding sequence would be
>
> [42, 4.2, 42, 4.2]
>
> which corresponds to a fusion::vector<int, double, int, double>.
> Practically, I don't see a way how to get the type of the vector at
> runtime unless knowing in advance the type of the fusion vector (which
> could be a potential assumption).
>
You have to know the type of the vector at compile time.
> I was also talking about "chopping" the variant in disjunct sequences.
> By this, I mean that a visitor goes over the variant and creates several
> sequences, say
>
> [42]
> [4.2, 42]
> [42]
>
I think the easiest way is probably to create a runtime
iterator that walks over the vector and recurses into
any variants that it contains. Then you can use fusion's
algorithms to iterate over the fusion::vector and the
vector in parallel.
> for the above example. That's the scenario I ultimately target. Ideally,
> these sequences are only views (tiers) of the original variant.
>
If you want it to be a view, you can use a fusion vector of references.
>> Depending on what you're doing, you might be able to use the nested
>> types typedef of variant, which is an MPL sequence.
>>
>
> Are you referring to the variant<T>::types MPL sequence?
>
Yes.
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