
David,
Thanks a lot. First example worked with Visual Studio 8. I also got your
book today, what a lucky day! Thanks for sharing your valuable thoughts with
the whole world.
Many Kind Regards,
Ovanes.
-----Original Message-----
From: David Abrahams [mailto:dave@boost-consulting.com]
Sent: Monday, June 19, 2006 15:10
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] mpl::transform question
"Ovanes Markarian"
Hello all,
somehow I have extreme difficulties to use mpl. Please do not understand this as any kind of blaming. I find the library really great and the possiblities it offers are tremendous. Currently I have some sort of problem, where I stuck at:
I have an mpl::vector instance of form (mpl namespace was left out for better readability):
class A; class B; class C;
typedef vector< pair
, A>, pair , B>, pair , C> > types_vector; Now I would like to use the mpl::transform algorithm to transform this vector into the mpl::map. I try to do it in the following way:
typedef mpl::transform
, mpl::_1 >::type type_map; And I also understand that _1 has no embedded typedefs for first and second, what a pair should have, so I am stuck here.
Well, transform doesn't look like the right algorithm to use in this way. What you're doing would produce a new vector of 3 single-element maps. You want to insert an element into a map, and then insert an element into the result of that insertion, etc. That's the pattern of the fold<> algorithm: fold< type_vector , map<> , insert<_,_> >::type copy is also probably an appropriate algorithm, but you'd need to use an Inserter. http://www.boost.org/libs/mpl/doc/refmanual/copy.html http://www.boost.org/libs/mpl/doc/refmanual/inserter.html http://www.boost.org/libs/mpl/doc/refmanual/inserters-inserter.html copy< type_vector , inserter< map<>, insert<_,_> > >::type Also, I'm afraid the MPL associative containers in 1.33.1 had some serious bugs that could prevent you from succeeding with this. I suggest if the above doesn't work, you first replace map<> with map0 in the examples, and then if that fails, check out the RC_1_34_0 branch from our CVS repository and try again. -- Dave Abrahams Boost Consulting www.boost-consulting.com