
Hello, I'm trying to convert an MPL map to a fusion map using boost::fusion::result_of::as_map. I have the following code, with some of the leading-in code omitted for brevity although I don't think it's relevant: //listener_info_types := mpl::list< pair<handler<E>, token<H> > > typedef typename boost::mpl::transform< handler_types, token_types, parameterize_pair<boost::mpl::_1, boost::mpl::_2> >::type listener_info_types; //listener_info_lookup = mpl::map<EventType, pair<handler<E>, token<H> > typedef typename boost::mpl::transform< SupportedEvents, listener_info_types, boost::mpl::inserter< boost::mpl::map<>, boost::mpl::identity<boost::mpl::_1> > >::type listener_info_lookup; typedef typename boost::fusion::result_of::as_map<listener_info_lookup>::type fusion_listener_map; Deleting the last line and everything works. I've successfully used a similar technique to convert mpl vectors to fusion vectors in the past, is it not possible for maps? Or more likely I'm just doing something wrong? I can post more code if necessary including full type definitions leading up to all these previous typedefs, but basically I have a class parameterized initially with an mpl::list of some number of types. I then do a sequence of mpl::transform calls, none of which with use a custom inserter. The end result of all of that is listener_info_types above. So listener_info_types should be an mpl::list. The next call should then create an mpl::map, (SupportedEvents is the initial type used to parameterize the class, so an mpl::list as previously mentioned). Any suggestions? Thanks Zach

On Mon, Aug 10, 2009 at 10:37 PM, Zachary Turner<divisortheory@gmail.com> wrote:
Hello, I'm trying to convert an MPL map to a fusion map using boost::fusion::result_of::as_map. I have the following code, with some of the leading-in code omitted for brevity although I don't think it's relevant:
Heh, apparently all I need to do was #include <boost/fusion/include/mpl.hpp> In the process I ran across the documentation for the mpl adapted sequences (http://www.boost.org/doc/libs/1_39_0/libs/fusion/doc/html/fusion/adapted/mpl...). Is there any difference between using result_of::as_map and this approach? With the adapted approach, can I simply declare an mpl::map on the stack and modify its internal items at runtime?

AMDG Zachary Turner wrote:
On Mon, Aug 10, 2009 at 10:37 PM, Zachary Turner<divisortheory@gmail.com> wrote:
Hello, I'm trying to convert an MPL map to a fusion map using boost::fusion::result_of::as_map. I have the following code, with some of the leading-in code omitted for brevity although I don't think it's relevant:
Heh, apparently all I need to do was
#include <boost/fusion/include/mpl.hpp>
In the process I ran across the documentation for the mpl adapted sequences (http://www.boost.org/doc/libs/1_39_0/libs/fusion/doc/html/fusion/adapted/mpl...). Is there any difference between using result_of::as_map and this approach? With the adapted approach, can I simply declare an mpl::map on the stack and modify its internal items at runtime?
An mpl::map doesn't store any data members. when it is viewed as a fusion sequence, the values are default constructed on the fly. In Christ, Steven Watanabe
participants (2)
-
Steven Watanabe
-
Zachary Turner