Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] How to transform types of fusion::map ?
From: Stjepan Rajko (stipe_at_[hidden])
Date: 2008-09-17 04:10:41


Hi Zeljko,

On Wed, Sep 17, 2008 at 8:25 AM, Zeljko Vrba <zvrba_at_[hidden]> wrote:
> A very concrete question:
>
> I have map<pair<K1, V1>, pair<K2, V2>, ..> as input. How do I produce
> map<pair<K1, std::vector<V1> >, pair<K2, std::vector<V2>, .. > on output?
>

Take a look at `transform` (algorithm/transformation/transform in the
docs), I think that should work for you. If you are only interested
in transforming the type, mpl::transform might work better (fusion's
transform is lazy, so to get the map type out you'd also need
`result_of::as_map` (container/conversion/metafunctions in the docs)).
 If you want to use mpl's transform on a fusion map, #include
<boost/fusion/include/mpl.hpp>

>
> - what is the purpose of for_each metafunction when the docs say that it
> always returns void? (and no side-effects are possible at compile-time)
>

fusion is not just compile-time - the types are compile time but the
values are run-time. Regardless, the function invoked by for_each can
have side-effects (there is also an mpl for_each which is useful).

Best,

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