Boost logo

Boost :

From: Sergei Politov (spolitov_at_[hidden])
Date: 2008-04-05 23:26:59


Hi,

Quite frenquently I'm facing the problem of creating fusion::map where the
value can be determined by key using some metafunction. For instance:
fusion::map<
fusion::pair<int, std::vector<int> >,
fusion::pair<char, std::vector<char> >
> my_map;

I did not find such ready to use functionality in fusion (may be my miss).

So I created utility metafunction to generate such maps.
For provided example, the usage of this class is the following:
template<class T>
struct make_vector {
typedef std::vector<T> type;
};

typedef mstd::map_gen<boost::mpl::vector<int, char>, make_vector>::type
my_map;

In other words it takes some fusion sequence and metafunction. The result is

fusion map with keys from the specified sequence and values generated from
keys
using specified metafunction.

I've found this metafunction very useful, also it easily solves the problem
discussed in boost.user list: "Need boost's help with poor design".

May be somebody also interested in this metafuction.

Best Regards,
  Sergei


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk