Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] How to transform types of fusion::map ?
From: Zeljko Vrba (zvrba_at_[hidden])
Date: 2008-09-17 07:44:30


On Wed, Sep 17, 2008 at 10:10:41AM +0200, Stjepan Rajko wrote:
>
> Take a look at `transform` (algorithm/transformation/transform in the
>

For anyone else who might be interested, transform_view seems to do the trick:

// Metafunction to convert from T=pair<K, V> to pair<K, std::vector<V>>.
struct t2v
{
        template<typename T>
        struct result;

        template<typename T>
        struct result<t2v(T)>
        {
                typedef typename boost::remove_reference<T>::type pair_type;
                typedef BF::pair<
                        typename pair_type::first_type,
                        std::vector<typename pair_type::second_type>
> type;
        };
};

template<typename BaseMap>
struct x : public
  BF::result_of::as_map<BF::transform_view<BaseMap, t2v> >::type
{ .. };

[BF is my shorthand for boost::fusion]


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