|
Boost Users : |
From: John C. Femiani (john.femiani_at_[hidden])
Date: 2008-08-14 01:44:03
Steven Watanabe wrote:
> AMDG
>
> John C. Femiani wrote:
>> I was just wondering why fusion (and mpl) don't include multi-maps or
>> multi-sets. Are they unnecessary at compile time? Are they too
>> trivial? Do they conceptually not work?
>
> The easiest way to implement a multimap is in terms of an ordinary map.
> In a fusion/mpl map the key is a type
> and lookup uses overload resolution. This means that there
> is necessarily a 1-1 correspondence between keys and values.
I would expect a multimap to contain pairs, and to provide an iterator
range or sequence of like keys via an 'equal_range' function (like
unordered_multimap).
I also just noticed there is no 'equal_range' query metafunction,
although there is a 'lower_bound' and 'upper_bound'.
> The obvious way to implement a multimap is to make the
> value a container. Because of the function nature of
> fusion/mpl this would be like
>
> template<class M, class K, class V>
> struct multimap_insert_existing {
> typedef typename insert<typename erase_key<M, K>::type, pair<K,
> typename push_back<typename at<M, K>::type, V>::type> > type;
> };
>
<more code>
So it is feasible, but the authors just wanted to keep the scope limited?
That works for me; I've been toying with that idea anyhow but I wanted
to make sure I was not going waste my time.
Thanks,
--John
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