Boost logo

Boost :

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


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::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

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
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,

Boost list run by bdawes at, gregod at, cpdaniel at, john at